67
67
68
68
log = getLogger (__name__ )
69
69
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" )
72
72
73
73
# these are things that we provide env vars for more explicitly. This list disables the
74
74
# pass-through of variant values to env vars for these keys.
@@ -852,7 +852,8 @@ def package_specs(self):
852
852
return specs
853
853
854
854
855
- cached_actions = {}
855
+ cached_precs = {}
856
+ deprecated .constant ("24.3" , "24.5" , "cached_actions" , cached_precs )
856
857
last_index_ts = 0
857
858
858
859
@@ -872,9 +873,9 @@ def get_package_records(
872
873
output_folder = None ,
873
874
channel_urls = None ,
874
875
):
875
- global cached_actions
876
+ global cached_precs
876
877
global last_index_ts
877
- actions = {}
878
+ precs = {}
878
879
log = utils .get_logger (__name__ )
879
880
conda_log_level = logging .WARN
880
881
specs = list (specs )
@@ -912,18 +913,16 @@ def get_package_records(
912
913
subdir ,
913
914
channel_urls ,
914
915
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 ()
919
918
elif specs :
920
919
# this is hiding output like:
921
920
# Fetching package metadata ...........
922
921
# Solving package specifications: ..........
923
922
with utils .LoggingContext (conda_log_level ):
924
923
with capture ():
925
924
try :
926
- actions = _install_actions (prefix , index , specs )
925
+ precs = _install_actions (prefix , index , specs )[ _LINK_ACTION ]
927
926
except (NoPackagesFoundError , UnsatisfiableError ) as exc :
928
927
raise DependencyNeedsBuildingError (exc , subdir = subdir )
929
928
except (
@@ -937,7 +936,7 @@ def get_package_records(
937
936
) as exc :
938
937
if "lock" in str (exc ):
939
938
log .warn (
940
- "failed to get install actions , retrying. exception was: %s" ,
939
+ "failed to get package records , retrying. exception was: %s" ,
941
940
str (exc ),
942
941
)
943
942
elif (
@@ -966,10 +965,10 @@ def get_package_records(
966
965
utils .rm_rf (pkg_dir )
967
966
if retries < max_env_retry :
968
967
log .warn (
969
- "failed to get install actions , retrying. exception was: %s" ,
968
+ "failed to get package records , retrying. exception was: %s" ,
970
969
str (exc ),
971
970
)
972
- actions = get_install_actions (
971
+ precs = get_package_records (
973
972
prefix ,
974
973
tuple (specs ),
975
974
env ,
@@ -987,7 +986,7 @@ def get_package_records(
987
986
)
988
987
else :
989
988
log .error (
990
- "Failed to get install actions , max retries exceeded."
989
+ "Failed to get package records , max retries exceeded."
991
990
)
992
991
raise
993
992
if disable_pip :
@@ -997,49 +996,10 @@ def get_package_records(
997
996
if not any (
998
997
re .match (r"^%s(?:$|[\s=].*)" % pkg , str (dep )) for dep in specs
999
998
):
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 ()
1005
1001
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
1043
1003
1044
1004
1045
1005
def create_env (
@@ -1081,12 +1041,9 @@ def create_env(
1081
1041
try :
1082
1042
with utils .try_acquire_locks (locks , timeout = config .timeout ):
1083
1043
# 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 ):
1088
1045
specs = list (set (specs_or_precs ))
1089
- actions = get_install_actions (
1046
+ precs = get_package_records (
1090
1047
prefix ,
1091
1048
tuple (specs ),
1092
1049
env ,
@@ -1102,10 +1059,7 @@ def create_env(
1102
1059
channel_urls = tuple (config .channel_urls ),
1103
1060
)
1104
1061
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
1109
1063
index , _ , _ = get_build_index (
1110
1064
subdir = subdir ,
1111
1065
bldpkgs_dir = config .bldpkgs_dir ,
@@ -1116,14 +1070,13 @@ def create_env(
1116
1070
locking = config .locking ,
1117
1071
timeout = config .timeout ,
1118
1072
)
1119
- utils .trim_empty_keys (actions )
1120
- _display_actions (prefix , actions )
1073
+ _display_actions (prefix , precs )
1121
1074
if utils .on_win :
1122
1075
for k , v in os .environ .items ():
1123
1076
os .environ [k ] = str (v )
1124
1077
with env_var ("CONDA_QUIET" , not config .verbose , reset_context ):
1125
1078
with env_var ("CONDA_JSON" , not config .verbose , reset_context ):
1126
- _execute_actions (prefix , actions )
1079
+ _execute_actions (prefix , precs )
1127
1080
except (
1128
1081
SystemExit ,
1129
1082
PaddingError ,
@@ -1158,15 +1111,13 @@ def create_env(
1158
1111
)
1159
1112
config .prefix_length = 80
1160
1113
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
-
1167
1114
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 ,
1170
1121
config = config ,
1171
1122
subdir = subdir ,
1172
1123
env = env ,
@@ -1307,7 +1258,7 @@ def remove_existing_packages(dirs, fns, config):
1307
1258
1308
1259
def get_pinned_deps (m , section ):
1309
1260
with TemporaryDirectory (prefix = "_" ) as tmpdir :
1310
- actions = get_install_actions (
1261
+ precs = get_package_records (
1311
1262
tmpdir ,
1312
1263
tuple (m .ms_depends (section )),
1313
1264
section ,
@@ -1322,10 +1273,7 @@ def get_pinned_deps(m, section):
1322
1273
output_folder = m .config .output_folder ,
1323
1274
channel_urls = tuple (m .config .channel_urls ),
1324
1275
)
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 ]
1329
1277
1330
1278
1331
1279
# NOTE: The function has to retain the "install_actions" name for now since
@@ -1374,8 +1322,8 @@ def install_actions(prefix, index, specs):
1374
1322
txn = solver .solve_for_transaction (prune = False , ignore_pinned = False )
1375
1323
prefix_setup = txn .prefix_setups [prefix ]
1376
1324
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 ],
1379
1327
}
1380
1328
return actions
1381
1329
@@ -1384,31 +1332,23 @@ def install_actions(prefix, index, specs):
1384
1332
del install_actions
1385
1333
1386
1334
1387
- def _execute_actions (prefix , actions ):
1335
+ @deprecated .argument ("24.3" , "24.5" , "actions" , rename = "precs" )
1336
+ def _execute_actions (prefix , precs ):
1388
1337
# This is copied over from https://github.com/conda/conda/blob/23.11.0/conda/plan.py#L575
1389
1338
# but reduced to only the functionality actually used within conda-build.
1390
-
1391
1339
assert prefix
1392
1340
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
-
1402
1341
# Always link menuinst first/last on windows in case a subsequent
1403
1342
# 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" ),
1406
1346
]
1407
1347
1408
- progressive_fetch_extract = ProgressiveFetchExtract (link_precs )
1348
+ progressive_fetch_extract = ProgressiveFetchExtract (precs )
1409
1349
progressive_fetch_extract .prepare ()
1410
1350
1411
- stp = PrefixSetup (prefix , (), link_precs , (), [], ())
1351
+ stp = PrefixSetup (prefix , (), precs , (), [], ())
1412
1352
unlink_link_transaction = UnlinkLinkTransaction (stp )
1413
1353
1414
1354
log .debug (" %s(%r)" , "PROGRESSIVEFETCHEXTRACT" , progressive_fetch_extract )
@@ -1417,7 +1357,8 @@ def _execute_actions(prefix, actions):
1417
1357
unlink_link_transaction .execute ()
1418
1358
1419
1359
1420
- def _display_actions (prefix , actions ):
1360
+ @deprecated .argument ("24.3" , "24.5" , "actions" , rename = "precs" )
1361
+ def _display_actions (prefix , precs ):
1421
1362
# This is copied over from https://github.com/conda/conda/blob/23.11.0/conda/plan.py#L58
1422
1363
# but reduced to only the functionality actually used within conda-build.
1423
1364
@@ -1449,7 +1390,7 @@ def channel_filt(s):
1449
1390
features = defaultdict (lambda : "" )
1450
1391
channels = defaultdict (lambda : "" )
1451
1392
1452
- for prec in actions . get ( LINK_ACTION , []) :
1393
+ for prec in precs :
1453
1394
assert isinstance (prec , PackageRecord )
1454
1395
pkg = prec ["name" ]
1455
1396
channels [pkg ] = channel_filt (channel_str (prec ))
0 commit comments