Skip to content

Commit

Permalink
Update GitHub Actions to deploy macOS aarch64.
Browse files Browse the repository at this point in the history
  • Loading branch information
crisluengo committed Mar 17, 2024
1 parent 3650cdb commit 3f19474
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 165 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
n_cores: 2
n_cores: 4
- os: macos-latest
n_cores: 3
- os: windows-latest
n_cores: 2
n_cores: 4
dip_cmake_opts: -A x64 -DDIP_ENABLE_UNICODE=Off -DGLFW_INCLUDE_DIR="glfw-3.3.5.bin.WIN64/include" -DGLFW_LIBRARY="glfw-3.3.5.bin.WIN64/lib-vc2019/glfw3.lib" -DDIP_FIND_FREEGLUT=Off
# Windows build must be 64-bit. We're also disabling Unicode because otherwise some tests fail.
fail-fast: true
Expand Down
42 changes: 34 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install
# Install libraries and Python packages we need
run: python3 -m pip install twine

- name: Deploy
run: bash tools/travis/deploy_linux.sh
run: bash tools/build/deploy_linux.sh
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

deploy_macos:
deploy_macos_x86_64:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install
# Install libraries and Python packages we need
Expand All @@ -31,18 +31,44 @@ jobs:
# export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# brew update
run: |
brew install libomp glfw
brew install libomp glfw wget
- name: Deploy
run: bash tools/travis/deploy_macos.sh
run: bash tools/build/deploy_macos.sh
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
HOMEBREW_DIR: /usr/local
BUILD_THREADS: 3
MACOSX_DEPLOYMENT_TARGET: 12.0

deploy_macos_aarch64:
runs-on: macos-14

steps:
- uses: actions/checkout@v3

- name: Install
# Install libraries and Python packages we need
# Note that twine and delocate and so on are installed by deploy_macos.sh
# If Homebrew doesn't know the newest Python version or something like that, add:
# export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# brew update
run: |
brew install libomp glfw wget
- name: Deploy
run: bash tools/build/deploy_macos.sh
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
HOMEBREW_DIR: /opt/homebrew
BUILD_THREADS: 3
MACOSX_DEPLOYMENT_TARGET: 12.0

deploy_windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install
# Install libraries and Python packages we need
Expand All @@ -51,6 +77,6 @@ jobs:
python -m pip install wheel build twine wget
- name: Deploy
run: tools/travis/deploy_windows.bat
run: tools/build/deploy_windows.bat
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target*/
build*/
!tools/build/
.idea/
.vs/
.vscode/
Expand All @@ -8,4 +9,4 @@ dipimage/private/*.jar
*~
*.orig
examples/python/.ipynb_checkpoints
*.code-workspace
*.code-workspace
17 changes: 0 additions & 17 deletions doc/release_procedure/DIPlib_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ page there is a list of workflows. Select "deploy". On the right of the page the
Press the button, and select the newly defined tag, then run the workflow. This will build the project (except
DIPimage) for the supported platforms and upload the new Python packages to PyPI.

### 5b. Manually build the macOS aarch64 Python packages

The GitHub deploy action currently does not generate macOS aarch64 packages. These must be build on an aarch64 Mac.

Run the script `tools/travis/deploy_macos_m1.sh` from the root of the repository. For example:
```shell
cd <repository root>
export PYPI_TOKEN=<token generated on PyPI>
source tools/travis/deploy_macos_m1.sh
```

First one needs to generate a new token on PyPI for the `diplib` project.
For security, delete the token after the packages have been uploaded.

The script will create a subdirectory `build`. Please make sure it doesn't yet exist, so that everything is
built from scratch.

### 6. Build the documentation

Build the documentation locally. This requires a machine with LaTeX, MATLAB and a bunch of other tools.
Expand Down
2 changes: 1 addition & 1 deletion pydip/setup/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ setup_kwargs = dict(
ext_modules=[Extension('diplib.PyDIP_bin', [])],
package_data={'diplib': libraries},
entry_points={'gui_scripts': ['dipview = diplib.dipview:main']},
python_requires='>=3.6'
python_requires='>=3.8'
)

name = os.path.join("$<TARGET_FILE_DIR:PyDIP_bin>", "staging", "dist", wheel_name(**setup_kwargs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Run this on a Linux machine with docker, from the diplib directory
# set $PYPI_TOKEN to the PyPI token for the diplib project

docker run -v `pwd`:/io quay.io/pypa/manylinux2014_x86_64 /bin/bash /io/tools/travis/manylinux.sh
docker run -v `pwd`:/io quay.io/pypa/manylinux2014_x86_64 /bin/bash /io/tools/build/manylinux.sh

python3 -m twine upload -u __token__ -p $PYPI_TOKEN wheelhouse/*.whl
31 changes: 31 additions & 0 deletions tools/build/deploy_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Run this on MacOS with Xcode from the diplib directory
# set $PYPI_TOKEN to the PyPI token for the diplib project

# Setup
export PYTHON_VERSIONS=(3.8 3.9 3.10 3.11 3.12)
brew install python@3.8
brew install python@3.9
brew install python@3.10
brew install python@3.11
brew install python@3.12
# The install above might have changed the default version of `python3`, so we need to reinstall packages:
python3 -m pip install -U twine delocate

mkdir build
cd build
wget -nv https://downloads.openmicroscopy.org/bio-formats/7.0.0/artifacts/bioformats_package.jar

# Basic configuration
cmake .. -DDIP_PYDIP_WHEEL_INCLUDE_LIBS=On -DBIOFORMATS_JAR=`pwd`/bioformats_package.jar -DDIP_BUILD_DIPIMAGE=Off

# Build all wheels
for v in ${PYTHON_VERSIONS[@]}; do
export PYTHON=/usr/local/opt/python@Sv/bin/python$v
$PYTHON -m pip install build
cmake .. -DPYBIND11_PYTHON_VERSION=$v -DPYTHON_EXECUTABLE=$PYTHON
make -j $BUILD_THREADS bdist_wheel
delocate-wheel -e libjvm -w wheelhouse/ -v pydip/staging/dist/*.whl
done;

# Upload to pypi.org
python3 -m twine upload -u __token__ -p $PYPI_TOKEN wheelhouse/*.whl
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/travis/manylinux.sh → tools/build/manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
yum -y install wget freeglut-devel java-1.8.0-openjdk-devel.x86_64
/opt/python/cp39-cp39/bin/python -m pip install cmake auditwheel
CMAKE=/opt/python/cp39-cp39/lib/python3.9/site-packages/cmake/data/bin/cmake
BUILD_THREADS=2
BUILD_THREADS=4
PYTHON_VERSIONS=(3.8 3.9 3.10 3.11 3.12)
EXCLUDES=(libjvm.so libOpenGL.so.0 libGLX.so.0 libGLdispatch.so.0)

Expand Down
64 changes: 0 additions & 64 deletions tools/travis/deploy_macos.sh

This file was deleted.

70 changes: 0 additions & 70 deletions tools/travis/deploy_macos_m1.sh

This file was deleted.

0 comments on commit 3f19474

Please sign in to comment.