diff --git a/.github/workflows/build_flake_pytest_ubuntu2004.yml b/.github/workflows/build_flake_pytest_ubuntu2004.yml index 6e0f5a6c..b762e56c 100644 --- a/.github/workflows/build_flake_pytest_ubuntu2004.yml +++ b/.github/workflows/build_flake_pytest_ubuntu2004.yml @@ -25,11 +25,12 @@ 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 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 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 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 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() 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", 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 +)