From 0fcb98b9415a51831a7df3ec6bfc7382c4e5ccfd Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 30 Dec 2024 13:39:17 +0530 Subject: [PATCH 1/3] python-abi3 --- recipes/python-abi3/LICENSE.txt | 27 ++++++++++ recipes/python-abi3/bld.bat | 11 +++++ recipes/python-abi3/build.sh | 7 +++ recipes/python-abi3/conda-forge.yml | 3 ++ recipes/python-abi3/conda_build_config.yaml | 17 +++++++ recipes/python-abi3/example-meta.yaml | 46 +++++++++++++++++ recipes/python-abi3/meta.yaml | 55 +++++++++++++++++++++ recipes/python-abi3/scripts/activate.sh | 2 + recipes/python-abi3/scripts/deactivate.sh | 1 + 9 files changed, 169 insertions(+) create mode 100644 recipes/python-abi3/LICENSE.txt create mode 100644 recipes/python-abi3/bld.bat create mode 100644 recipes/python-abi3/build.sh create mode 100644 recipes/python-abi3/conda-forge.yml create mode 100644 recipes/python-abi3/conda_build_config.yaml create mode 100644 recipes/python-abi3/example-meta.yaml create mode 100644 recipes/python-abi3/meta.yaml create mode 100644 recipes/python-abi3/scripts/activate.sh create mode 100644 recipes/python-abi3/scripts/deactivate.sh diff --git a/recipes/python-abi3/LICENSE.txt b/recipes/python-abi3/LICENSE.txt new file mode 100644 index 0000000000000..d5ba276d41cb7 --- /dev/null +++ b/recipes/python-abi3/LICENSE.txt @@ -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. \ No newline at end of file diff --git a/recipes/python-abi3/bld.bat b/recipes/python-abi3/bld.bat new file mode 100644 index 0000000000000..08922ecd74520 --- /dev/null +++ b/recipes/python-abi3/bld.bat @@ -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 + :: 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 +) diff --git a/recipes/python-abi3/build.sh b/recipes/python-abi3/build.sh new file mode 100644 index 0000000000000..bb4a2ddea2e45 --- /dev/null +++ b/recipes/python-abi3/build.sh @@ -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 diff --git a/recipes/python-abi3/conda-forge.yml b/recipes/python-abi3/conda-forge.yml new file mode 100644 index 0000000000000..70803e27c2bca --- /dev/null +++ b/recipes/python-abi3/conda-forge.yml @@ -0,0 +1,3 @@ +noarch_platforms: +- linux_64 +- win_64 diff --git a/recipes/python-abi3/conda_build_config.yaml b/recipes/python-abi3/conda_build_config.yaml new file mode 100644 index 0000000000000..33f28732cdd5e --- /dev/null +++ b/recipes/python-abi3/conda_build_config.yaml @@ -0,0 +1,17 @@ +version: +- "3.8" +- "3.9" +- "3.10" +- "3.11" +- "3.12" +- "3.13" +version_hex: +- "0x03080000" +- "0x03090000" +- "0x030a0000" +- "0x030b0000" +- "0x030c0000" +- "0x030d0000" +zip_keys: +- - version + - version_hex diff --git a/recipes/python-abi3/example-meta.yaml b/recipes/python-abi3/example-meta.yaml new file mode 100644 index 0000000000000..76588e8838acd --- /dev/null +++ b/recipes/python-abi3/example-meta.yaml @@ -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 diff --git a/recipes/python-abi3/meta.yaml b/recipes/python-abi3/meta.yaml new file mode 100644 index 0000000000000..25429341a9054 --- /dev/null +++ b/recipes/python-abi3/meta.yaml @@ -0,0 +1,55 @@ +{% if version is not defined %} +{% set version = "3.9" %} +{% endif %} + +package: + name: python-abi3-split + version: {{ version }} + +outputs: + - name: python-abi3 + build: + number: 0 + 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 + noarch: generic + requirements: + run: + - cpython + - python-gil + +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 diff --git a/recipes/python-abi3/scripts/activate.sh b/recipes/python-abi3/scripts/activate.sh new file mode 100644 index 0000000000000..d99008bf30aed --- /dev/null +++ b/recipes/python-abi3/scripts/activate.sh @@ -0,0 +1,2 @@ +export PY_LIMITED_API="@PY_LIMITED_API@" +export CPPFLAGS="${CPPFLAGS} -DPy_LIMITED_API=@PY_LIMITED_API@" diff --git a/recipes/python-abi3/scripts/deactivate.sh b/recipes/python-abi3/scripts/deactivate.sh new file mode 100644 index 0000000000000..de0b8382ab0ca --- /dev/null +++ b/recipes/python-abi3/scripts/deactivate.sh @@ -0,0 +1 @@ +unset PY_LIMITED_API From fb730ea00002546794d10bbbd89d0313288666ef Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Fri, 3 Jan 2025 13:32:42 +0530 Subject: [PATCH 2/3] fix lints --- recipes/python-abi3/meta.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recipes/python-abi3/meta.yaml b/recipes/python-abi3/meta.yaml index 25429341a9054..e432e9578a5d0 100644 --- a/recipes/python-abi3/meta.yaml +++ b/recipes/python-abi3/meta.yaml @@ -6,10 +6,12 @@ package: name: python-abi3-split version: {{ version }} +build: + number: 0 + outputs: - name: python-abi3 build: - number: 0 noarch: generic run_exports: - _python_abi3_support 1.* @@ -32,11 +34,15 @@ outputs: - name: _python_abi3_support version: 1.0 - noarch: generic + build: + noarch: generic requirements: run: - cpython - python-gil + test: + commands: + - echo "hello world!" about: home: https://github.com/conda-forge/python-abi3-feedstock From edd77208be05403667d155030fb5f340fe8c3f70 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 6 Jan 2025 11:38:19 +0530 Subject: [PATCH 3/3] Delete 3.8 --- recipes/python-abi3/conda_build_config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/python-abi3/conda_build_config.yaml b/recipes/python-abi3/conda_build_config.yaml index 33f28732cdd5e..8fc3cb36ef171 100644 --- a/recipes/python-abi3/conda_build_config.yaml +++ b/recipes/python-abi3/conda_build_config.yaml @@ -1,12 +1,10 @@ version: -- "3.8" - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" version_hex: -- "0x03080000" - "0x03090000" - "0x030a0000" - "0x030b0000"