Skip to content

Commit

Permalink
python_site_packages_path can be specified in the build section (#5502)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Bianca Henderson <[email protected]>
Co-authored-by: Jannis Leidel <[email protected]>
Co-authored-by: Bianca Henderson <[email protected]>
  • Loading branch information
4 people authored Nov 5, 2024
1 parent d8a4148 commit bd94b7f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions docs/source/resources/define-metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------
Expand Down
Original file line number Diff line number Diff line change
@@ -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

* <news item>

### 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: python
version: 3.99.99

build:
python_site_packages_path: "some/path"
9 changes: 9 additions & 0 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down

0 comments on commit bd94b7f

Please sign in to comment.