Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax package/version check for multi outputs #5096

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ def name(self) -> str:

def version(self) -> str:
version = self.get_value("package/version", "")
if not version and self.final:
if not version and not self.get_section("outputs") and self.final:
sys.exit("Error: package/version missing in: %r" % self.meta_path)
jezdez marked this conversation as resolved.
Show resolved Hide resolved
version = str(version)
check_bad_chrs(version, "package/version")
Expand Down
19 changes: 19 additions & 0 deletions news/5096-relax-metadata-version-checks
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Relax `conda_build.metadata.MetaData.version` checks when `outputs` have been defined. (#5096)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package:
name: _empty_outputs_requires_package_version
# when there are not outputs, package/version is required
# version: 0

outputs:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package:
name: _multi_outputs_without_package_version
# when there are outputs, package/version is not required
# version: 0

outputs:
- name: a
version: 1
- name: b
version: 2
- name: c
version: 3
2 changes: 1 addition & 1 deletion tests/test-recipes/split-packages/_order/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: toplevel-ab
version: 0.0.1
version: 1

outputs:
- name: a
Expand Down
3 changes: 3 additions & 0 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ def dummy_executable(folder, exename):
return exename


@pytest.mark.skip(
reason="GitHub discontinued SVN, see https://github.com/conda/conda-build/issues/5098"
)
Comment on lines +415 to +417
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub has started the processes of turning off SVN support causing this tests to fail. Refactoring revealed unexpected surprises, so I've chosen to step back for this hotfix and temporarily bypass the failing test.

See #5098 for more.

def test_checkout_tool_as_dependency(testing_workdir, testing_config, monkeypatch):
# "hide" svn by putting a known bad one on PATH
exename = dummy_executable(testing_workdir, "svn")
Expand Down
17 changes: 17 additions & 0 deletions tests/test_subpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,20 @@ def test_build_string_does_not_incorrectly_add_hash(testing_config):
assert len(output_files) == 4
assert any("clang_variant-1.0-cling.tar.bz2" in f for f in output_files)
assert any("clang_variant-1.0-default.tar.bz2" in f for f in output_files)


def test_multi_outputs_without_package_version(testing_config):
# outputs without package/version is allowed
recipe = os.path.join(subpackage_dir, "_multi_outputs_without_package_version")
outputs = api.build(recipe, config=testing_config)
assert len(outputs) == 3
assert outputs[0].endswith("a-1-0.tar.bz2")
assert outputs[1].endswith("b-2-0.tar.bz2")
assert outputs[2].endswith("c-3-0.tar.bz2")


def test_empty_outputs_requires_package_version(testing_config):
# no outputs means package/version is required
recipe = os.path.join(subpackage_dir, "_empty_outputs_requires_package_version")
with pytest.raises(SystemExit, match="package/version missing"):
api.build(recipe, config=testing_config)
Loading