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

Port wrapt to heap types and stable ABI #187

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
13 changes: 5 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ jobs:
name: Test (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10-dev
- pypy-2.7
- pypy-3.6
- pypy-3.7
steps:
Expand All @@ -45,18 +43,16 @@ jobs:
name: Test (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
python-version:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10-dev
- pypy-2.7
- pypy-3.6
- pypy-3.7
steps:
Expand All @@ -82,17 +78,16 @@ jobs:
name: Test (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
python-version:
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10-dev
- pypy-2.7
- pypy-3.6
- pypy-3.7
steps:
Expand Down Expand Up @@ -152,6 +147,8 @@ jobs:
env:
WRAPT_INSTALL_EXTENSIONS: true # Require extensions.
CIBW_SKIP: pp* # Skip wheels for PyPy.
# build on 3.6 to 3.9. cp39 provides stable abi cp39-abi3
CIBW_BUILD: cp36-* cp37-* cp38-* cp39-*
- uses: actions/upload-artifact@v2
with:
name: dist
Expand Down
10 changes: 2 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ keywords = wrapper, proxy, decorator
classifiers =
Development Status :: 5 - Production/Stable
License :: OSI Approved :: BSD License
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Expand All @@ -34,7 +31,7 @@ project_urls =

[options]
zip_safe = false
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*
python_requires = >= 3.6
packages = find:
package_dir =
=src
Expand Down Expand Up @@ -71,19 +68,16 @@ norecursedirs = .tox venv

[tox:tox]
envlist =
py{27,35,36,37,38,39,310}-{without,install,disable}-extensions,
py{36,37,38,39,310}-{without,install,disable}-extensions,
pypy-without-extensions

[gh-actions]
python =
2.7: py27, py27-without-extensions, py27-install-extensions, py27-disable-extensions
3.5: py35, py35-without-extensions, py35-install-extensions, py35-disable-extensions
3.6: py36, py36-without-extensions, py36-install-extensions, py36-disable-extensions
3.7: py37, py37-without-extensions, py37-install-extensions, py37-disable-extensions
3.8: py38, py38-without-extensions, py38-install-extensions, py38-disable-extensions
3.9: py39, py39-without-extensions, py39-install-extensions, py39-disable-extensions
3.10: py310, py310-without-extensions, py310-install-extensions, py310-disable-extensions
pypy-2.7: pypy-without-extensions
pypy-3.6: pypy-without-extensions
pypy-3.7: pypy-without-extensions

Expand Down
33 changes: 32 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import os
import platform

import sys
import setuptools

try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
bdist_wheel = None


# # --- Detect if extensions should be disabled ------------------------------

Expand All @@ -17,19 +24,43 @@
if platform.python_implementation() != "CPython":
disable_extensions = True

# # --- stable ABI / limited API hacks ---------------------------------------
# Python < 3.9 is missing some features to build wheels with stable ABI

define_macros = []
cmdclass = {}

if sys.version_info >= (3, 9, 0) and platform.python_implementation() == "CPython":
py_limited_api = True
define_macros.append(("Py_LIMITED_API", "0x03090000"))

if bdist_wheel is not None:
class LimitedAPIWheel(bdist_wheel):
def finalize_options(self):
self.py_limited_api = "cp39"
bdist_wheel.finalize_options(self)

cmdclass["bdist_wheel"] = LimitedAPIWheel
else:
py_limited_api = False


# --- C extension ------------------------------------------------------------

extensions = [
setuptools.Extension(
"wrapt._wrappers",
sources=["src/wrapt/_wrappers.c"],
optional=not force_extensions,
py_limited_api=py_limited_api,
define_macros=define_macros,
)
]


# --- Setup ------------------------------------------------------------------

setuptools.setup(
ext_modules=[] if disable_extensions else extensions
ext_modules=[] if disable_extensions else extensions,
cmdclass=cmdclass
)
Loading