Skip to content

Commit

Permalink
use setup() options to pass py_limited_api to bdist_wheel & bump cibu…
Browse files Browse the repository at this point in the history
…ildwheel (#2450)

Signed-off-by: mayeut <mayeut@users.noreply.github.com>
  • Loading branch information
mayeut authored Oct 3, 2024
1 parent f84ca7d commit 7d21555
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
if: matrix.arch == 'aarch64'

- name: Create wheels + run tests
uses: pypa/cibuildwheel@v2.19.2
uses: pypa/cibuildwheel@v2.21.2
env:
CIBW_ARCHS: "${{ matrix.arch }}"
CIBW_PRERELEASE_PYTHONS: True
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ archs = ["arm64", "x86_64"]

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=43", "wheel"]
requires = ["setuptools>=43"]
27 changes: 8 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@
from setuptools import Extension
from setuptools import setup
except ImportError:
if "CIBUILDWHEEL" in os.environ:
raise
setuptools = None
from distutils.core import Extension
from distutils.core import setup
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
if "CIBUILDWHEEL" in os.environ:
raise
bdist_wheel = None

HERE = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -153,16 +149,19 @@ def get_version():

# Py_LIMITED_API lets us create a single wheel which works with multiple
# python versions, including unreleased ones.
if bdist_wheel and CP36_PLUS and (MACOS or LINUX) and not Py_GIL_DISABLED:
if setuptools and CP36_PLUS and (MACOS or LINUX) and not Py_GIL_DISABLED:
py_limited_api = {"py_limited_api": True}
options = {"bdist_wheel": {"py_limited_api": "cp36"}}
macros.append(('Py_LIMITED_API', '0x03060000'))
elif bdist_wheel and CP37_PLUS and WINDOWS and not Py_GIL_DISABLED:
elif setuptools and CP37_PLUS and WINDOWS and not Py_GIL_DISABLED:
# PyErr_SetFromWindowsErr / PyErr_SetFromWindowsErrWithFilename are
# part of the stable API/ABI starting with CPython 3.7
py_limited_api = {"py_limited_api": True}
options = {"bdist_wheel": {"py_limited_api": "cp37"}}
macros.append(('Py_LIMITED_API', '0x03070000'))
else:
py_limited_api = {}
options = {}


def get_long_description():
Expand Down Expand Up @@ -462,22 +461,11 @@ def get_sunos_update():
else:
extensions = [ext]

cmdclass = {}
if py_limited_api:

class bdist_wheel_abi3(bdist_wheel):
def get_tag(self):
python, _abi, plat = bdist_wheel.get_tag(self)
return python, "abi3", plat

cmdclass["bdist_wheel"] = bdist_wheel_abi3


def main():
kwargs = dict(
name='psutil',
version=VERSION,
cmdclass=cmdclass,
description=__doc__.replace('\n', ' ').strip() if __doc__ else '',
long_description=get_long_description(),
long_description_content_type='text/x-rst',
Expand All @@ -497,6 +485,7 @@ def main():
license='BSD-3-Clause',
packages=['psutil', 'psutil.tests'],
ext_modules=extensions,
options=options,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand Down

0 comments on commit 7d21555

Please sign in to comment.