-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.0: Setup CI/CD using cibuildwheel + GitHub Actions, Makefile, bu…
…ild (#2) * v1.0.0: Setup CI/CD using cibuildwheel + GitHub Actions, Makefile, build - Makefile that allows in-place testing using make test - setup.py that always turns on optimizations on Linux prod builds - GitHub Actions/cibuildhweel config isolating the tests from source - Badges - v1.0.0 - Update benchmarks: now 40x faster than wcwidth
- Loading branch information
Showing
6 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
name: Build and upload | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
if: github.event_name == 'release' && github.event.action == 'created' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_TEST_COMMAND_WINDOWS: > | ||
cd /d {package} | ||
&& ( rmdir ..\uwcwidth_tmp /s /q 2>NUL || cd . ) | ||
&& mkdir ..\uwcwidth_tmp | ||
&& cd ..\uwcwidth_tmp | ||
&& xcopy {package} /s | ||
&& rmdir uwcwidth /s /q | ||
&& pytest | ||
- 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 | ||
if: github.event_name == 'release' && github.event.action == 'created' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: python3 -m pip install --upgrade build | ||
|
||
- name: Build sdist | ||
run: python3 -m build --sdist | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-sdist | ||
path: dist/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: production | ||
permissions: | ||
id-token: write | ||
if: | | ||
github.event_name == 'release' && github.event.action == 'created' | ||
&& !endsWith(github.ref, '-test') | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
upload_pypi_test: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: production | ||
permissions: | ||
id-token: write | ||
if: | | ||
github.event_name == 'release' && github.event.action == 'created' | ||
&& endsWith(github.ref, '-test') | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
upload_gh_release: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: production | ||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- uses: softprops/action-gh-release@v2 | ||
with: | ||
files: dist/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'README.md' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.13' | ||
- run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.PHONY: all build build-debug clean clean-build clean-venv test | ||
|
||
all: build venv | ||
@: | ||
|
||
build: venv | ||
DEBUG=$(DEBUG) venv/bin/python3 setup.py build_ext --inplace | ||
|
||
build-debug: override DEBUG=1 | ||
build-debug: build ; | ||
|
||
clean: clean-venv clean-build | ||
@: | ||
|
||
clean-venv: | ||
rm -rf venv | ||
|
||
clean-build: | ||
rm -rf build | ||
|
||
test: build | ||
venv/bin/pytest | ||
|
||
venv: | ||
python3 -mvenv venv | ||
venv/bin/pip install setuptools Cython pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
# SPDX-License-Identifier: MIT | ||
import os | ||
import platform | ||
|
||
from setuptools import setup, Extension | ||
|
||
|
||
DEBUG=(os.getenv('DEBUG') or '').strip().lower() in ['1', 'y', 'true'] | ||
MSVC=(platform.platform().startswith('Windows') and | ||
platform.python_compiler().startswith('MS')) | ||
COMPILE_ARGS=[] if MSVC else (["-g", "-O0", "-UNDEBUG"] if DEBUG else ["-O3"]) | ||
|
||
|
||
def uwcwidth_ext(module, pyx_file): | ||
return Extension(module, | ||
sources=[pyx_file], | ||
extra_compile_args=COMPILE_ARGS) | ||
|
||
|
||
setup( | ||
name='uwcwidth', | ||
ext_modules=[Extension("uwcwidth.uwcwidth", | ||
sources=["uwcwidth/uwcwidth.pyx"])], | ||
ext_modules=[uwcwidth_ext("uwcwidth.uwcwidth", "uwcwidth/uwcwidth.pyx")], | ||
package_data={'uwcwidth': ['__init__.pxd', 'uwcwidth.pxd', 'tables.pxd']} | ||
) |