diff --git a/.github/workflows/freeze_requirements.yml b/.github/workflows/freeze_requirements.yml index d63a55f11..68450e29e 100644 --- a/.github/workflows/freeze_requirements.yml +++ b/.github/workflows/freeze_requirements.yml @@ -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/setup-python@v5.0.0 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 }} diff --git a/.github/workflows/publish_to_testpypi.yml b/.github/workflows/publish_to_testpypi.yml new file mode 100644 index 000000000..e00a8c5c5 --- /dev/null +++ b/.github/workflows/publish_to_testpypi.yml @@ -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/cibuildwheel@v2.16.2 + 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/ \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e714f6c4..14b49f075 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/setup-python@v5.0.0 diff --git a/.python-version b/.python-version index 7c7a975f4..c48263aa2 100644 --- a/.python-version +++ b/.python-version @@ -1 +1,2 @@ -3.10 \ No newline at end of file +3.10 +~=3.9,<3.12 \ No newline at end of file diff --git a/cibuildwheel.toml b/cibuildwheel.toml new file mode 100644 index 000000000..7a6db7865 --- /dev/null +++ b/cibuildwheel.toml @@ -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/ +#""" \ No newline at end of file