Skip to content

Add an option to create arch specific, python version independent pkgs#5456

Merged
isuruf merged 18 commits intoconda:mainfrom
isuruf:python-ver-indep
Feb 25, 2025
Merged

Add an option to create arch specific, python version independent pkgs#5456
isuruf merged 18 commits intoconda:mainfrom
isuruf:python-ver-indep

Conversation

@isuruf
Copy link
Copy Markdown
Contributor

@isuruf isuruf commented Aug 12, 2024

Description

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

Implementation for ABI3 as described in https://github.com/conda/ceps/blob/main/cep-0020.md
This implementation depends on a specific python-abi3 package (already in conda-forge at https://github.com/conda-forge/python-abi3-feedstock) in host to set the correct runtime dependencies.
By being ABI3 agnostic, we leave room for other standards like ABI4, HPy to be supported.
Added documentation has an example, and a more complicated example for conda-forge is at https://github.com/conda-forge/python-abi3-feedstock/blob/main/recipe/example-meta.yaml

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Aug 12, 2024
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Aug 12, 2024

CodSpeed Performance Report

Merging #5456 will not alter performance

Comparing isuruf:python-ver-indep (efe1e9c) with main (caa6d2f)

Summary

✅ 5 untouched benchmarks

Comment thread conda_build/metadata.py Outdated
Comment thread conda_build/metadata.py Outdated
Copy link
Copy Markdown
Contributor

@beckermr beckermr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test here that asserts that the output package is put into an arch-specific part of the repodata (e.g., linux-64)? It is not obvious to me from the changes that this would happen, but I am still a conda-build n00b.

@isuruf isuruf marked this pull request as ready for review January 3, 2025 08:09
@isuruf isuruf requested a review from a team as a code owner January 3, 2025 08:09
@isuruf isuruf requested review from beckermr and jaimergp January 6, 2025 12:43
@jaimergp
Copy link
Copy Markdown
Member

jaimergp commented Jan 9, 2025

Thanks for the docs! We are missing the news/ entry and perhaps a short description in the PR linking to the relevant issues, discussions, CEPs, etc. I'll review once those are in.

@isuruf
Copy link
Copy Markdown
Contributor Author

isuruf commented Jan 9, 2025

Thanks. Added a news entry and updated the PR description.

@wolfv
Copy link
Copy Markdown
Contributor

wolfv commented Jan 9, 2025

Awesome work!

Comment thread docs/source/resources/define-metadata.rst Outdated
Copy link
Copy Markdown
Member

@jaimergp jaimergp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions and comments that need to be addressed, but nothing major. Once that's in, I'll be happy to approve!

Comment thread conda_build/build.py Outdated
Comment thread conda_build/build.py
if target_file.find("site-packages") >= 0:
return target_file[target_file.find("site-packages") :]
elif target_file.startswith("bin") and (
if target_file.startswith("bin") and (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this include the slash to prevent matches with paths like binocular.dat?

Suggested change
if target_file.startswith("bin") and (
if target_file.startswith("bin/") and (

(And in that case, update the replace below?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it for a different PR?

Comment thread conda_build/build.py
if target_file.startswith("bin") and (
target_file not in entry_point_script_names
):
return target_file.replace("bin", "python-scripts")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return target_file.replace("bin", "python-scripts")
return target_file.replace("bin/", "python-scripts/")

Comment thread conda_build/metadata.py Outdated
Comment on lines +1858 to +1859
# This is a hack to make conda/mamba/micromamba compile the pure python files
# and for micromamba to move the files in site-packages to the correct dir.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which versions require this hack? All of them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a clarification to the comment here.

Comment thread conda_build/metadata.py
Comment thread conda_build/render.py
python_version_independent: true

A package builder also has to indicate which standard is supported by
the package, i.e., for ABI3,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the package, i.e., for ABI3,
the package, i.e., for ABI3 in conda-forge

AFAIK, python-abi3 is a conda-forge-specific package, right? Or is it in defaults too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add it to defaults too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenghlee do you think it's reasonable to add this package to defaults? Otherwise I'll update this PR to reflect that the package is only in conda-forge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenghlee let me know how you want to proceed here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already introduced python_abi in main to support free threading:

$ conda search -c main python_abi
Loading channels: done
# Name                       Version           Build  Channel             
python_abi                      3.13         0_cp313  pkgs/main           
python_abi                      3.13        0_cp313t  pkgs/main

So I don't see any need to say that the python_abi package is conda-forge specific.

(What I can't definitely say is when python_abi support will be extended to Python versions before 3.13, but that feels more like an Anaconda, rather than a conda community, problem.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chenghlee

Comment thread docs/source/resources/define-metadata.rst Outdated
Comment thread news/5456-python-version-independent.rst Outdated
isuruf and others added 6 commits January 13, 2025 12:47
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
Co-authored-by: Jannis Leidel <jannis@leidel.info>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
@isuruf isuruf requested a review from jaimergp January 14, 2025 13:53
@jschueller
Copy link
Copy Markdown
Contributor

this sounds great, should save us some ci times, looking forward to this!

@isuruf isuruf merged commit 6e6bb13 into conda:main Feb 25, 2025
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Feb 25, 2025
@isuruf isuruf deleted the python-ver-indep branch March 6, 2025 20:08
@kenodegard kenodegard mentioned this pull request Mar 17, 2025
59 tasks
@casperdcl
Copy link
Copy Markdown

casperdcl commented Oct 17, 2025

Sorry just to clarify, is this the intention?

meta.yml modification target platform target python
(none) linux-64 etc 3.9 etc
noarch: python noarch *
python_version_independent: true linux-64 etc *

If so, that would be great.

However, from my testing it seems that python_version_independent: true has no effect (i.e. it creates lib/python3.12/site-packages rather than pyver-independent site-packages).

@isuruf
Copy link
Copy Markdown
Contributor Author

isuruf commented Oct 17, 2025

Yes, that's correct.

The line you linked to doesn't matter. conda-build's relocation logic works after the link check logic.

@casperdcl
Copy link
Copy Markdown

casperdcl commented Oct 17, 2025

I still don't get it... with python_version_independent: true:

$ conda build --output-folder dist ...
$ tar tf dist/*/mypackagename-*.tar.bz2
...
lib/python3.12/site-packages/mypackagename/...
$ mamba create -n testing -c ./dist python=3.13 mypackagename
...
Could not solve for environment specs
The following packages are incompatible
├─ mypackagename * is installable and it requires
│  └─ python_abi 3.12.* *_cp312, which requires
│     └─ python 3.12.* *_cpython, which can be installed;
└─ python 3.13**  is not installable because it conflicts with any installable versions previously reported.

@casperdcl
Copy link
Copy Markdown

Should I open an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

9 participants