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

Add action to publish to testpypi #978

Merged
merged 6 commits into from
Apr 19, 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
28 changes: 15 additions & 13 deletions .github/workflows/freeze_requirements.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
name : Freeze release requirements

on:
push:
tags:
- '*'
release:
types: [published]

jobs:
freeze_requirements:
runs-on: scilus-runners
steps:
-
name: Checkout scilpy
- name: Checkout scilpy
uses: actions/checkout@v3
-
name: Install python
uses: actions/setup-python@v4

- name: Fetch python version from repository
id: python-selector
run: echo "python-version=$(head -1 .python-version)" >> $GITHUB_OUTPUT

- name: Set up Python for Scilpy
uses: actions/[email protected]
with:
python-version-file: '.python-version'
python-version: ${{ steps.python-selector.outputs.python-version }}
cache: 'pip'
-
name: Freeze requirements

- name: Freeze requirements
id: requirements-freezer
run: |
pip install pip-tools
pip-compile --no-upgrade --allow-unsafe -o requirements.${{ github.ref_name }}.frozen
echo "requirements=$PWD/requirements.${{ github.ref_name }}.frozen" >> $GITHUB_OUTPUT
-
name: Upload frozen requirements to release

- name: Upload frozen requirements to release
uses: softprops/action-gh-release@v1
with:
files : ${{ steps.requirements-freezer.outputs.requirements }}
72 changes: 72 additions & 0 deletions .github/workflows/publish_to_testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build

on:
release:
types: [published]

jobs:
build_wheels:
permissions:
contents: write

name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]

steps:
- name: Save workspaces path
id: workspace
run: echo "path=${GITHUB_WORKSPACE}" >> $GITHUB_OUTPUT

- name: Checkout Scilpy
uses: actions/checkout@v4
with:
repository: scilus/scilpy
ref: ${{ github.ref_name }}
path: ${{ steps.workspace.outputs.path }}/scilpy

- name: Create source distribution for Scilpy
run: pipx run build --sdist --outdir ${{ steps.workspace.outputs.path }}/sdist ${{ steps.workspace.outputs.path }}/scilpy

# Once we have aarch64 vtk wheels, we can reinstate this to build scilpy wheels for aarch64
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels for Scilpy
uses: pypa/[email protected]
with:
package-dir: ${{ steps.workspace.outputs.path }}/scilpy
output-dir: ${{ steps.workspace.outputs.path }}/sdist
config-file: ${{ steps.workspace.outputs.path }}/scilpy/cibuildwheel.toml
env:
CIBW_ARCHS_LINUX: auto64
CIBW_SKIP: "*-musllinux* pp* *-win* *-win32* *aarch64"

- name: Upload wheels and source to artifacts
uses: actions/upload-artifact@v3
with:
path: |
${{ steps.workspace.outputs.path }}/sdist/*.whl
${{ steps.workspace.outputs.path }}/sdist/*.tar.gz

- name: Add wheels and sdist to release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref_name }}
files: |
${{ steps.workspace.outputs.path }}/sdist/*.tar.gz
${{ steps.workspace.outputs.path }}/sdist/*.whl

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TESTPYPI_PASSWORD }}
repository-url: https://test.pypi.org/scilpy/
packages-dir: ${{ steps.workspace.outputs.path }}/sdist/
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Fetch python version from repository
id: python-selector
run: echo "python-version=$(cat .python-version)" >> $GITHUB_OUTPUT
run: echo "python-version=$(head -1 .python-version)" >> $GITHUB_OUTPUT

- name: Set up Python for Scilpy
uses: actions/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
3.10
3.10
~=3.9,<3.12
46 changes: 46 additions & 0 deletions cibuildwheel.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[tool.cibuildwheel]

# We only build native to the local machine. If desired, this can be changed
# to auto to build for all locally supported platforms. 32-bit builds on a
# 64-bit architecture can be disabled by setting this to auto64.
archs = ["native"]

# We use build (instead of steuptools or pip) to create the Scilpy package
build-frontend = "build"

# We build for all those python versions, plus extras
# (see below for skipped implementations)
# TODO: add back *311-* when we pass to h5py >=3.8
build = "*38-* *39-* *310-*"

# By default, we skip :
# - All Pypa builds, since we have C extensions (not fully supported)
# - All windows builds (spams doesn't handle them)
# - All aarch64 builds (we don't have wheels for vtk)
skip = "pp* *-win* *-win32* *aarch64"

# Here, we want to run pytest on scilpy, once mocking accelerate all of them
# For now, we only ensure the wheel has installed sucessfully
test-command = "echo 'Wheel installed successfully'"

# Dipy forgot to list packaging, we should not need this after 1.8.0
before-test = "pip install packaging"

# Install blas, lapack, freetype on x86_64
[tool.cibuildwheel.linux]
before-all = "yum -y update && yum -y install blas-devel lapack-devel freetype-devel"
before-test = "yum -y update && yum -y install openblas-devel lapack freetype && pip install packaging"

# Musl Linux uses APK instead of YUM, on x86_64
[[tool.cibuildwheel.overrides]]
select = "*-musllinux*"
before-all = "apk add --no-cache blas-dev lapack-dev freetype-dev"
before-test = "apk add --no-cache openblas-dev lapack freetype && pip install packaging"

# To reinstate once vtk has official linux aarch64 wheels available (we won't build them for them)
#[[tool.cibuildwheel.overrides]]
#select = "*aarch64"
#before-test = """
#pip install packaging
#pip config set global.extra-index-url https://gitlab.kitware.com/api/v4/projects/13/packages/pypi/simple/
#"""