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

Use scikit-build-core to build ABI3 wheels #6

Merged
merged 8 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
experimental: [false]
python-version: ["3.7", "3.12"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- { python-version: "3.7", os: "macos-latest", experimental: false }
- { python-version: "3.8", os: "macos-latest", experimental: false }
- { python-version: "3.9", os: "macos-latest", experimental: false }
- { python-version: "3.13", os: "windows-latest", experimental: false }
include:
# Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
- { python-version: "3.7", os: "macos-13", experimental: false }
- { python-version: "3.8", os: "macos-13", experimental: false }
- { python-version: "3.9", os: "macos-13", experimental: false }
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install tox
Expand All @@ -31,9 +43,9 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
Expand All @@ -44,8 +56,3 @@ jobs:
- name: Build documentation
run: |
python -m sphinx -W -an doc build
- uses: actions/upload-artifact@v3
with:
name: sphinx-out
path: ./build/
retention-days: 5
40 changes: 25 additions & 15 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch tags for setuptools-scm

# Used to host cibuildwheel
- uses: actions/setup-python@v4
# Used to host cibuildwhee
- uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand All @@ -32,41 +34,49 @@ jobs:
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch tags for setuptools-scm
- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Build sdist
run: pipx run build --sdist

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

upload_pypi:
name: Create release
needs: [ build_wheels, build_sdist ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/autosar_e2e
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # for action-gh-release

# upload to PyPI only on release
if: github.event.release && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ venv*/
ENV/
env.bak/
venv.bak/
.venv*

# Spyder project settings
.spyderproject
Expand All @@ -136,3 +137,4 @@ dmypy.json
/.vscode/

/autosar_specs/
/src/e2e/_version.py
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.15...3.26)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)

find_package(Python
REQUIRED
COMPONENTS
Interpreter
Development.Module
${SKBUILD_SABI_COMPONENT})

if(NOT "${SKBUILD_SABI_COMPONENT}" STREQUAL "")
python_add_library(crc
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI USE_SABI 3.11)
python_add_library(p01
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p01.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI USE_SABI 3.11)
python_add_library(p02
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p02.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI USE_SABI 3.11)
python_add_library(p05
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p05.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI USE_SABI 3.11)
else()
python_add_library(crc
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI)
python_add_library(p01
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p01.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI)
python_add_library(p02
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p02.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI)
python_add_library(p05
MODULE
${CMAKE_SOURCE_DIR}/src/e2e/p05.c
${CMAKE_SOURCE_DIR}/src/e2e/crc.c
WITH_SOABI)
endif()

install(TARGETS crc p01 p02 p05 LIBRARY DESTINATION e2e)
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
build-backend = 'setuptools.build_meta'
requires = ["setuptools >= 62.0"]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"

[project]
name = "autosar-e2e"
Expand Down Expand Up @@ -36,14 +36,14 @@ Issues = "https://github.com/zariiii9003/autosar-e2e/issues"
Source = "https://github.com/zariiii9003/autosar-e2e"
Homepage = "https://github.com/zariiii9003/autosar-e2e"

[tool.setuptools.dynamic]
version = {attr = "e2e.__version__"}
[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/e2e/_version.py"]
wheel.packages = ["src/e2e"]
wheel.py-api = "cp311"

[tool.setuptools.package-data]
"*" = [
"**/py.typed",
"**.pyi",
]
[tool.setuptools_scm] # Section required
write_to = "src/e2e/_version.py"

[tool.cibuildwheel]
test-requires = "pytest"
Expand Down
48 changes: 0 additions & 48 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/e2e/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__version__ = "0.4.1"

__all__ = [
"__version__",
"crc",
"p01",
"p02",
Expand All @@ -11,3 +10,4 @@
from e2e import p01 as p01
from e2e import p02 as p02
from e2e import p05 as p05
from e2e._version import __version__
14 changes: 7 additions & 7 deletions src/e2e/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,31 +495,31 @@ py_calculate_crc64(PyObject *module,

static struct PyMethodDef methods[] = {
{"calculate_crc8",
py_calculate_crc8,
(PyCFunction)py_calculate_crc8,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc8_doc},
{"calculate_crc8_h2f",
py_calculate_crc8_h2f,
(PyCFunction)py_calculate_crc8_h2f,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc8_h2f_doc},
{"calculate_crc16",
py_calculate_crc16,
(PyCFunction)py_calculate_crc16,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc16_doc},
{"calculate_crc16_arc",
py_calculate_crc16_arc,
(PyCFunction)py_calculate_crc16_arc,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc16_arc_doc},
{"calculate_crc32",
py_calculate_crc32,
(PyCFunction)py_calculate_crc32,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc32_doc},
{"calculate_crc32_p4",
py_calculate_crc32_p4,
(PyCFunction)py_calculate_crc32_p4,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc32_p4_doc},
{"calculate_crc64",
py_calculate_crc64,
(PyCFunction)py_calculate_crc64,
METH_VARARGS | METH_KEYWORDS,
py_calculate_crc64_doc},
{NULL} // sentinel
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/p01.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ py_e2e_p01_check(PyObject *module,

static struct PyMethodDef methods[] = {
{"e2e_p01_protect",
py_e2e_p01_protect,
(PyCFunction)py_e2e_p01_protect,
METH_VARARGS | METH_KEYWORDS,
e2e_p01_protect_doc},
{"e2e_p01_check",
py_e2e_p01_check,
(PyCFunction)py_e2e_p01_check,
METH_VARARGS | METH_KEYWORDS,
e2e_p01_check_doc},
{NULL} // sentinel
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/p02.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ py_e2e_p02_check(PyObject *module,

static struct PyMethodDef methods[] = {
{"e2e_p02_protect",
py_e2e_p02_protect,
(PyCFunction)py_e2e_p02_protect,
METH_VARARGS | METH_KEYWORDS,
e2e_p02_protect_doc},
{"e2e_p02_check",
py_e2e_p02_check,
(PyCFunction)py_e2e_p02_check,
METH_VARARGS | METH_KEYWORDS,
e2e_p02_check_doc},
{NULL} // sentinel
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/p05.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ py_e2e_p05_check(PyObject *module,

static struct PyMethodDef methods[] = {
{"e2e_p05_protect",
py_e2e_p05_protect,
(PyCFunction)py_e2e_p05_protect,
METH_VARARGS | METH_KEYWORDS,
e2e_p05_protect_doc},
{"e2e_p05_check",
py_e2e_p05_check,
(PyCFunction)py_e2e_p05_check,
METH_VARARGS | METH_KEYWORDS,
e2e_p05_check_doc},
{NULL} // sentinel
Expand Down
Loading