Skip to content

Commit

Permalink
Switch to ABI3 compatible wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Dec 11, 2024
1 parent d5f17b3 commit 07f7ca5
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 188 deletions.
135 changes: 84 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,31 @@ on:
- published

jobs:
build_test_wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: build
env:
SYSTEMRDL_REQUIRE_BINARY_BUILD: ~
run: |
python -m pip install build
python -m build
- uses: actions/upload-artifact@v4
with:
name: test_wheel
path: dist/*.whl

#-------------------------------------------------------------------------------
test:
needs:
- build_test_wheel
strategy:
matrix:
python-version:
Expand Down Expand Up @@ -40,20 +64,22 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install -U pytest pytest-cov coveralls>=3.0.0 parameterized
- uses: actions/download-artifact@v4
with:
name: test_wheel
path: dist

- name: Install
run: |
python -m pip install .
python -m pip install dist/*.whl
python -m pip install -r test/requirements.txt
- name: Test
run: |
Expand All @@ -67,12 +93,12 @@ jobs:
pytest
- name: Coveralls
if: ${{ matrix.python-version != 3.5 }} # coveralls no longer works well on 3.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
run: |
cd test
python -m pip install -U coveralls>=3.0.0
coveralls --service=github
finish_coveralls:
Expand All @@ -94,46 +120,55 @@ jobs:
#-------------------------------------------------------------------------------
lint:
needs:
- build_test_wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install -U pylint
- uses: actions/download-artifact@v4
with:
name: test_wheel
path: dist

- name: Install
run: |
python setup.py install
python -m pip install dist/*.whl
python -m pip install -r test/requirements.txt
- name: Run Lint
run: |
pylint --rcfile test/pylint.rc systemrdl
pylint --rcfile test/pylint.rc src/systemrdl
#-------------------------------------------------------------------------------
mypy:
needs:
- build_test_wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install -U types-Markdown
- uses: actions/download-artifact@v4
with:
name: test_wheel
path: dist

# Exclude version due to: https://github.com/python/mypy/issues/16770
python -m pip install -U "mypy != 1.8.0"
- name: Install
run: |
python -m pip install dist/*.whl
python -m pip install -r test/requirements.txt
- name: Type Check
run: |
mypy --config-file test/mypy.ini systemrdl
mypy --config-file test/mypy.ini src/systemrdl
#-------------------------------------------------------------------------------
build_wheels:
Expand All @@ -149,47 +184,40 @@ jobs:
os:
- windows-latest
- macos-latest
- ubuntu-latest
include:
# Only build CPython 3.x targets
- cibw_build: "cp3*"
cibw_skip: ""
name_suffix: ""

# Parallelize Linux builds because there are many!
- os: ubuntu-latest
name_suffix: "manylinux_x86_64"
cibw_build: "cp3*-manylinux_x86_64"
cibw_skip: ""
- os: ubuntu-latest
name_suffix: "manylinux_i686"
cibw_build: "cp3*-manylinux_i686"
cibw_skip: ""
- os: ubuntu-latest
name_suffix: "musllinux_x86_64"
cibw_build: "cp3*-musllinux_x86_64"
cibw_skip: ""
- os: ubuntu-latest
name_suffix: "others"
cibw_build: "cp3*"
cibw_skip: "cp3*-{manylinux_x86_64,manylinux_i686,musllinux_x86_64}"


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: ${{ matrix.cibw_skip }}
# Only build CPython 3.x targets
CIBW_BUILD: "cp3*"
# Ensure full C++17 availability on macOS builds
MACOSX_DEPLOYMENT_TARGET: "10.13"
# Signal setup.py to fail if binary build fails
SYSTEMRDL_REQUIRE_BINARY_BUILD: ~

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install abi3audit
- name: ABI3 audit
run: |
abi3audit --debug --verbose --summary --strict wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
name: whl-${{ matrix.os }}${{ matrix.name_suffix }}
name: release-dist-whl-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

#-------------------------------------------------------------------------------
Expand All @@ -201,18 +229,22 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install build
- name: Build sdist
run: python setup.py sdist
run: python -m build --sdist

- uses: actions/upload-artifact@v4
name: sdist
name: release-dist-sdist
with:
path: dist/*.tar.gz

Expand All @@ -229,6 +261,7 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-dist-*
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
8 changes: 3 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
include LICENSE
include LICENSE-3RD-PARTY
include systemrdl/preprocessor/ppp_runner.pl
include systemrdl/py.typed
recursive-include systemrdl/parser/ext *
recursive-exclude test *
recursive-exclude docs *
recursive-exclude examples *
recursive-exclude .github *
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ def run_setup(with_binary):
sources=get_files("src/systemrdl/parser/ext", "*.cpp"),
depends=get_files("src/systemrdl/parser/ext", "*.h"),

extra_compile_args=extra_compile_args.get(target, [])
extra_compile_args=extra_compile_args.get(target, []),
define_macros=[("Py_LIMITED_API", "0x03060000")],
py_limited_api=True,
)
ext_modules = [parser_ext]
options = {"bdist_wheel": {"py_limited_api": "cp36"}}
else:
ext_modules = []
options = {}

setuptools.setup(
ext_modules=ext_modules,
cmdclass={"build_ext": ve_build_ext},
options=options,
)


Expand Down Expand Up @@ -89,6 +94,9 @@ def build_extension(self, ext):
# Force using fallback python parser under some conditions
using_fallback = is_jython or is_pypy or is_old_python

if 'SYSTEMRDL_SKIP_BINARY_BUILD' in os.environ:
using_fallback = True

if not using_fallback:
try:
run_setup(with_binary=True)
Expand Down
Loading

0 comments on commit 07f7ca5

Please sign in to comment.