Skip to content

Commit

Permalink
Added a workaround to test installed wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
oulap committed Sep 26, 2024
1 parent 02d29f7 commit a3064d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
name: Build and upload artefact
strategy:
max-parallel: 1
# max-parallel: 1
matrix:
os: [macos-latest, macos-13]
python-version: ["3.8", "3.9", "3.10", "3.11"]
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
name: Test the wheel
needs: build
strategy:
max-parallel: 1
# max-parallel: 1
matrix:
os: [macos-latest, macos-13]
python-version: ["3.8", "3.9", "3.10", "3.11"]
Expand All @@ -130,6 +130,8 @@ jobs:
echo "_PYTHON_HOST_PLATFORM=${_PYTHON_HOST_PLATFORM}" >> $GITHUB_ENV
PYTHON_VERSION_STR=$(python -c "import sys;print(f'cp{sys.version_info.major}{sys.version_info.minor}')")
echo "PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> $GITHUB_ENV
SAMSEG_TEST_PATH=${GITHUB_WORKSPACE}/samseg
echo "SAMSEG_TEST_PATH=${SAMSEG_TEST_PATH}" >> $GITHUB_ENV
- name: Detect if x64 and set build variables
if: runner.arch == 'x64'
Expand All @@ -138,6 +140,8 @@ jobs:
echo "_PYTHON_HOST_PLATFORM=${_PYTHON_HOST_PLATFORM}" >> $GITHUB_ENV
PYTHON_VERSION_STR=$(python -c "import sys;print(f'cp{sys.version_info.major}{sys.version_info.minor}')")
echo "PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> $GITHUB_ENV
SAMSEG_TEST_PATH=${GITHUB_WORKSPACE}/samseg
echo "SAMSEG_TEST_PATH=${SAMSEG_TEST_PATH}" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v4
Expand All @@ -151,7 +155,7 @@ jobs:
python -m pip install samseg*.whl
python -m pip install pytest
python -m pip install tensorflow
python -m pytest samseg
pytest --pyargs samseg.tests
publish:
name: Publish the wheel
Expand Down
11 changes: 11 additions & 0 deletions samseg/tests/test_samseg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
from ..Samseg import initVisualizer, Samseg
from ..io import kvlReadSharedGMMParameters

# This is a hack to test an installed wheel
# Because the test data is not in the wheel
# the tests would fail. If you export the
# SAMSEG_TEST_PATH variable to point to
# the source code directory, the test data
# is picked up from there instead.
try:
SAMSEGDIR = os.environ['SAMSEG_TEST_PATH']
except KeyError:
print("No environment variable set, using standard path.")

@pytest.fixture(scope='module')
def testernie_nii():
fn = os.path.join(
Expand Down

0 comments on commit a3064d3

Please sign in to comment.