Skip to content

Commit

Permalink
Collapse _plan_from_actions into execute_actions
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
  • Loading branch information
mbargull committed Jan 19, 2024
1 parent 240baf3 commit f410de4
Showing 1 changed file with 10 additions and 33 deletions.
43 changes: 10 additions & 33 deletions conda_build/_legacy_conda_imports/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

PREFIX = "PREFIX"
LINK = "LINK"
UNLINKLINKTRANSACTION = "UNLINKLINKTRANSACTION"
PROGRESSIVEFETCHEXTRACT = "PROGRESSIVEFETCHEXTRACT"

log = getLogger(__name__)

Expand Down Expand Up @@ -112,41 +110,18 @@ def format(s, pkg):
# ---------------------------- Backwards compat for conda-build --------------------------


def execute_actions(actions, verbose=False): # pragma: no cover
plan = _plan_from_actions(actions)
log.debug("executing plan %s", plan)

for instruction, arg in plan:
log.debug(" %s(%r)", instruction, arg)

if instruction in (PREFIX, LINK):
continue

if instruction == PROGRESSIVEFETCHEXTRACT:
progressive_fetch_extract = arg
assert isinstance(progressive_fetch_extract, ProgressiveFetchExtract)
progressive_fetch_extract.execute()
elif instruction == UNLINKLINKTRANSACTION:
unlink_link_transaction = arg
assert isinstance(unlink_link_transaction, UnlinkLinkTransaction)
unlink_link_transaction.execute()
else:
raise KeyError(instruction)


def _plan_from_actions(actions): # pragma: no cover
def execute_actions(actions, verbose=False):
assert PREFIX in actions and actions[PREFIX]
prefix = actions[PREFIX]
plan = [(PREFIX, "%s" % prefix)]

if LINK not in actions:
log.debug(f"action {LINK} not in actions")
return plan
return

link_precs = actions[LINK]
if not link_precs:
log.debug(f"action {LINK} has None value")
return plan
return

if on_win:
# Always link menuinst first/last on windows in case a subsequent
Expand All @@ -156,14 +131,16 @@ def _plan_from_actions(actions): # pragma: no cover
[p for p in link_precs if p.name != "menuinst"]
)

pfe = ProgressiveFetchExtract(link_precs)
pfe.prepare()
plan.append((PROGRESSIVEFETCHEXTRACT, pfe))
progressive_fetch_extract = ProgressiveFetchExtract(link_precs)
progressive_fetch_extract.prepare()

stp = PrefixSetup(prefix, (), link_precs, (), [], ())
plan.append((UNLINKLINKTRANSACTION, UnlinkLinkTransaction(stp)))
unlink_link_transaction = UnlinkLinkTransaction(stp)

return plan
log.debug(" %s(%r)", "PROGRESSIVEFETCHEXTRACT", progressive_fetch_extract)
progressive_fetch_extract.execute()
log.debug(" %s(%r)", "UNLINKLINKTRANSACTION", unlink_link_transaction)
unlink_link_transaction.execute()


def install_actions(
Expand Down

0 comments on commit f410de4

Please sign in to comment.