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

Pyinstaller Github Actions #2197

Draft
wants to merge 36 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
629d47a
exclude test.support modules from loaded operations
MikeSullivan7 Aug 1, 2024
726adda
upgrade python, h5py, imagecodecs, scikit-image, coverage, coveralls
MikeSullivan7 Jul 18, 2024
90b4da2
Release note
MikeSullivan7 Jul 23, 2024
10e3236
change assertions in image_stack_test and strictdataset_test
MikeSullivan7 Jul 23, 2024
db6e1db
remove astra-toolbox channels from env files
MikeSullivan7 Jul 30, 2024
0c5f0de
put CONDA_OVERRIDE_CUDA env variable at job level
MikeSullivan7 Jul 31, 2024
ed01ce6
upgrade astra to 2.1.0=cuda*
MikeSullivan7 Jul 31, 2024
f3f8fbc
add cupy_backends module explicitly in PackagingWithPyInstaller
MikeSullivan7 Aug 1, 2024
3639e53
updated to Miniforge from Mambaforge
MikeSullivan7 May 8, 2024
2c904d7
use nsis to make installer
MikeSullivan7 May 8, 2024
31e7b9c
update Jimver cuda-toolkit
MikeSullivan7 May 8, 2024
aebd4a4
quick yml fix
MikeSullivan7 May 8, 2024
989524d
set CUDA_PATH to reflect local
MikeSullivan7 May 8, 2024
cfde440
quick yml fix
MikeSullivan7 May 8, 2024
61c33fa
test cupy installed
MikeSullivan7 May 8, 2024
314ad00
list installed packages
MikeSullivan7 May 8, 2024
edab260
archive spec file
MikeSullivan7 May 8, 2024
cc3de5d
archive spec file
MikeSullivan7 May 9, 2024
5cd7520
printing pyinstaller run options
MikeSullivan7 May 9, 2024
20c41ff
test
MikeSullivan7 May 9, 2024
c788622
remove CUDA toolkit install
MikeSullivan7 May 9, 2024
63e6d94
remove CUDA toolkit install
MikeSullivan7 May 9, 2024
41f7422
remove CUDA toolkit install
MikeSullivan7 May 9, 2024
3b40448
spec artifact
MikeSullivan7 May 9, 2024
defa77c
use cupy-cuda102 whl
MikeSullivan7 May 9, 2024
11b9f65
add cudatoolkit in meta.yml
MikeSullivan7 May 10, 2024
0cd1617
look at GH environment variables
MikeSullivan7 May 10, 2024
d4edaa5
add CONDA_CUPY_CUDA_PATH
MikeSullivan7 May 10, 2024
19b3b01
add CONDA_CUPY_CUDA_PATH
MikeSullivan7 May 10, 2024
031a533
add CONDA_CUPY_CUDA_PATH
MikeSullivan7 May 10, 2024
57b9e91
change env back to main
MikeSullivan7 May 10, 2024
bc751a4
install CUDA before MI env
MikeSullivan7 May 10, 2024
0caee66
add use-only-tar-bz2: true to pip & miniforge caching
MikeSullivan7 May 10, 2024
e6adb28
add CONDA_OVERRIDE_CUDA=11.8 to job env
MikeSullivan7 Jul 31, 2024
c6cfe61
change cuda path to env path
MikeSullivan7 Aug 1, 2024
e1f0e56
test
MikeSullivan7 Aug 1, 2024
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
96 changes: 96 additions & 0 deletions .github/workflows/pyinstaller_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: PyInstaller Windows Build

on:
pull_request:
branches:
- 'main'
- 'release-*'
release:

jobs:
test:
runs-on: windows-latest
env:
CONDA_OVERRIDE_CUDA: 10.2

steps:
- uses: actions/checkout@v4
with:
# Needed to get tags so that git describe works during package build
fetch-depth: "0"

- name: cuda-toolkit
uses: Jimver/[email protected]
with:
cuda: '10.2.89'

- name: Get Date
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%V")" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Miniforge and Pip packages
uses: actions/cache@v4
env:
CACHE_NUMBER: 0
with:
path: |
~/conda_pkgs_dir
~/.cache/pip
key:
${{runner.os}}-condapkg-${{env.CACHE_NUMBER}}-${{steps.get-date.outputs.date}}-${{hashFiles('environment-dev.yml','conda/meta.yaml')}}

- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: mantidimaging-dev
auto-activate-base: false
use-mamba: false

- name: Cache Miniforge environment
uses: actions/cache@v4
id: cache-miniforge-environment
env:
CACHE_NUMBER: 0
with:
path: ${{env.CONDA}}/envs/mantidimaging-dev
key:
${{runner.os}}-condaenv-${{env.CACHE_NUMBER}}-${{steps.get-date.outputs.date}}-${{hashFiles('environment-dev.yml','conda/meta.yaml')}}

- name: Mantid Imaging developer dependencies
if: steps.cache-miniforge-environment.outputs.cache-hit != 'true'
shell: bash -l {0}
run: |
conda deactivate
python ./setup.py create_dev_env

- name: List versions
shell: bash -l {0}
run: |
conda env list
python --version; conda list ; pip list

- name: PyInstaller Build
shell: bash -l {0}
env:
CUDA_PATH: ${{env.CONDA}}/envs/mantidimaging-dev
run: |
conda activate mantidimaging-dev
echo "Cuda path: $CUDA_PATH"
echo "dev env path: '${{env.CONDA}}/envs/mantidimaging-dev'"
cd packaging
python PackageWithPyInstaller.py

