wheels: convert versions to match pypa spec, add uploading

* wheel versions now replace `+` with `.post` to match spec at https://packaging.python.org/en/latest/specifications/version-specifiers/
* CI updates:
  * Bump action versions
  * Disabled Windows for now and documented why
  * Added a new job to upload all wheels
  * Added new variable, `PYPI_INDEX`: fallback 'https://pypi.org/' if unset
  * Added new secret, `PYPI_TOKEN`
* .editorconfig now uses 2 spaces for YML (it kept setting mine to tabs
  and GitHub Actions doesn't like that)
This commit is contained in:
Mohamed Gaber 2024-10-04 16:14:26 +03:00
parent 08c23b7632
commit 0bb1f899e8
No known key found for this signature in database
3 changed files with 40 additions and 15 deletions

View File

@ -10,3 +10,7 @@ insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = false
[*.yml]
indent_style = space
indent_size = 2

View File

@ -1,8 +1,7 @@
name: Build Wheels for PyPI
on:
workflow_dispatch:
push:
# tags: ["yosys-*"]
jobs:
build_wheels:
strategy:
@ -37,24 +36,27 @@ jobs:
runner: "macos-14",
archs: "arm64",
},
{
name: "Windows Server 2019",
family: "windows",
runner: "windows-2019",
archs: "AMD64",
},
## Windows is disabled because of an issue with compiling FFI as
## under MinGW in the GitHub Actions environment (SHELL variable has
## whitespace.)
# {
# name: "Windows Server 2019",
# family: "windows",
# runner: "windows-2019",
# archs: "AMD64",
# },
]
name: Build Wheels | ${{ matrix.os.name }} | ${{ matrix.os.archs }}
runs-on: ${{ matrix.os.runner }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- if: ${{ matrix.os.family == 'linux' }}
name: "[Linux] Set up QEMU"
uses: docker/setup-qemu-action@v2
- uses: actions/setup-python@v3
uses: docker/setup-qemu-action@v3
- uses: actions/setup-python@v5
- name: Get Boost Source
shell: bash
run: |
@ -73,7 +75,7 @@ jobs:
brew install flex bison
echo "PATH=$(brew --prefix flex)/bin:$PATH" >> $GITHUB_ENV
echo "PATH=$(brew --prefix bison)/bin:$PATH" >> $GITHUB_ENV
- if : ${{ matrix.os.family == 'windows' }}
- if: ${{ matrix.os.family == 'windows' }}
name: "[Windows] Flex/Bison"
run: |
choco install winflexbison3
@ -86,7 +88,7 @@ jobs:
uses: pypa/cibuildwheel@v2.21.1
env:
# * APIs not supported by PyPy
# * Musllinux temporarily disabled because it takes too much time
# * Musllinux disabled because it increases build time from 48m to ~3h
CIBW_SKIP: >
pp*
*musllinux*
@ -109,6 +111,25 @@ jobs:
makeFlags='BOOST_PYTHON_LIB=./boost/pfx/lib/libboost_python*.a CONFIG=clang'
CIBW_BEFORE_BUILD: bash ./.github/workflows/wheels/cibw_before_build.sh
CIBW_TEST_COMMAND: python3 -c "from pyosys import libyosys as ys;d=ys.Design();ys.run_pass('help', d)"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: python-wheels
path: ./wheelhouse/*.whl
upload_wheels:
name: Upload Wheels
runs-on: ubuntu-latest
needs: build_wheels
steps:
- uses: actions/download-artifact@v4
with:
name: python-wheels
path: "."
- run: |
ls
mkdir -p ./dist
mv *.whl ./dist
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
repository-url: ${{ vars.PYPI_INDEX || 'https://upload.pypi.org/legacy/' }}

View File

@ -25,7 +25,7 @@ yosys_version_rx = re.compile(r"YOSYS_VER\s*:=\s*([\w\-\+\.]+)")
version = yosys_version_rx.search(
open(os.path.join(__dir__, "Makefile"), encoding="utf8").read()
)[1]
)[1].replace("+", ".post")
class libyosys_so_ext(Extension):