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

Add python-abi3 #28743

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions recipes/python-abi3/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2015-2023, conda-forge
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of staged-recipes nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 11 additions & 0 deletions recipes/python-abi3/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:: Copy the [de]activate scripts to %PREFIX%\etc\conda\[de]activate.d.
:: This will allow them to be run on environment activation.
FOR %%F IN (activate deactivate) DO (
if not exist %PREFIX%\etc\conda\%%F.d MKDIR %PREFIX%\etc\conda\%%F.d
if errorlevel 1 exit 1
sed "s/@PY_LIMITED_API/%PY_LIMITED_API%/g" %RECIPE_DIR%\scripts\%%F.bat >> %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat
Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot to create the bat versions of the activation scripts. This didn't fail here because this call didn't have an if errorlevel.

:: We also copy .sh scripts to be able to use them
:: with POSIX CLI on Windows.
sed "s/@PY_LIMITED_API/%PY_LIMITED_API%/g" %RECIPE_DIR%\scripts\%%F.sh >> %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.sh
if errorlevel 1 exit 1
)
7 changes: 7 additions & 0 deletions recipes/python-abi3/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d.
# This will allow them to be run on environment activation.
for CHANGE in "activate" "deactivate"
do
mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
sed "s/@PY_LIMITED_API@/${PY_LIMITED_API}/g" "${RECIPE_DIR}/scripts/${CHANGE}.sh" >> "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
done
3 changes: 3 additions & 0 deletions recipes/python-abi3/conda-forge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
noarch_platforms:
- linux_64
- win_64
15 changes: 15 additions & 0 deletions recipes/python-abi3/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
version_hex:
- "0x03090000"
- "0x030a0000"
- "0x030b0000"
- "0x030c0000"
- "0x030d0000"
zip_keys:
- - version
- version_hex
46 changes: 46 additions & 0 deletions recipes/python-abi3/example-meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package:
name: python-abi3-package-sample
version: 0.0.1

source:
url: https://github.com/joerick/python-abi3-package-sample/archive/6f74ae7b31e58ef5f8f09b647364854122e61155.tar.gz
sha256: e81fd4d4c4f5b7bc9786d9ee990afc659e14a25ce11182b7b69f826407cc1718

build:
number: 0
python_version_independent: true # [is_abi3]
script: {{ PYTHON }} -m pip install . -vv
skip: True # [is_abi3 and not is_python_min]

requirements:
build:
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- python-abi3 # [is_abi3]
- python
- pip
- setuptools
run:
- python

test:
imports:
- spam
requires:
- pip
- abi3audit
commands:
- pip check
- abi3audit $SP_DIR/spam.abi3.so -s -v --assume-minimum-abi3 {{ python_min }} # [unix]
- abi3audit %SP_DIR%/spam.dll -s -v --assume-minimum-abi3 {{ python_min }} # [win]

about:
home: https://github.com/joerick/python-abi3-package-sample
summary: 'ABI3 example'
license: Apache-2.0
license_file: LICENSE

extra:
recipe-maintainers:
- isuruf
61 changes: 61 additions & 0 deletions recipes/python-abi3/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% if version is not defined %}
{% set version = "3.9" %}
{% endif %}

package:
name: python-abi3-split
version: {{ version }}

build:
number: 0

outputs:
- name: python-abi3
build:
noarch: generic
run_exports:
- _python_abi3_support 1.*
- python >={{ version }}
script_env:
- PY_LIMITED_API={{ version_hex }}
requirements:
build:
- sed # [unix]
- m2-sed # [win]
host:
run:
- python {{ version }}
- _python_abi3_support
- __unix # [unix]
- __win # [win]
test:
commands:
- echo "hello world!"

- name: _python_abi3_support
version: 1.0
build:
noarch: generic
requirements:
run:
- cpython
- python-gil
test:
commands:
- echo "hello world!"

about:
home: https://github.com/conda-forge/python-abi3-feedstock
summary: 'Support Python ABI3 packages on conda'
description: |
python-abi3 package can be used for supporting ABI3 packages on
conda-forge. ABI3 supports building a C extension for one specific
CPython version and make it work on any later version.
(freethreading is not supported)
license: MIT
license_file: LICENSE.txt

extra:
feedstock-name: python-abi3
recipe-maintainers:
- isuruf
2 changes: 2 additions & 0 deletions recipes/python-abi3/scripts/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export PY_LIMITED_API="@PY_LIMITED_API@"
export CPPFLAGS="${CPPFLAGS} -DPy_LIMITED_API=@PY_LIMITED_API@"
1 change: 1 addition & 0 deletions recipes/python-abi3/scripts/deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unset PY_LIMITED_API
Loading