Supported builds with limited API
This commit is contained in:
parent
e5f2cc21c3
commit
a90d5e2289
5 changed files with 47 additions and 5 deletions
30
.github/workflows/build.yaml
vendored
30
.github/workflows/build.yaml
vendored
|
|
@ -25,7 +25,35 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install setuptools "cython >= 3" pytest
|
pip install setuptools "cython >= 3.1" pytest
|
||||||
|
- name: Build with Python ${{ matrix.python-version }}
|
||||||
|
run: |
|
||||||
|
python setup.py build
|
||||||
|
python setup.py build_ext -i
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
|
env:
|
||||||
|
LC_ALL: C.UTF-8
|
||||||
|
LANG: C.UTF-8
|
||||||
|
|
||||||
|
build-limited-api:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
env:
|
||||||
|
USE_LIMITED_API: "1"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v6
|
||||||
|
python-version: "3.x"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install setuptools "cython >= 3.1" pytest
|
||||||
- name: Build with Python ${{ matrix.python-version }}
|
- name: Build with Python ${{ matrix.python-version }}
|
||||||
run: |
|
run: |
|
||||||
python setup.py build
|
python setup.py build
|
||||||
|
|
|
||||||
4
.github/workflows/publish-twine.yaml
vendored
4
.github/workflows/publish-twine.yaml
vendored
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
- name: Install cibuildwheel
|
- name: Install cibuildwheel
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install cibuildwheel
|
python -m pip install "cython >= 3.1" cibuildwheel
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: |
|
run: |
|
||||||
python -m cibuildwheel --output-dir dist
|
python -m cibuildwheel --output-dir dist
|
||||||
|
|
@ -46,7 +46,7 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install setuptools "cython >= 3"
|
pip install setuptools "cython >= 3.1"
|
||||||
- name: Build sdist
|
- name: Build sdist
|
||||||
run: |
|
run: |
|
||||||
python setup.py build
|
python setup.py build
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ functionality.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* `Cython >= 3` (optional, only for building). If Cython is not available, the C files are not
|
* `Cython >= 3.1` (optional, only for building). If Cython is not available, the C files are not
|
||||||
regenerated from their source.
|
regenerated from their source.
|
||||||
|
|
||||||
## Quick installation guide
|
## Quick installation guide
|
||||||
|
|
@ -25,6 +25,9 @@ or by running:
|
||||||
python3 setup.py install
|
python3 setup.py install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In case the extension should be built with the limited Python API, set the environment variable
|
||||||
|
`USE_LIMITED_API` to any value.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```python3
|
```python3
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools >= 43",
|
"setuptools >= 43",
|
||||||
"Cython >= 3",
|
"Cython >= 3.1",
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
|
|
||||||
11
setup.py
11
setup.py
|
|
@ -1,9 +1,13 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
|
|
||||||
|
use_limited_api = "USE_LIMITED_API" in os.environ
|
||||||
|
|
||||||
|
|
||||||
extension_sources = ["cwcwidth/_impl.pyx"]
|
extension_sources = ["cwcwidth/_impl.pyx"]
|
||||||
define_macros = []
|
define_macros = []
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
|
|
@ -12,11 +16,17 @@ if platform.system() == "Windows":
|
||||||
("USE_MK_WCWIDTH", None),
|
("USE_MK_WCWIDTH", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
options = {}
|
||||||
|
if use_limited_api:
|
||||||
|
define_macros.append(("Py_LIMITED_API", 0x030B0000)) # 3.11
|
||||||
|
options["bdist_wheel"] = {"py_limited_api": "cp311"}
|
||||||
|
|
||||||
ext_modules = [
|
ext_modules = [
|
||||||
Extension(
|
Extension(
|
||||||
"cwcwidth._impl",
|
"cwcwidth._impl",
|
||||||
extension_sources,
|
extension_sources,
|
||||||
define_macros=define_macros,
|
define_macros=define_macros,
|
||||||
|
py_limited_api=use_limited_api,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -26,4 +36,5 @@ setup(
|
||||||
package_data={
|
package_data={
|
||||||
"cwcwidth": ["_impl.pyi", "py.typed"],
|
"cwcwidth": ["_impl.pyi", "py.typed"],
|
||||||
},
|
},
|
||||||
|
options=options,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue