From 24850efd1b33f94f3b88e66046b6c55bcbd0bf0e Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 17:50:47 +0100 Subject: [PATCH 1/7] Update build_flake_pytest_ubuntu2004.yml --- .github/workflows/build_flake_pytest_ubuntu2004.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_flake_pytest_ubuntu2004.yml b/.github/workflows/build_flake_pytest_ubuntu2004.yml index 6e0f5a6c..0b1a8a64 100644 --- a/.github/workflows/build_flake_pytest_ubuntu2004.yml +++ b/.github/workflows/build_flake_pytest_ubuntu2004.yml @@ -28,8 +28,9 @@ jobs: if: matrix.python == '2.7' run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends python2 python3-virtualenv + sudo apt-get install -y --no-install-recommends python2 python2-dev python3-virtualenv virtualenv -p python2 ${HOME}/cp27 + source ${HOME}/cp27/bin/activate ${HOME}/cp27/bin/python -m pip install -U pip ${HOME}/cp27/bin/python -m pip install -U setuptools wheel echo "${HOME}/cp27/bin" >> $GITHUB_PATH @@ -37,12 +38,12 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi python -m pip install . - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude="*depreciated*" + python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude="*depreciated*" # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest From 5f69de4660bba320a41177713a0ceb844bbe1d38 Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 17:53:28 +0100 Subject: [PATCH 2/7] Update build_flake_pytest_ubuntu2004.yml --- .github/workflows/build_flake_pytest_ubuntu2004.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_flake_pytest_ubuntu2004.yml b/.github/workflows/build_flake_pytest_ubuntu2004.yml index 0b1a8a64..b762e56c 100644 --- a/.github/workflows/build_flake_pytest_ubuntu2004.yml +++ b/.github/workflows/build_flake_pytest_ubuntu2004.yml @@ -25,7 +25,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install Ubuntu python 2.7 - if: matrix.python == '2.7' + if: matrix.python-version == '2.7' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends python2 python2-dev python3-virtualenv From 63529f5cc8223ffb43e2ceaebb497cd8249680fd Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 17:58:11 +0100 Subject: [PATCH 3/7] Update setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 7949b1a3..369ae6ec 100644 --- a/setup.py +++ b/setup.py @@ -157,6 +157,7 @@ def build_extension(self, ext): 'pyyaml', "pytest", # for the CI 'numba==0.46.0 ; python_version < "3" ', # for some test cases + 'llvmlite==0.30.0 ; python_version < "3" ', # for some test cases 'numba ; python_version > "3" ', # for some test cases "bslz4_to_sparse", "fast_histogram", From 19a78deeb81215b386bf82199f7ee1d30b93249d Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 18:00:29 +0100 Subject: [PATCH 4/7] Update sigma_3_matrices.py (py2, print) --- sandbox/sigma_3_matrices.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sandbox/sigma_3_matrices.py b/sandbox/sigma_3_matrices.py index ca7467c0..d86fd4fc 100644 --- a/sandbox/sigma_3_matrices.py +++ b/sandbox/sigma_3_matrices.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import ImageD11.grain import ImageD11.grid_index_parallel @@ -39,4 +41,4 @@ def twin_check( ind, matrices, symmetry='cubic', poserr=1000, angerr=0.5 ): else: e = '!' print("%4d "%(s1), end=e) - print() \ No newline at end of file + print() From e29dfe88804ab99238235bf01ef48c774d03c021 Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 18:01:41 +0100 Subject: [PATCH 5/7] Update properties.py (py2: print) --- ImageD11/sinograms/properties.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ImageD11/sinograms/properties.py b/ImageD11/sinograms/properties.py index fd4f2a1c..5f217eda 100755 --- a/ImageD11/sinograms/properties.py +++ b/ImageD11/sinograms/properties.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import os import logging From e7f6ec53f77c7b5910ec279ca7851fe6fcb94223 Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 18:02:59 +0100 Subject: [PATCH 6/7] Update test_datasets.py (py2: fstring/print) --- test/testdatasets/test_datasets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/testdatasets/test_datasets.py b/test/testdatasets/test_datasets.py index 206fbcbf..6dfeaab1 100644 --- a/test/testdatasets/test_datasets.py +++ b/test/testdatasets/test_datasets.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import ImageD11.sinograms.dataset @@ -15,7 +16,7 @@ def testcase(dataroot = '/data/id11/nanoscope/ihmi1452/id11', sample = 'WAucross', dset = 'H0_', - destination = f'/tmp/case.h5', + destination = '/tmp/case.h5', analysisroot = 'should_not_exist', scans= None ): @@ -53,4 +54,4 @@ def testcase(dataroot = '/data/id11/nanoscope/ihmi1452/id11', sample = 'goldBall', dset = 'r2_Z071', scans = [ '4.1',] -) \ No newline at end of file +) From 6ddcb68d0a1209ad2f421eef9b5335cf23d13056 Mon Sep 17 00:00:00 2001 From: Jon Wright Date: Wed, 29 Nov 2023 18:11:29 +0100 Subject: [PATCH 7/7] Update cImageD11.py : use OMP_NUM_THREADS and py27 --- ImageD11/cImageD11.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ImageD11/cImageD11.py b/ImageD11/cImageD11.py index 8a7241cb..75abb09c 100644 --- a/ImageD11/cImageD11.py +++ b/ImageD11/cImageD11.py @@ -39,13 +39,15 @@ def check_multiprocessing(): if hasattr(multiprocessing,"parent_process"): parent = multiprocessing.parent_process() # only for python 3.8 and up - if parent is not None: + if (parent is not None) and ('OMP_NUM_THREADS' not in os.environ): cimaged11_omp_set_num_threads( 1 ) # people wanting Nprocs * Mthreads need to reset after import - # OMP_NUM_THREADS is not going to work for them - # how are we going to remember this in the future?? + # or use OMP_NUM_THREADS as usual # # now check for the fork issue + if not hasattr(multiprocessing, 'get_start_method'): + # You are on python2.7. Give up. + return if ((multiprocessing.get_start_method(allow_none=False) == 'fork') and # we have the problem (multiprocessing.get_start_method(allow_none=True) is None) and # by accident ('forkserver' in multiprocessing.get_all_start_methods())): # so fix it