- name: Archive PyInstalled File
uses: actions/upload-artifact@v3
with:
name: MantidImagingSpec
path: packaging/MantidImaging.spec

- name: Archive PyInstalled File
uses: actions/upload-artifact@v3
with:
name: MantidImaging
path: packaging/dist
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ concurrency:
jobs:
test:
runs-on: windows-latest
env:
CONDA_OVERRIDE_CUDA: 11.8

steps:
- uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ source:

requirements:
build:
- python=3.10.*
- python=3.12.*
- setuptools=62.*
run:
- python=3.10.*
- python=3.12.*
- pip
- astropy=6.0.*
- scipy=1.14.*
- scikit-image=0.20.*
- scikit-image=0.22.*
- tifffile=2023.7.18
- imagecodecs=2023.1.23
- imagecodecs=2023.9.18
- numpy=1.26.*
- numexpr=2.8.*
- algotom=1.6.*
- tomopy=1.12.*
- cudatoolkit=11.8.*
- cupy=12.3.*
- astra-toolbox=2.0.0
- astra-toolbox=2.1.0=cuda*
- requests=2.27.*
- h5py=3.9.*
- hdf5=1.14.2
Expand Down
1 change: 1 addition & 0 deletions docs/release_notes/next/dev-2267-upgrade-python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#2267: Python has been upgraded to use version 3.12
5 changes: 2 additions & 3 deletions environment-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: mantidimaging-dev
channels:
- mantidimaging/label/unstable
- astra-toolbox
- conda-forge
- ccpi
- algotom
Expand All @@ -24,8 +23,8 @@ dependencies:
- pytest-xdist==3.3.*
- testfixtures==7.2.*
- gitpython==3.1.*
- coverage==6.5.*
- coveralls==3.3.*
- coverage==7.3.*
- coveralls==4.0.*
- pyfakefs==5.3.*
- parameterized==0.9.*
- pyinstaller==6.9.*
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: mantidimaging-nightly
channels:
- mantidimaging/label/unstable
- astra-toolbox
- conda-forge
- ccpi
- algotom
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/core/data/test/image_stack_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_image_eq_method(self):
self.assertRaises(ValueError, lambda a, b: a == b, data_images, 1.0)

def test_cant_change_id(self):
with self.assertRaisesRegex(Exception, "can't set attribute"):
with self.assertRaises(AttributeError):
generate_images().id = "id"

def test_default_name(self):
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/core/data/test/strictdataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_attribute_not_set_returns_none(self):
self.assertIsNone(dataset.dark_after)

def test_cant_change_dataset_id(self):
with self.assertRaisesRegex(Exception, "set attribute"):
with self.assertRaises(AttributeError):
self.strict_dataset.id = "id"

def test_set_flat_before(self):
Expand Down
3 changes: 2 additions & 1 deletion mantidimaging/core/operations/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def _find_operation_modules() -> list[BaseFilterClass]:
if not ispkg:
continue

if getattr(sys, 'frozen', False):
if getattr(sys, 'frozen', False) and "test.support" not in module_name:
# If we're running a PyInstaller executable then we need to use a full module path
# Need to prevent importing standard library test modules found by pkgutil
module_name = f'mantidimaging.core.operations.{module_name}'

# near impossible to type check as find can be a pyinstaller specific type that we can't normally import
Expand Down
11 changes: 7 additions & 4 deletions packaging/PackageWithPyInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def create_run_options():
run_options = [
'../mantidimaging/__main__.py', '--name=MantidImaging', '--additional-hooks-dir=hooks', '--onedir',
'../mantidimaging/__main__.py', '--name=MantidImaging', '--additional-hooks-dir=hooks',
'--icon=../images/mantid_imaging_unstable_64px.ico'
]

Expand All @@ -38,7 +38,10 @@ def add_hidden_imports(run_options):
path_to_operations = Path(__file__).parent.parent.joinpath('mantidimaging/core/operations')
# COMPAT python 3.10 won't accept a Path: github.com/python/cpython/issues/88227
for _, ops_module, _ in pkgutil.walk_packages([str(path_to_operations)]):
imports.append(f'mantidimaging.core.operations.{ops_module}')
# stop non-existent Hidden Imports
# https://github.com/mantidproject/mantidimaging/issues/2298
if "test.support" not in ops_module:
imports.append(f'mantidimaging.core.operations.{ops_module}')

run_options.extend([f'--hidden-import={name}' for name in imports])

Expand All @@ -52,7 +55,7 @@ def add_hidden_imports(run_options):


def add_missing_submodules(run_options):
imports = ['cupy']
imports = ['cupy', 'cupy_backends']
run_options.extend([f'--collect-submodules={name}' for name in imports])


Expand All @@ -67,6 +70,7 @@ def add_data_files(run_options):
('../mantidimaging/gui/windows/wizard/*.yml', 'mantidimaging/gui/windows/wizard/')]

data_files += collect_data_files("cupy")
data_files += collect_data_files("cupy_backends")
run_options.extend([f'--add-data={src}{os.pathsep}{dest}' for src, dest in data_files])


Expand Down Expand Up @@ -97,5 +101,4 @@ def add_exclude_modules(run_options):
# The default limit is 1000, meaning a recursion error would occur at around 115 nested imports.
# A limit of 5000 means the error should occur at about 660 nested imports.
sys.setrecursionlimit(sys.getrecursionlimit() * 5)

PyInstaller.__main__.run(create_run_options())
Loading