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

feat: Support for optional python_site_packages_path in repodata #3579

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jjhelmus
Copy link

@jjhelmus jjhelmus commented Nov 6, 2024

Add support for the optional python_site_packages_path field that can appear in repodata for python packages as a means to specify the location of the site-packages directory.

This optional field is defined in CEP-17.

partial implementation for #3558

Please be kind as this is my first contribution to mamba and the first time digging into the source.

@jjhelmus jjhelmus changed the title add optional python_site_packages_path in repodata support for optional python_site_packages_path in repodata Nov 6, 2024
@jjhelmus
Copy link
Author

jjhelmus commented Nov 6, 2024

This is likely not a complete implementation for CEP-17 in mamba but may be enough to unblock libmamba-conda-solver (see conda/conda-libmamba-solver#560).

This is rough and likely needs some work to finish things up but was hoping for initial feedback (or someone else to take over 😄).

With these changes I was able to get the field to show up in the output of repoquery search:

./build/micromamba/mamba repoquery search -c jjhelmus/label/sp_path python=3.99.99  --json | jq .result.pkgs
[
  {
    "build": "0",
    "build_number": 0,
    "build_string": "0",
    "channel": "jjhelmus",
    "constrains": [],
    "depends": [
      "pip"
    ],
    "fn": "python-3.99.99-0.tar.bz2",
    "license": "",
    "md5": "2570015e0cb5829cbdfa9780b4564db9",
    "name": "python",
    "noarch": "generic",
    "python_site_packages_path": "lib/python3.99t/site-packages",
    "sha256": "a2be7c56f9ce3d6fc25220a49185894d02cf03b832bb9fb55122e6a662bde910",
    "size": 2912,
    "subdir": "noarch",
    "timestamp": 1726861043,
    "track_features": "",
    "url": "https://conda.anaconda.org/t/jj-80e459ed-f2bc-4975-ae2e-68f8e339b666/jjhelmus/label/sp_path/noarch/python-3.99.99-0.tar.bz2",
    "version": "3.99.99"
  }
]

@jaimergp jaimergp mentioned this pull request Nov 7, 2024
@JohanMabille JohanMabille added the release::enhancements For enhancements PRs or implementing features label Nov 20, 2024
@JohanMabille
Copy link
Member

JohanMabille commented Nov 20, 2024

Hi, thanks for tackling this! The implementation is neat and looks good to me, can you add some test to check this is correctly working?

Also running pre-commit run --all-files should fix the linter.

@jjerphan jjerphan changed the title support for optional python_site_packages_path in repodata feat: Support for optional python_site_packages_path in repodata Nov 20, 2024
@jjerphan
Copy link
Member

jjerphan commented Jan 8, 2025

Hi @jjhelmus, the support of CEP-17 is important for supporting Python 3.13t builds.

Are you still interested in continuing this PR?

@jjhelmus
Copy link
Author

Hi @jjhelmus, the support of CEP-17 is important for supporting Python 3.13t builds.

Are you still interested in continuing this PR?

I can still work on this but progress will be slow. If anyone wants to take over this work that would be fine.

When I original started for on this, supported free-threading was a high priority for the team I was on. Since then, free-threading support is no longer a priority so I have very little time to work on this.

@jaimergp
Copy link
Contributor

Hi! I'm reviewing conda/conda-libmamba-solver#628 and in there we are already assuming that python_site_packages_path will be the name of the attribute used in the libmambapy PackageRecord object. Can that be guaranteed even without this being merged yet? IOW, will you change the name of the attribute in this PR? Thanks!

Add support for the optional python_site_packages_path field that can
appear in repodata for python packages to specify the location of the
site-packages directory.

This optional field is defined in CEP-17.
Add the `python_site_packages_path` attribute to the PackageInfo class
in the libmambapy bindings module.
Use the python_site_packages_path parameter from the python package
in the environment as the site_package_path when available. When not
specified fall back to setting this from the python version.
@jjhelmus
Copy link
Author

I found some time to work on this again and have been making some progress. Micromamba will now copy the contents of noarch: python packages into the location specified by the python_site_packages_path field when available in the package's repodata entry.

This can be checked using:

./build/micromamba/mamba create -p ./blah python=3.13 "python_abi=*=*_cp313t" imagesize -c conda-forge --yes
ls -d blah/lib/python3.13*

There should be a single directory, blah/lib/python3.13t and its site-packages subdirectory should contain the file from the imagesize package.

I'm still working on adding some tests, should have these complete by the end of the week.

@jjhelmus
Copy link
Author

This PR is ready for review.

With these changes, noarch: python packages are installed into the location specific by the python_site_packages_path field of the python package when present. When not specified packages are into into the site-packages path determined from the version of the python package as is the existing behavior.

This field is exposed in libmambapy so that it can be used by conda-libmamba-solver and in turn conda.

There are tests at a unit and integration level.

Happy to address any concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release::enhancements For enhancements PRs or implementing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants