-
Notifications
You must be signed in to change notification settings - Fork 427
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
Add an option to create arch specific, python version independent pkgs #5456
base: main
Are you sure you want to change the base?
Changes from all commits
b336f6e
b80db8c
64a26b2
f028f78
0c1e9c4
5ffc58d
3e0bb37
fa7b1bb
32eaa9b
1f81f8f
acce288
1729889
aa72898
fc6fe30
834dadd
3071b17
99fe265
efe1e9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1247,8 +1247,11 @@ def write_info_files_file(m, files): | |||||
def write_link_json(m): | ||||||
package_metadata = OrderedDict() | ||||||
noarch_type = m.get_value("build/noarch") | ||||||
if noarch_type: | ||||||
noarch_type_str = str(noarch_type) | ||||||
if noarch_type or m.python_version_independent: | ||||||
if noarch_type: | ||||||
noarch_type_str = str(noarch_type) | ||||||
elif m.python_version_independent: | ||||||
noarch_type_str = "python" | ||||||
noarch_dict = OrderedDict(type=noarch_type_str) | ||||||
if noarch_type_str.lower() == "python": | ||||||
entry_points = m.get_value("build/entry_points") | ||||||
|
@@ -1441,13 +1444,14 @@ def create_info_files(m, replacements, files, prefix): | |||||
|
||||||
|
||||||
def get_short_path(m, target_file): | ||||||
if m.python_version_independent: | ||||||
if (site_packages_idx := target_file.find("site-packages")) >= 0: | ||||||
return target_file[site_packages_idx:] | ||||||
if m.noarch == "python": | ||||||
entry_point_script_names = get_entry_point_script_names( | ||||||
m.get_value("build/entry_points") | ||||||
) | ||||||
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 ( | ||||||
target_file not in entry_point_script_names | ||||||
): | ||||||
return target_file.replace("bin", "python-scripts") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
@@ -1665,6 +1669,9 @@ def post_process_files(m: MetaData, initial_prefix_files): | |||||
noarch_python.populate_files( | ||||||
m, pkg_files, host_prefix, entry_point_script_names | ||||||
) | ||||||
elif m.python_version_independent: | ||||||
# For non noarch: python ones, we don't need to handle entry points in a special way. | ||||||
noarch_python.populate_files(m, pkg_files, host_prefix, []) | ||||||
|
||||||
current_prefix_files = utils.prefix_files(prefix=host_prefix) | ||||||
new_files = current_prefix_files - initial_prefix_files | ||||||
|
@@ -3036,7 +3043,7 @@ def _set_env_variables_for_build(m, env): | |||||
# locally, and if we don't, it's a problem. | ||||||
env["PIP_NO_INDEX"] = True | ||||||
|
||||||
if m.noarch == "python": | ||||||
if m.python_version_independent: | ||||||
env["PYTHONDONTWRITEBYTECODE"] = True | ||||||
|
||||||
# The stuff in replacements is not parsable in a shell script (or we need to escape it) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -701,6 +701,61 @@ conda >=4.3 to install. | |||||
it was built, which probably will result in incorrect/incomplete installation in other | ||||||
platforms. | ||||||
|
||||||
Python version independent packages | ||||||
----------------------------------- | ||||||
|
||||||
Allows you to specify "no python version" when building a Python | ||||||
package thus making it compatible with a user specified range of Python | ||||||
versions. Main use-case for this is to create ABI3 packages as specified | ||||||
in [CEP 20](https://github.com/conda/ceps/blob/main/cep-0020.md). | ||||||
|
||||||
ABI3 packages support building a native Python extension using a | ||||||
specific Python version and running it against any later Python version. | ||||||
ABI3 or stable ABI is supported by only CPython - the reference Python | ||||||
implementation with the Global Interpreter Lock (GIL) enabled. Therefore | ||||||
package builders who wishes to support the free-threaded python build | ||||||
or another implementation like PyPy still has to build a conda package | ||||||
specific to that ABI as they don't support ABI3. There are other | ||||||
proposed standards like HPy and ABI4 (work-in-progress) that tries | ||||||
to address all python implementations. | ||||||
|
||||||
conda-build can indicate that a conda package works for any python version | ||||||
by adding | ||||||
|
||||||
.. code-block:: yaml | ||||||
|
||||||
build: | ||||||
python_version_independent: true | ||||||
|
||||||
A package builder also has to indicate which standard is supported by | ||||||
the package, i.e., for ABI3, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
AFAIK, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add it to defaults too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
|
||||||
.. code-block:: yaml | ||||||
|
||||||
requirements: | ||||||
host: | ||||||
- python-abi3 | ||||||
- python | ||||||
run: | ||||||
- python | ||||||
|
||||||
|
||||||
In order to support ABI3 with Python 3.9 and onwards and | ||||||
free-threaded builds you can do | ||||||
|
||||||
.. code-block:: yaml | ||||||
build: | ||||||
python_version_independent: true # [py == 39] | ||||||
skip: true # [py > 39 and not python.endswith("t")] | ||||||
|
||||||
requirements: | ||||||
host: | ||||||
- python-abi3 # [py == 39] | ||||||
- python | ||||||
run: | ||||||
- python | ||||||
|
||||||
|
||||||
Include build recipe | ||||||
-------------------- | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### Enhancements | ||
|
||
* Added an option `build.python_version_independent` to recipes to support | ||
building ABI3 for one CPython version and using the package in any | ||
later version. (#5456) | ||
|
||
### 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,28 @@ | ||
package: | ||
name: python_version_independent_test_package | ||
version: "1.0" | ||
|
||
source: | ||
path: ../_noarch_python_with_tests/noarch_python_test_package | ||
|
||
build: | ||
script: python setup.py install --single-version-externally-managed --record=record.txt | ||
python_version_independent: true | ||
entry_points: | ||
- noarch_python_test_package_script = noarch_python_test_package:main | ||
|
||
requirements: | ||
build: | ||
host: | ||
- python 3.11.* | ||
- setuptools | ||
run: | ||
- python >=3.11 | ||
|
||
test: | ||
requires: | ||
- python 3.12.* | ||
imports: | ||
- noarch_python_test_package | ||
commands: | ||
- noarch_python_test_package_script |
There was a problem hiding this comment.
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
?(And in that case, update the replace below?)
There was a problem hiding this comment.
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?