From bd94b7f9de83e6514c96ce98d61147a635eb5cea Mon Sep 17 00:00:00 2001 From: "Jonathan J. Helmus" Date: Tue, 5 Nov 2024 10:47:23 -0600 Subject: [PATCH] python_site_packages_path can be specified in the build section (#5502) * include python_site_packages_path in index.json * TST: test for python_site_packages_path metadata * DOC: document python_site_packages_path * add news item * Update news Co-authored-by: Jannis Leidel --------- Co-authored-by: Bianca Henderson Co-authored-by: Jannis Leidel Co-authored-by: Bianca Henderson --- conda_build/metadata.py | 5 +++++ docs/source/resources/define-metadata.rst | 13 +++++++++++++ ...path-can-be-specified-in-the-build-section | 19 +++++++++++++++++++ .../_python_site_packages_path/meta.yaml | 6 ++++++ tests/test_api_build.py | 9 +++++++++ 5 files changed, 52 insertions(+) create mode 100644 news/5502-python_site_packages_path-can-be-specified-in-the-build-section create mode 100644 tests/test-recipes/metadata/_python_site_packages_path/meta.yaml diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 2854248761..c9e32487a8 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -628,6 +628,7 @@ def parse(data, config, path=None): "error_overdepending": None, "error_overlinking": None, "overlinking_ignore_patterns": [], + "python_site_packages_path": str, }, "outputs": { "name": None, @@ -1800,6 +1801,10 @@ def info_index(self): d["provides_features"] = self.get_value("build/provides_features") if self.get_value("build/requires_features"): d["requires_features"] = self.get_value("build/requires_features") + if self.get_value("build/python_site_packages_path"): + d["python_site_packages_path"] = self.get_value( + "build/python_site_packages_path" + ) if self.noarch: d["platform"] = d["arch"] = None d["subdir"] = "noarch" diff --git a/docs/source/resources/define-metadata.rst b/docs/source/resources/define-metadata.rst index 26aea14f10..06cc7234cb 100644 --- a/docs/source/resources/define-metadata.rst +++ b/docs/source/resources/define-metadata.rst @@ -373,6 +373,19 @@ Python in macOS. The default is ``False``. build: osx_is_app: True +python_site_packages_path +------------------------- + +Packages with a name of ``python`` can optionally specify the location of the +site-packages directory relative to the root of the environment with +``python_site_packages_path``. This should only be used in ``python`` packages +and only when the path is not the CPython default. + +.. code-block:: yaml + + build: + python_site_packages_path: lib/python3.13t/site-packages + Track features -------------- diff --git a/news/5502-python_site_packages_path-can-be-specified-in-the-build-section b/news/5502-python_site_packages_path-can-be-specified-in-the-build-section new file mode 100644 index 0000000000..1e6ab3a657 --- /dev/null +++ b/news/5502-python_site_packages_path-can-be-specified-in-the-build-section @@ -0,0 +1,19 @@ +### Enhancements + +* Add support for CEP-17 that allows specifying the location of the site-packages directory with the `python_site_packages_path` build option for any packages named `python`. (#5502) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/tests/test-recipes/metadata/_python_site_packages_path/meta.yaml b/tests/test-recipes/metadata/_python_site_packages_path/meta.yaml new file mode 100644 index 0000000000..2c38618aa1 --- /dev/null +++ b/tests/test-recipes/metadata/_python_site_packages_path/meta.yaml @@ -0,0 +1,6 @@ +package: + name: python + version: 3.99.99 + +build: + python_site_packages_path: "some/path" diff --git a/tests/test_api_build.py b/tests/test_api_build.py index becad4e40b..115be4fa17 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1705,6 +1705,15 @@ def test_provides_features_metadata(testing_config): assert index["provides_features"] == {"test2": "also_ok"} +@pytest.mark.sanity +def test_python_site_packages_path(testing_config): + recipe = os.path.join(metadata_dir, "_python_site_packages_path") + out = api.build(recipe, config=testing_config)[0] + index = json.loads(package_has_file(out, "info/index.json")) + assert "python_site_packages_path" in index + assert index["python_site_packages_path"] == "some/path" + + def test_overlinking_detection( testing_config, testing_workdir, variants_conda_build_sysroot ):