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

Fix the github CI to run on 2.7 #188

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/workflows/build_flake_pytest_ubuntu2004.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@ 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
- name: Install dependencies
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
Expand Down
8 changes: 5 additions & 3 deletions ImageD11/cImageD11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ImageD11/sinograms/properties.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function


import os
import logging
Expand Down
4 changes: 3 additions & 1 deletion sandbox/sigma_3_matrices.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function


import ImageD11.grain
import ImageD11.grid_index_parallel
Expand Down Expand Up @@ -39,4 +41,4 @@ def twin_check( ind, matrices, symmetry='cubic', poserr=1000, angerr=0.5 ):
else:
e = '!'
print("%4d "%(s1), end=e)
print()
print()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions test/testdatasets/test_datasets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function

import os
import ImageD11.sinograms.dataset
Expand All @@ -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
):
Expand Down Expand Up @@ -53,4 +54,4 @@ def testcase(dataroot = '/data/id11/nanoscope/ihmi1452/id11',
sample = 'goldBall',
dset = 'r2_Z071',
scans = [ '4.1',]
)
)
Loading