From 5015b17f9ef0cdbce7b7ccd792aefb9105c7969b Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 6 Dec 2023 02:08:22 -0500 Subject: [PATCH] Relax `package/version` check for multi `outputs` (#5096) * Relax package/version check for multi outputs * Skip GitHub + SVN failure * Add news --- conda_build/metadata.py | 2 +- news/5096-relax-metadata-version-checks | 19 +++++++++++++++++++ .../meta.yaml | 6 ++++++ .../meta.yaml | 12 ++++++++++++ .../split-packages/_order/meta.yaml | 2 +- tests/test_api_build.py | 3 +++ tests/test_subpackages.py | 17 +++++++++++++++++ 7 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 news/5096-relax-metadata-version-checks create mode 100644 tests/test-recipes/split-packages/_empty_outputs_requires_package_version/meta.yaml create mode 100644 tests/test-recipes/split-packages/_multi_outputs_without_package_version/meta.yaml diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 9f9e11eefe..9539dc5d14 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -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) version = str(version) check_bad_chrs(version, "package/version") diff --git a/news/5096-relax-metadata-version-checks b/news/5096-relax-metadata-version-checks new file mode 100644 index 0000000000..12325a70e1 --- /dev/null +++ b/news/5096-relax-metadata-version-checks @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Relax `conda_build.metadata.MetaData.version` checks when `outputs` have been defined. (#5096) + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/tests/test-recipes/split-packages/_empty_outputs_requires_package_version/meta.yaml b/tests/test-recipes/split-packages/_empty_outputs_requires_package_version/meta.yaml new file mode 100644 index 0000000000..2cb957bfff --- /dev/null +++ b/tests/test-recipes/split-packages/_empty_outputs_requires_package_version/meta.yaml @@ -0,0 +1,6 @@ +package: + name: _empty_outputs_requires_package_version + # when there are not outputs, package/version is required + # version: 0 + +outputs: diff --git a/tests/test-recipes/split-packages/_multi_outputs_without_package_version/meta.yaml b/tests/test-recipes/split-packages/_multi_outputs_without_package_version/meta.yaml new file mode 100644 index 0000000000..6943d411f7 --- /dev/null +++ b/tests/test-recipes/split-packages/_multi_outputs_without_package_version/meta.yaml @@ -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 diff --git a/tests/test-recipes/split-packages/_order/meta.yaml b/tests/test-recipes/split-packages/_order/meta.yaml index 0db9f6bbce..fb171942a8 100644 --- a/tests/test-recipes/split-packages/_order/meta.yaml +++ b/tests/test-recipes/split-packages/_order/meta.yaml @@ -1,6 +1,6 @@ package: name: toplevel-ab - version: 0.0.1 + version: 1 outputs: - name: a diff --git a/tests/test_api_build.py b/tests/test_api_build.py index ff3e431ff3..f7e6864412 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -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" +) 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") diff --git a/tests/test_subpackages.py b/tests/test_subpackages.py index a27402cb47..2d63042cb5 100644 --- a/tests/test_subpackages.py +++ b/tests/test_subpackages.py @@ -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)