Skip to content

Commit

Permalink
Relax package/version check for multi outputs (#5096)
Browse files Browse the repository at this point in the history
* Relax package/version check for multi outputs

* Skip GitHub + SVN failure

* Add news
  • Loading branch information
kenodegard authored Dec 6, 2023
1 parent 91d10fc commit 5015b17
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 2 deletions.
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)
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"
)
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)

0 comments on commit 5015b17

Please sign in to comment.