Skip to content

Commit f203b9d

Browse files
authored
switch to uv and update python supported versions (#355)
switch to uv from poetry; allows more python supported versions
1 parent 61375c2 commit f203b9d

File tree

11 files changed

+2537
-1854
lines changed

11 files changed

+2537
-1854
lines changed

.github/workflows/phantoms.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
os: [ubuntu-latest]
31-
python: ["3.10"]
31+
python: ["3.12"]
3232
fail-fast: false
3333

3434
steps:
@@ -87,16 +87,19 @@ jobs:
8787
cache-dependency-path: |
8888
pypet2bids/pyproject.toml
8989
90+
- name: Install UV
91+
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.cargo/bin" >> $GITHUB_PATH
92+
9093
- name: Install Python Dependencies
9194
run: |
9295
cd pypet2bids
93-
pip install .
96+
pip install -e .[dev]
9497
95-
- name: Install Poetry Build Package
98+
- name: Install UV Build Package
9699
run: |
97-
make installpoetry
100+
make installuv
98101
make buildpackage
99-
make installpackage
102+
cd pypet2bids && uv pip install dist/pypet2bids-*.whl --system
100103
dcm2niix4pet -h
101104
102105
- name: Set Up Node

.github/workflows/python.yaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
matrix:
3232
os: [macOS-latest, ubuntu-latest]
33-
python: ['3.9', '3.10']
33+
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
3434

3535
steps:
3636
- name: Checkout Repo
@@ -47,14 +47,16 @@ jobs:
4747
uses: actions/setup-python@v4
4848
with:
4949
python-version: ${{ matrix.python }}
50+
cache: 'pip'
51+
cache-dependency-path: 'pypet2bids/pyproject.toml'
52+
53+
- name: Install UV
54+
run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.cargo/bin" >> $GITHUB_PATH
5055

5156
- name: Install dependencies
52-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
5357
run: |
5458
cd pypet2bids
55-
python -m pip install --upgrade pip
56-
pip install poetry==1.6.1
57-
poetry install --with dev
59+
pip install -e .[dev]
5860
5961
- name: Collect ECAT and other phantoms
6062
if: steps.cache-phantoms.outputs.cache-hit != 'true'
@@ -73,12 +75,12 @@ jobs:
7375
- name: Test CLI --help
7476
run: |
7577
cd pypet2bids/
76-
poetry run python3 -m pypet2bids.ecat_cli --help
78+
python3 -m pypet2bids.ecat_cli --help
7779
7880
- name: Test CLI Ecat Dump
7981
run: |
8082
cd pypet2bids/
81-
poetry run python3 -m pypet2bids.ecat_cli ${{ env.REAL_ECAT_TEST_PATH }} --dump
83+
python3 -m pypet2bids.ecat_cli ${{ env.REAL_ECAT_TEST_PATH }} --dump
8284
8385
# the larger real data file uses too much ram for the github runner, we use the small file for
8486
# heavy io operations instead
@@ -87,9 +89,9 @@ jobs:
8789
gzip -d ${{ env.SMALLER_ECAT_PATH }}
8890
8991
- name: Test ecatread
90-
run: "cd pypet2bids/ && poetry run python3 -m tests.test_ecatread"
92+
run: "cd pypet2bids/ && python3 -m tests.test_ecatread"
9193

9294
- name: Run All Other Python Tests w/ Pytest
9395
run: |
9496
cd pypet2bids
95-
poetry run pytest -k 'not write_pixel_data' -k 'not test_convert_pmod_to_blood' tests/
97+
python -m pytest -k 'not write_pixel_data' -k 'not test_convert_pmod_to_blood' tests/

Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ help:
2020
%: Makefile
2121
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2222

23-
# add a dependency, this is an alias for poetry add that also updates the requirements.txt file
23+
# add a dependency, this is an alias for uv add that also updates the pyproject.toml file
2424
add:
2525
@scripts/add_python_dependency $(ARGUMENTS)
2626

27-
# copies metadata to path included in pypet2bids project to enable packaging of those files w/ poetry
27+
# builds package using standard Python packaging tools
2828
buildpackage:
2929
@cp pypet2bids/pyproject.toml pypet2bids/pypet2bids/pyproject.toml
3030
@rm -rf pypet2bids/dist
31-
@cd pypet2bids && poetry lock && poetry build
31+
@cd pypet2bids && uv build
3232

3333
publish:
34-
@cd pypet2bids && poetry publish
34+
@cd pypet2bids && uv publish
3535

36-
installpoetry:
37-
@cd scripts && ./installpoetry
36+
installuv:
37+
@cd scripts && ./installuv
3838

3939
# installs latest package
4040
installpackage:
@@ -43,14 +43,18 @@ installpackage:
4343
testphantoms:
4444
@scripts/testphantoms
4545

46+
# test package across all supported Python versions
47+
test-all-python-versions:
48+
@scripts/test_all_python_versions
49+
4650
html:
4751
@cd docs && make html
4852

4953
installdependencies:
5054
@cd pypet2bids; \
5155
python -m pip install --upgrade pip; \
52-
pip install poetry; \
53-
poetry install --with dev
56+
pip install uv; \
57+
uv sync --dev
5458

5559
collectphantoms:
5660
ifeq (, $(wildcard ./PHANTOMS.zip))
@@ -64,20 +68,20 @@ decompressphantoms:
6468

6569
testecatcli:
6670
@cd pypet2bids; \
67-
poetry run python -m pypet2bids.ecat_cli --help; \
68-
poetry run python -m pypet2bids.ecat_cli ../OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v --dump
71+
uv run python -m pypet2bids.ecat_cli --help; \
72+
uv run python -m pypet2bids.ecat_cli ../OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v --dump
6973

7074
testecatread:
7175
@cd pypet2bids; \
7276
export TEST_ECAT_PATH="../OpenNeuroPET-Phantoms/sourcedata/SiemensHRRT-JHU/Hoffman.v"; \
7377
export READ_ECAT_SAVE_AS_MATLAB="$$PWD/tests/ECAT7_multiframe.mat"; \
7478
export NIBABEL_READ_ECAT_SAVE_AS_MATLAB="$$PWD/tests/ECAT7_multiframe.nibabel.mat"; \
75-
poetry run python3 -m tests.test_ecatread
79+
uv run python3 -m tests.test_ecatread
7680

7781
testotherpython:
7882
cd pypet2bids; \
7983
export TEST_DICOM_IMAGE_FOLDER="../OpenNeuroPET-Phantoms/sourcedata/SiemensBiographPETMR-NIMH/AC_TOF"; \
80-
poetry run pytest --ignore=tests/test_write_ecat.py tests/ -vvv
84+
uv run pytest --ignore=tests/test_write_ecat.py tests/ -vvv
8185

8286
pythongithubworkflow: installdependencies collectphantoms decompressphantoms testecatread testecatcli testotherpython
8387
@echo finished running python tests

0 commit comments

Comments
 (0)