Skip to content

Use nionswift PyPI URL. #81

Use nionswift PyPI URL.

Use nionswift PyPI URL. #81

Workflow file for this run

name: Build
on:
push:
branches: [ master ]
tags: '*'
pull_request:
branches: [ master ]
env:
tool-id: nionswift-tool
tool-package: nionswift
tool-exe: nionswift --app
jobs:
build_linux:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
python-version: ["3.9", "3.10", "3.11", "3.12"]
qt-version: ["6.6.0"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
- name: Build
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install install wheel
python -m pip install install packaging
python -m pip install install "numpy>=1.26,<1.27"
pushd launcher
PYTHON=`python -c "import sys; print(sys.executable, end='')"`
cmake CMakeLists.txt -DPython3_EXECUTABLE="$PYTHON"
cmake --build . --config Release
mkdir -p linux
mv build linux/x64
popd
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6Core.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6DBus.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6Gui.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6OpenGL.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6Widgets.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libQt6XcbQpa.so.6 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libicui18n.so.56 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libicudata.so.56 launcher/linux/x64
cp ../Qt/${{ matrix.qt-version }}/gcc_64/lib/libicuuc.so.56 launcher/linux/x64
mkdir -p launcher/linux/x64/plugins/platforms
mkdir -p launcher/linux/x64/plugins/imageformats
cp ../Qt/${{ matrix.qt-version }}/gcc_64/plugins/platforms/libqxcb.so launcher/linux/x64/plugins/platforms
cp ../Qt/${{ matrix.qt-version }}/gcc_64/plugins/imageformats/libq* launcher/linux/x64/plugins/imageformats
rm launcher/linux/x64/plugins/imageformats/libqsvg.so
chrpath -r "\$ORIGIN" launcher/linux/x64/libicu*.so.56
chrpath -r "\$ORIGIN/../.." launcher/linux/x64/plugins/platforms/libqxcb.so
chrpath -r "\$ORIGIN/../.." launcher/linux/x64/plugins/imageformats/*.so
printf "[Paths]\nPrefix=.\nPlugins=plugins\n" > launcher/linux/x64/qt.conf
python setup.py bdist_wheel
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.11
- name: Build Conda Package
if: matrix.python-version != '3.12'
shell: bash -l {0}
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
conda install -q conda-build -y
conda build -q --python ${{ matrix.python-version }} ./.github/workflows/recipe
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.tool-id }}-linux-whl-${{ matrix.python-version }}
path: dist/*.whl
- name: Upload Conda Package
uses: actions/upload-artifact@v3
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-linux-conda-${{ matrix.python-version }}
path: /usr/share/miniconda/envs/test/conda-bld/linux-64/*.tar.bz2
build_macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-11.0]
python-version: ["3.9", "3.10", "3.11", "3.12"]
qt-version: ["6.6.0"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
host: 'mac'
target: 'desktop'
- name: Build
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install install packaging
python -m pip install install "numpy>=1.26,<1.27"
pushd launcher
PYTHON=`python -c "import sys; print(sys.executable, end='')"`
cmake CMakeLists.txt -DPython3_EXECUTABLE="$PYTHON"
cmake --build . --config Release
mkdir -p build/Release
mv build/*.app build/Release
popd
python setup.py bdist_wheel
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.11
- name: Build Conda Package
if: matrix.python-version != '3.12'
shell: bash -l {0}
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
conda install -q conda-build -y
conda build -q --python ${{ matrix.python-version }} ./.github/workflows/recipe
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.tool-id }}-macos-whl-${{ matrix.python-version }}
path: dist/*.whl
- name: Upload Conda Package
uses: actions/upload-artifact@v3
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-macos-conda-${{ matrix.python-version }}
path: /usr/local/miniconda/envs/test/conda-bld/osx-64/*.tar.bz2
build_win:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
qt-version: ["6.6.0"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
shell: pwsh
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
- name: Build
shell: pwsh
run: |
python -m pip install --upgrade pip
pip install packaging
pip install "numpy>=1.26,<1.27"
pushd launcher
$PYTHON_EXEC = python -c "import sys; print(sys.executable, end='')"
cmake CMakeLists.txt -DPython3_EXECUTABLE="$PYTHON_EXEC"
cmake --build . --config Release
Get-ChildItem -Include *.pdb -Recurse | foreach { $_.Delete() }
Get-ChildItem build\Release\imageformats -Include *d.dll -Recurse | foreach { $_.Delete() }
Rename-Item -Path build\Release\NionSwiftLauncher.exe -NewName NionSwift.exe
Remove-Item -Recurse -Force x64\*
Move-Item -Path build\Release -Destination x64
popd
python setup.py bdist_wheel
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.11
- name: Build Conda Package
if: matrix.python-version != '3.12'
shell: pwsh
run: |
python -c "import sys; print(sys.version)"
python -c "import sys; print(sys.executable)"
conda install -q conda-build -y
conda build -q --python ${{ matrix.python-version }} ./.github/workflows/recipe
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: ${{ env.tool-id }}-win-whl-${{ matrix.python-version }}
path: dist\*.whl
- name: Upload Conda Package
uses: actions/upload-artifact@v3
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-win-conda-${{ matrix.python-version }}
path: C:\Miniconda\envs\test\conda-bld\win-64\*.tar.bz2
test_linux:
needs: build_linux
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Download Wheel
uses: actions/download-artifact@v3
id: download_wheel
with:
name: ${{ env.tool-id }}-linux-whl-${{ matrix.python-version }}
path: downloads
- name: Download Conda
uses: actions/download-artifact@v3
id: download_conda
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-linux-conda-${{ matrix.python-version }}
path: conda_downloads
- name: Set up Python ${{ matrix.python-version }} with official build
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Virtual screen
shell: bash
run: |
sudo apt-get install xvfb -y
# libopengl0: see https://bugreports.qt.io/browse/QTBUG-89754
sudo apt-get install libopengl0 -y
# see https://doc.qt.io/qt-6/linux-requirements.html
sudo apt-get install libegl1 libfontconfig1 libfreetype6 libxcb1 libxcb-glx0 libxcb-keysyms1 libxcb-image0 libxcb-shm0 libxcb-icccm4 libxcb-xfixes0 libxcb-shape0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 libxcb-sync1 libxcb-cursor0 -y
# sudo apt-get install libx11 libx11-xcb libxext libxfixes libxi libxrender libxcb-sync libxcb-util libxkbcommon
- name: Test system Python installed with official build with virtual environment
shell: bash
run: |
sudo apt update
python -m pip install --upgrade pip
SYSTEM_PYTHON_EXE=python
$SYSTEM_PYTHON_EXE -m venv test_venv
source test_venv/bin/activate
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install ${{ env.tool-package }}
python -m pip install ${{steps.download_wheel.outputs.download-path}}/*.whl
python -m pip install numpy scipy h5py
pushd nionui_app_test
python -m pip install .
popd
echo "Running test... ${{ env.tool-exe }}"
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack | grep ACK
deactivate
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Test Conda
shell: bash -l {0}
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
conda update --all -q -y
conda install -q numpy scipy h5py imageio setuptools pip -y
conda install -q -y -c nion ${{ env.tool-package }}
conda install -q -y ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack | grep ACK
- name: Test Conda Forge
shell: bash -l {0}
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
conda create -q -n test-env -c conda-forge python=${{ matrix.python-version }} numpy scipy h5py imageio setuptools -y
conda activate test-env
conda install -q -y -c nion -c conda-forge ${{ env.tool-package }}
conda install -q -y -c conda-forge ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack
xvfb-run ${{ env.tool-exe }} nionui_app.test_ack | grep ACK
conda deactivate
- name: Build/publish anaconda package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'ubuntu-20.04' && matrix.python-version != '3.12'
shell: bash -l {0}
run: |
conda info
conda install anaconda-client -y
anaconda --token ${{ secrets.anaconda_token }} upload --user nion --skip-existing ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
test_macos:
needs: build_macos
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-11.0]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Download Wheel
uses: actions/download-artifact@v3
id: download_wheel
with:
name: ${{ env.tool-id }}-macos-whl-${{ matrix.python-version }}
path: downloads
- name: Download Conda
uses: actions/download-artifact@v3
id: download_conda
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-macos-conda-${{ matrix.python-version }}
path: conda_downloads
- name: Test system Python installed with brew with virtual environment
shell: bash
run: |
brew update
brew install python@${{ matrix.python-version }} || true
SYSTEM_PYTHON_EXE=/usr/local/bin/python${{ matrix.python-version }}
$SYSTEM_PYTHON_EXE -m venv test_venv
source test_venv/bin/activate
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install ${{ env.tool-package }}
python -m pip install ${{steps.download_wheel.outputs.download-path}}/*.whl
python --version
python -m pip install numpy scipy h5py
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
- name: Set up Python ${{ matrix.python-version }} with official build
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Test system Python installed with official build with virtual environment
shell: bash
run: |
SYSTEM_PYTHON_EXE=python3
$SYSTEM_PYTHON_EXE -m venv test_venv
source test_venv/bin/activate
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install ${{ env.tool-package }}
python -m pip install ${{steps.download_wheel.outputs.download-path}}/*.whl
python --version
python -m pip install numpy scipy h5py
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
deactivate
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Test Conda
shell: bash -l {0}
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
# use nomkl until anaconda gets its act together
conda install -q nomkl numpy scipy h5py imageio setuptools -y
conda install -q -y -c nion ${{ env.tool-package }}
conda install -q -y ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
- name: Test Conda Forge
shell: bash -l {0}
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
# use nomkl until anaconda gets its act together
conda create -n test-env -c conda-forge -q python=${{ matrix.python-version }} numpy scipy h5py imageio setuptools -y
conda activate test-env
conda install -q -y -c nion -c conda-forge ${{ env.tool-package }}
conda install -q -y -c conda-forge ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
conda deactivate
- name: Build/publish anaconda package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'macos-11.0' && matrix.python-version != '3.12'
shell: bash -l {0}
run: |
conda info
conda install -q anaconda-client -y
anaconda --token ${{ secrets.anaconda_token }} upload --user nion --skip-existing ${{steps.download_conda.outputs.download-path}}/*.tar.bz2
test_win:
needs: build_win
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Download Wheel
uses: actions/download-artifact@v3
id: download_wheel
with:
name: ${{ env.tool-id }}-win-whl-${{ matrix.python-version }}
path: downloads
- name: Download Conda
uses: actions/download-artifact@v3
id: download_conda
if: matrix.python-version != '3.12'
with:
name: ${{ env.tool-id }}-win-conda-${{ matrix.python-version }}
path: conda_downloads
- name: Set up Python ${{ matrix.python-version }} with official build
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Test system Python installed with official build with virtual environment
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m venv test_venv
test_venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install ${{ env.tool-package }}
$filename = Get-ChildItem -name ${{steps.download_wheel.outputs.download-path}}\*.whl
python -m pip install ${{steps.download_wheel.outputs.download-path}}\$filename
python --version
python -m pip install numpy scipy h5py
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
deactivate
- name: Set up Miniconda ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Test Conda
shell: pwsh
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
conda update -q --all -y
conda install -q numpy scipy h5py imageio setuptools -y
conda install -q -y -c nion ${{ env.tool-package }}
$filename = Get-ChildItem -name ${{steps.download_conda.outputs.download-path}}\*.tar.bz2
conda install -q -y ${{steps.download_conda.outputs.download-path}}\$filename
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
- name: Test Conda Forge
shell: pwsh
if: matrix.python-version != '3.12'
run: |
# use conda versions instead of pypi versions. install before anything else.
conda create -n test-env -c conda-forge -q python=${{ matrix.python-version }} numpy scipy h5py imageio setuptools -y
conda activate test-env
conda install -q -y -c nion -c conda-forge ${{ env.tool-package }}
$filename = Get-ChildItem -name ${{steps.download_conda.outputs.download-path}}\*.tar.bz2
conda install -q -y -c conda-forge ${{steps.download_conda.outputs.download-path}}\$filename
pushd nionui_app_test
python -m pip install .
popd
echo "Running test..."
conda list
${{ env.tool-exe }} nionui_app.test_ack
${{ env.tool-exe }} nionui_app.test_ack | grep ACK
conda deactivate
- name: Build/publish anaconda package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && matrix.os == 'windows-2019' && matrix.python-version != '3.12'
shell: pwsh
run: |
conda info
conda install -q anaconda-client -y
$filename = Get-ChildItem -name ${{steps.download_conda.outputs.download-path}}\*.tar.bz2
Write-Output ${{steps.download_conda.outputs.download-path}}\$filename
anaconda --token ${{ secrets.anaconda_token }} upload --user nion --skip-existing ${{steps.download_conda.outputs.download-path}}\$filename
pypi-publish:
name: Upload release to PyPI
needs: [test_linux, test_macos, test_win]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
environment:
name: release
url: https://pypi.org/p/nionswift-tool
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v3
- name: Remove all the files except the ones to upload to PyPI.
shell: bash
run: |
mkdir dist
find . -name "*cp39*.whl" -exec cp {} dist \;
ls -Rl .
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
print-hash: true