Skip to content

Commit 19251f4

Browse files
authored
Revert "Fix transitive subpackage dependency resolution (conda#5603)" (conda#5647)
1 parent e77c4c6 commit 19251f4

6 files changed

Lines changed: 33 additions & 50 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
# auto format Python codes within docstrings
5959
- id: blacken-docs
6060
- repo: https://github.com/astral-sh/ruff-pre-commit
61-
rev: v0.9.10
61+
rev: v0.11.0
6262
hooks:
6363
# lint & attempt to correct failures (e.g. pyupgrade)
6464
- id: ruff

conda_build/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ def build(
24402440
exclude_pattern = re.compile(
24412441
r"|".join(rf"(?:^{exc}(?:\s|$|\Z))" for exc in excludes)
24422442
)
2443-
add_upstream_pins(m, False, exclude_pattern, [])
2443+
add_upstream_pins(m, False, exclude_pattern)
24442444

24452445
create_build_envs(top_level_pkg, notest)
24462446

conda_build/render.py

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def get_env_dependencies(
130130
exclude_pattern=None,
131131
permit_unsatisfiable_variants=False,
132132
merge_build_host_on_same_platform=True,
133-
extra_specs=None,
134133
):
135134
specs = m.get_depends_top_and_out(env)
136135
# replace x.x with our variant's numpy version, or else conda tries to literally go get x.x
@@ -149,8 +148,6 @@ def get_env_dependencies(
149148
)
150149

151150
dependencies = set(dependencies)
152-
if extra_specs:
153-
dependencies |= set(extra_specs)
154151
unsat = None
155152
random_string = "".join(
156153
random.choice(string.ascii_uppercase + string.digits) for _ in range(10)
@@ -186,7 +183,7 @@ def get_env_dependencies(
186183
specs = [package_record_to_requirement(prec) for prec in precs]
187184
return (
188185
utils.ensure_list(
189-
(specs + subpackages + pass_through_deps + (extra_specs or []))
186+
(specs + subpackages + pass_through_deps)
190187
or m.get_value(f"requirements/{env}", [])
191188
),
192189
precs,
@@ -444,15 +441,13 @@ def _read_upstream_pin_files(
444441
env,
445442
permit_unsatisfiable_variants,
446443
exclude_pattern,
447-
extra_specs,
448444
):
449445
deps, precs, unsat = get_env_dependencies(
450446
m,
451447
env,
452448
m.config.variant,
453449
exclude_pattern,
454450
permit_unsatisfiable_variants=permit_unsatisfiable_variants,
455-
extra_specs=extra_specs,
456451
)
457452
# extend host deps with strong build run exports. This is important for things like
458453
# vc feature activation to work correctly in the host env.
@@ -464,18 +459,12 @@ def _read_upstream_pin_files(
464459
)
465460

466461

467-
def add_upstream_pins(
468-
m: MetaData, permit_unsatisfiable_variants, exclude_pattern, extra_specs
469-
):
462+
def add_upstream_pins(m: MetaData, permit_unsatisfiable_variants, exclude_pattern):
470463
"""Applies run_exports from any build deps to host and run sections"""
471464
# if we have host deps, they're more important than the build deps.
472465
requirements = m.get_section("requirements")
473466
build_deps, build_unsat, extra_run_specs_from_build = _read_upstream_pin_files(
474-
m,
475-
"build",
476-
permit_unsatisfiable_variants,
477-
exclude_pattern,
478-
[] if m.is_cross else extra_specs,
467+
m, "build", permit_unsatisfiable_variants, exclude_pattern
479468
)
480469

481470
# is there a 'host' section?
@@ -501,7 +490,7 @@ def add_upstream_pins(
501490
host_reqs.extend(extra_run_specs_from_build.get("strong", []))
502491

503492
host_deps, host_unsat, extra_run_specs_from_host = _read_upstream_pin_files(
504-
m, "host", permit_unsatisfiable_variants, exclude_pattern, extra_specs
493+
m, "host", permit_unsatisfiable_variants, exclude_pattern
505494
)
506495
if m.noarch or m.noarch_python:
507496
extra_run_specs = set(extra_run_specs_from_host.get("noarch", []))
@@ -658,40 +647,9 @@ def finalize_metadata(
658647
utils.insert_variant_versions(requirements, m.config.variant, "build")
659648
utils.insert_variant_versions(requirements, m.config.variant, "host")
660649

661-
host_requirements = requirements.get("host" if m.is_cross else "build", [])
662-
host_requirement_names = [req.split(" ")[0] for req in host_requirements]
663-
extra_specs = []
664-
if output and output_excludes and not is_top_level and host_requirement_names:
665-
reqs = {}
666-
667-
# we first make a mapping of output -> requirements
668-
for (name, _), (_, other_meta) in m.other_outputs.items():
669-
if name == m.name():
670-
continue
671-
other_meta_reqs = other_meta.meta.get("requirements", {}).get("run", [])
672-
reqs[name] = set(other_meta_reqs)
673-
674-
seen = set()
675-
# for each subpackage that is a dependency we add its dependencies
676-
# and transitive dependencies if the dependency of the subpackage
677-
# is a subpackage.
678-
to_process = set(
679-
name for (name, _) in m.other_outputs if name in host_requirement_names
680-
)
681-
while to_process:
682-
name = to_process.pop()
683-
if name == m.name():
684-
continue
685-
for req in reqs[name]:
686-
req_name = req.split(" ")[0]
687-
if req_name not in reqs:
688-
extra_specs.append(req)
689-
elif req_name not in seen:
690-
to_process.add(req_name)
691-
692650
m = parent_metadata.get_output_metadata(m.get_rendered_output(m.name()))
693651
build_unsat, host_unsat = add_upstream_pins(
694-
m, permit_unsatisfiable_variants, exclude_pattern, extra_specs
652+
m, permit_unsatisfiable_variants, exclude_pattern
695653
)
696654
# getting this AFTER add_upstream_pins is important, because that function adds deps
697655
# to the metadata.
@@ -719,7 +677,6 @@ def finalize_metadata(
719677
m.config.variant,
720678
exclude_pattern=exclude_pattern,
721679
permit_unsatisfiable_variants=permit_unsatisfiable_variants,
722-
extra_specs=extra_specs,
723680
)
724681
full_build_dep_versions = {
725682
dep.split()[0]: " ".join(dep.split()[1:]) for dep in full_build_deps

news/5647-revert

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* <news item>
4+
5+
### Bug fixes
6+
7+
* Revert #5603 to avoid rendering regressions in multi-output recipes. (#5644, #5645 via #5647)
8+
9+
### Deprecations
10+
11+
* <news item>
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

tests/test_api_build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def test_recipe_builds(
137137
pytest.xfail("Issue related to #3754 on conda-build.")
138138
elif recipe.name == "unicode_all_over" and context.solver == "libmamba":
139139
pytest.xfail("Unicode package names not supported in libmamba.")
140+
elif recipe.name == "transitive_subpackage":
141+
pytest.xfail(
142+
"Added as part of #5603, reverted in #5647. Fix needs to be reworked."
143+
)
140144

141145
# These variables are defined solely for testing purposes,
142146
# so they can be checked within build scripts

tests/test_api_render.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def test_pin_compatible_semver(testing_config):
122122
assert "zlib >=1.2.11,<2.0a0" in metadata.get_value("requirements/run")
123123

124124

125+
@pytest.mark.xfail(
126+
reason="Added as part of #5603, reverted in #5647. Fix needs to be reworked."
127+
)
125128
def test_transitive_subpackage_dependency(testing_config):
126129
recipe_dir = os.path.join(metadata_dir, "transitive_subpackage")
127130
metadata = api.render(recipe_dir, config=testing_config)[1][0]

0 commit comments

Comments
 (0)