Skip to content
Open
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
77 changes: 55 additions & 22 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,61 @@

# This workflow follow documentation from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

# Example of cibuildwheel from https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml

name: Publish

# TODO revert before merge
on:
push:
branches: ['master']
tags: ['*']
push

permissions:
contents: read

jobs:
build:
build_wheels:
name: Build wheel on ${{ matrix.os }} for python ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: windows-latest
python: 39
platform_id: win_amd64
- os: macos-13
python: 39
platform_id: macosx_x86_64
steps:
- uses: actions/checkout@v4
- name: Build wheels
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
run: |
python -m pip install cibuildwheel pipenv
python -m cibuildwheel --output-dir wheelhouse
- name: Upload wheel for ${{ matrix.os }} ${{ strategy.job-index }}
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_dist:
name: Prepare distribution packages
runs-on: ubuntu-latest
environment:
name: build
strategy:
matrix:
python-version: ['3.9']
steps:
- uses: actions/checkout@v4
- name: Unshallow repo clone
run: git fetch --prune --unshallow --tags
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9
cache: 'pipenv'
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
Expand All @@ -38,15 +66,17 @@ jobs:
- name: Build package
run: pipenv run python ./setup.py build_ext -i -j2 bdist_wheel
- name: Store the distribution packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
name: cibw-dist
path: dist/*.tar.gz
# TODO add twine check dist/*.tar.gz
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
- build_wheels
- build_dist
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -55,16 +85,18 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build
- build_wheels
- build_dist
runs-on: ubuntu-latest

environment:
Expand All @@ -76,10 +108,11 @@ jobs:

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ name: Dev
on:
push:
branches: ['master']
pull_request:
branches: ['master']
# TODO revert before merge
# pull_request:
# branches: ['master']

jobs:
tests:
Expand All @@ -17,8 +18,6 @@ jobs:
name: build
steps:
- uses: actions/checkout@v4
- name: Unshallow repo clone
run: git fetch --prune --unshallow --tags
- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include MANIFEST.in
include pyproject.toml
include *.txt
recursive-include cyperf/tools *.pyx.in *.pxd.in
recursive-include cyperf *.pyx *.pxd *.py *.pxi *.cc *.h
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "pipenv", "numpy>=1.19.5", "cython>=0.29.5,<3.0.0", "scipy>=1.2.0"]
3 changes: 3 additions & 0 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def get_version():
version_returned = 'unknown'
print(f"version=={version_returned}")
return version_returned
# unshallow repo clone to make `git describe` work in CI
_run(['git', 'fetch', '--prune', '--unshallow', '--tags'])
describe_cmd = ['git', 'describe', '--tags', '--always']
last_tag = _run(describe_cmd + ['--abbrev=0']) # '1.0.14'
describe = _run(describe_cmd) # '1.0.14-2-gfaa2442' {tag}-{nb_commit_since_tag}-{hash}'
Expand All @@ -48,6 +50,7 @@ def get_version():
version_returned = f"{last_tag.replace('v', '', 1)}.dev0+{short_hash[1:]}"
LOGGER.info("version==%s", version_returned)
print(f"version=={version_returned}")
print(_run(['pip', 'freeze']))
return version_returned


Expand Down