Skip to content

Commit ca792ee

Browse files
committed
Remove deprecated functions
1 parent 4da3bce commit ca792ee

File tree

6 files changed

+51
-158
lines changed

6 files changed

+51
-158
lines changed

conda_build/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3501,7 +3501,7 @@ def test(
35013501
AssertionError,
35023502
) as exc:
35033503
log.warn(
3504-
"failed to get install actions, retrying. exception was: %s", str(exc)
3504+
"failed to get package records, retrying. exception was: %s", str(exc)
35053505
)
35063506
tests_failed(
35073507
metadata,

conda_build/environ.py

+41-100
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767

6868
log = getLogger(__name__)
6969

70-
PREFIX_ACTION = "PREFIX"
71-
LINK_ACTION = "LINK"
70+
deprecated.constant("24.3", "24.5", "PREFIX_ACTION", _PREFIX_ACTION := "PREFIX")
71+
deprecated.constant("24.3", "24.5", "LINK_ACTION", _LINK_ACTION := "LINK")
7272

7373
# these are things that we provide env vars for more explicitly. This list disables the
7474
# pass-through of variant values to env vars for these keys.
@@ -852,7 +852,8 @@ def package_specs(self):
852852
return specs
853853

854854

855-
cached_actions = {}
855+
cached_precs = {}
856+
deprecated.constant("24.3", "24.5", "cached_actions", cached_precs)
856857
last_index_ts = 0
857858

858859

@@ -872,9 +873,9 @@ def get_package_records(
872873
output_folder=None,
873874
channel_urls=None,
874875
):
875-
global cached_actions
876+
global cached_precs
876877
global last_index_ts
877-
actions = {}
878+
precs = {}
878879
log = utils.get_logger(__name__)
879880
conda_log_level = logging.WARN
880881
specs = list(specs)
@@ -912,18 +913,16 @@ def get_package_records(
912913
subdir,
913914
channel_urls,
914915
disable_pip,
915-
) in cached_actions and last_index_ts >= index_ts:
916-
actions = cached_actions[(specs, env, subdir, channel_urls, disable_pip)].copy()
917-
if PREFIX_ACTION in actions:
918-
actions[PREFIX_ACTION] = prefix
916+
) in cached_precs and last_index_ts >= index_ts:
917+
precs = cached_precs[(specs, env, subdir, channel_urls, disable_pip)].copy()
919918
elif specs:
920919
# this is hiding output like:
921920
# Fetching package metadata ...........
922921
# Solving package specifications: ..........
923922
with utils.LoggingContext(conda_log_level):
924923
with capture():
925924
try:
926-
actions = _install_actions(prefix, index, specs)
925+
precs = _install_actions(prefix, index, specs)[_LINK_ACTION]
927926
except (NoPackagesFoundError, UnsatisfiableError) as exc:
928927
raise DependencyNeedsBuildingError(exc, subdir=subdir)
929928
except (
@@ -937,7 +936,7 @@ def get_package_records(
937936
) as exc:
938937
if "lock" in str(exc):
939938
log.warn(
940-
"failed to get install actions, retrying. exception was: %s",
939+
"failed to get package records, retrying. exception was: %s",
941940
str(exc),
942941
)
943942
elif (
@@ -966,10 +965,10 @@ def get_package_records(
966965
utils.rm_rf(pkg_dir)
967966
if retries < max_env_retry:
968967
log.warn(
969-
"failed to get install actions, retrying. exception was: %s",
968+
"failed to get package records, retrying. exception was: %s",
970969
str(exc),
971970
)
972-
actions = get_install_actions(
971+
precs = get_package_records(
973972
prefix,
974973
tuple(specs),
975974
env,
@@ -987,7 +986,7 @@ def get_package_records(
987986
)
988987
else:
989988
log.error(
990-
"Failed to get install actions, max retries exceeded."
989+
"Failed to get package records, max retries exceeded."
991990
)
992991
raise
993992
if disable_pip:
@@ -997,49 +996,10 @@ def get_package_records(
997996
if not any(
998997
re.match(r"^%s(?:$|[\s=].*)" % pkg, str(dep)) for dep in specs
999998
):
1000-
actions[LINK_ACTION] = [
1001-
prec for prec in actions[LINK_ACTION] if prec.name != pkg
1002-
]
1003-
utils.trim_empty_keys(actions)
1004-
cached_actions[(specs, env, subdir, channel_urls, disable_pip)] = actions.copy()
999+
precs = [prec for prec in precs if prec.name != pkg]
1000+
cached_precs[(specs, env, subdir, channel_urls, disable_pip)] = precs.copy()
10051001
last_index_ts = index_ts
1006-
return actions.get(LINK_ACTION, [])
1007-
1008-
1009-
@deprecated("24.1.0", "24.3.0", addendum="Use `get_package_records` instead.")
1010-
def get_install_actions(
1011-
prefix,
1012-
specs,
1013-
env,
1014-
retries=0,
1015-
subdir=None,
1016-
verbose=True,
1017-
debug=False,
1018-
locking=True,
1019-
bldpkgs_dirs=None,
1020-
timeout=900,
1021-
disable_pip=False,
1022-
max_env_retry=3,
1023-
output_folder=None,
1024-
channel_urls=None,
1025-
):
1026-
precs = get_package_records(
1027-
prefix=prefix,
1028-
specs=specs,
1029-
env=env,
1030-
retries=retries,
1031-
subdir=subdir,
1032-
verbose=verbose,
1033-
debug=debug,
1034-
locking=locking,
1035-
bldpkgs_dirs=bldpkgs_dirs,
1036-
timeout=timeout,
1037-
disable_pip=disable_pip,
1038-
max_env_retry=max_env_retry,
1039-
output_folder=output_folder,
1040-
channel_urls=channel_urls,
1041-
)
1042-
return {PREFIX_ACTION: prefix, LINK_ACTION: precs}
1002+
return precs
10431003

10441004

10451005
def create_env(
@@ -1081,12 +1041,9 @@ def create_env(
10811041
try:
10821042
with utils.try_acquire_locks(locks, timeout=config.timeout):
10831043
# input is a list of specs in MatchSpec format
1084-
if not (
1085-
hasattr(specs_or_precs, "keys")
1086-
or isinstance(specs_or_precs[0], PackageRecord)
1087-
):
1044+
if not isinstance(specs_or_precs[0], PackageRecord):
10881045
specs = list(set(specs_or_precs))
1089-
actions = get_install_actions(
1046+
precs = get_package_records(
10901047
prefix,
10911048
tuple(specs),
10921049
env,
@@ -1102,10 +1059,7 @@ def create_env(
11021059
channel_urls=tuple(config.channel_urls),
11031060
)
11041061
else:
1105-
if not hasattr(specs_or_precs, "keys"):
1106-
actions = {LINK_ACTION: specs_or_precs}
1107-
else:
1108-
actions = specs_or_precs
1062+
precs = specs_or_precs
11091063
index, _, _ = get_build_index(
11101064
subdir=subdir,
11111065
bldpkgs_dir=config.bldpkgs_dir,
@@ -1116,14 +1070,13 @@ def create_env(
11161070
locking=config.locking,
11171071
timeout=config.timeout,
11181072
)
1119-
utils.trim_empty_keys(actions)
1120-
_display_actions(prefix, actions)
1073+
_display_actions(prefix, precs)
11211074
if utils.on_win:
11221075
for k, v in os.environ.items():
11231076
os.environ[k] = str(v)
11241077
with env_var("CONDA_QUIET", not config.verbose, reset_context):
11251078
with env_var("CONDA_JSON", not config.verbose, reset_context):
1126-
_execute_actions(prefix, actions)
1079+
_execute_actions(prefix, precs)
11271080
except (
11281081
SystemExit,
11291082
PaddingError,
@@ -1158,15 +1111,13 @@ def create_env(
11581111
)
11591112
config.prefix_length = 80
11601113

1161-
host = "_h_env" in prefix
1162-
# Set this here and use to create environ
1163-
# Setting this here is important because we use it below (symlink)
1164-
prefix = config.host_prefix if host else config.build_prefix
1165-
actions[PREFIX_ACTION] = prefix
1166-
11671114
create_env(
1168-
prefix,
1169-
actions,
1115+
(
1116+
config.host_prefix
1117+
if "_h_env" in prefix
1118+
else config.build_prefix
1119+
),
1120+
specs_or_precs,
11701121
config=config,
11711122
subdir=subdir,
11721123
env=env,
@@ -1307,7 +1258,7 @@ def remove_existing_packages(dirs, fns, config):
13071258

13081259
def get_pinned_deps(m, section):
13091260
with TemporaryDirectory(prefix="_") as tmpdir:
1310-
actions = get_install_actions(
1261+
precs = get_package_records(
13111262
tmpdir,
13121263
tuple(m.ms_depends(section)),
13131264
section,
@@ -1322,10 +1273,7 @@ def get_pinned_deps(m, section):
13221273
output_folder=m.config.output_folder,
13231274
channel_urls=tuple(m.config.channel_urls),
13241275
)
1325-
runtime_deps = [
1326-
package_record_to_requirement(prec) for prec in actions.get(LINK_ACTION, [])
1327-
]
1328-
return runtime_deps
1276+
return [package_record_to_requirement(prec) for prec in precs]
13291277

13301278

13311279
# NOTE: The function has to retain the "install_actions" name for now since
@@ -1374,8 +1322,8 @@ def install_actions(prefix, index, specs):
13741322
txn = solver.solve_for_transaction(prune=False, ignore_pinned=False)
13751323
prefix_setup = txn.prefix_setups[prefix]
13761324
actions = {
1377-
PREFIX_ACTION: prefix,
1378-
LINK_ACTION: [prec for prec in prefix_setup.link_precs],
1325+
_PREFIX_ACTION: prefix,
1326+
_LINK_ACTION: [prec for prec in prefix_setup.link_precs],
13791327
}
13801328
return actions
13811329

@@ -1384,31 +1332,23 @@ def install_actions(prefix, index, specs):
13841332
del install_actions
13851333

13861334

1387-
def _execute_actions(prefix, actions):
1335+
@deprecated.argument("24.3", "24.5", "actions", rename="precs")
1336+
def _execute_actions(prefix, precs):
13881337
# This is copied over from https://github.com/conda/conda/blob/23.11.0/conda/plan.py#L575
13891338
# but reduced to only the functionality actually used within conda-build.
1390-
13911339
assert prefix
13921340

1393-
if LINK_ACTION not in actions:
1394-
log.debug(f"action {LINK_ACTION} not in actions")
1395-
return
1396-
1397-
link_precs = actions[LINK_ACTION]
1398-
if not link_precs:
1399-
log.debug(f"action {LINK_ACTION} has None value")
1400-
return
1401-
14021341
# Always link menuinst first/last on windows in case a subsequent
14031342
# package tries to import it to create/remove a shortcut
1404-
link_precs = [p for p in link_precs if p.name == "menuinst"] + [
1405-
p for p in link_precs if p.name != "menuinst"
1343+
precs = [
1344+
*(prec for prec in precs if prec.name == "menuinst"),
1345+
*(prec for prec in precs if prec.name != "menuinst"),
14061346
]
14071347

1408-
progressive_fetch_extract = ProgressiveFetchExtract(link_precs)
1348+
progressive_fetch_extract = ProgressiveFetchExtract(precs)
14091349
progressive_fetch_extract.prepare()
14101350

1411-
stp = PrefixSetup(prefix, (), link_precs, (), [], ())
1351+
stp = PrefixSetup(prefix, (), precs, (), [], ())
14121352
unlink_link_transaction = UnlinkLinkTransaction(stp)
14131353

14141354
log.debug(" %s(%r)", "PROGRESSIVEFETCHEXTRACT", progressive_fetch_extract)
@@ -1417,7 +1357,8 @@ def _execute_actions(prefix, actions):
14171357
unlink_link_transaction.execute()
14181358

14191359

1420-
def _display_actions(prefix, actions):
1360+
@deprecated.argument("24.3", "24.5", "actions", rename="precs")
1361+
def _display_actions(prefix, precs):
14211362
# This is copied over from https://github.com/conda/conda/blob/23.11.0/conda/plan.py#L58
14221363
# but reduced to only the functionality actually used within conda-build.
14231364

@@ -1449,7 +1390,7 @@ def channel_filt(s):
14491390
features = defaultdict(lambda: "")
14501391
channels = defaultdict(lambda: "")
14511392

1452-
for prec in actions.get(LINK_ACTION, []):
1393+
for prec in precs:
14531394
assert isinstance(prec, PackageRecord)
14541395
pkg = prec["name"]
14551396
channels[pkg] = channel_filt(channel_str(prec))

conda_build/noarch_python.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66
import os
77
import shutil
88
import sys
9-
from os.path import basename, dirname, isdir, isfile, join
9+
from os.path import basename, dirname, isfile, join
1010

11-
from .deprecations import deprecated
1211
from .utils import on_win
1312

1413

15-
@deprecated("24.1", "24.3", addendum="Use `os.makedirs(exist_ok=True)` instead.")
16-
def _force_dir(dirname):
17-
if not isdir(dirname):
18-
os.makedirs(dirname)
19-
20-
21-
@deprecated("24.1", "24.3")
22-
def _error_exit(exit_message):
23-
sys.exit("[noarch_python] %s" % exit_message)
24-
25-
2614
def rewrite_script(fn, prefix):
2715
"""Take a file from the bin directory and rewrite it into the python-scripts
2816
directory with the same permissions after it passes some sanity checks for

0 commit comments

Comments
 (0)