Skip to content

Commit 91b288c

Browse files
authored
Merge pull request #122 from loli/Release_0.5.0
Release 0.5.0
2 parents 54bb190 + 507f67e commit 91b288c

File tree

553 files changed

+11684
-34141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

553 files changed

+11684
-34141
lines changed

.bettercodehub.yml

-9
This file was deleted.

.github/workflows/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# MedPy's CI/CD workflows
2+
3+
## Build & release
4+
Upon creating a release or a pre-release on GitHub, the package is *build* and *published* to [test.pypi.org](https://test.pypi.org).
5+
6+
Install from test PyPi with `python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple medpy==x.y.z.`. This ensures that the dependencies are installed from the proper PyPI.
7+
8+
After making sure that the package published there is installable and passes all tests, the final *publish* to [pypi.org](https://pypi.org) can be triggered manually from the GitHub UI.
9+
10+
Note that publishing only works for releases created directly from the `master` branch. Releasees published from other branches should always be pre-releases and never published to [pypi.org](https://pypi.org), but only [test.pypi.org](https://test.pypi.org).
11+
12+
## pre-commit.yml
13+
Makes sure that all PRs and all releases adhere to the pre-commit rules.
14+
15+
## run-test*.yml
16+
Makes sure that all PRs and all releases pass the tests.
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Build package & publish a release to PyPI (test)
2+
# Given a tag, downloads the associated code, builds the package, and uploads the source tarball as artifact
3+
# This version releases to https://test.pypi.org/ for testing purposes
4+
# Triggers on: all published releases (incl pre-releases)
5+
6+
name: Build package & release to PyPI (test)
7+
8+
on:
9+
release:
10+
types: [published]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.x
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build
28+
- name: Build a source tarball
29+
run: python -m build --sdist
30+
- name: Store the distribution packages
31+
uses: actions/[email protected]
32+
with:
33+
name: python-package-distributions-${{ github.ref_name }}
34+
path: dist/
35+
36+
publish-test:
37+
needs:
38+
- build
39+
runs-on: ubuntu-latest
40+
environment:
41+
name: pypi-publish-test
42+
url: https://test.pypi.org/p/medpy
43+
permissions:
44+
id-token: write # IMPORTANT: mandatory for trusted publishing
45+
steps:
46+
- name: Download dists
47+
uses: actions/[email protected] # make sure that same major version as actions/upload-artifact
48+
with:
49+
name: python-package-distributions-${{ github.ref_name }}
50+
path: dist/
51+
- name: Publish package
52+
uses: pypa/[email protected]
53+
with:
54+
repository-url: https://test.pypi.org/legacy/ # test publish platform

.github/workflows/pre-commit.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Runs the pre-commit hooks to make sure that all changes are properly formatted and such
2+
# Triggers on: All PRs that are mergable, but not for draft PRs
3+
# Triggers on: all published releases (incl draft releases)
4+
5+
name: Pre-commit hooks
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened, ready_for_review]
10+
release:
11+
types: [published]
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
pre-commit:
18+
if: github.event.pull_request.draft == false
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: 3.x
28+
- uses: pre-commit/[email protected]
29+
- uses: pre-commit-ci/[email protected]
30+
if: always()

.github/workflows/publish.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Publish a release to PyPI
2+
# Requires build package workflow to run first
3+
# This version releases to https://pypi.org/, only trigger if the release has been thorough tested
4+
5+
name: Build package & release to PyPI
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: "Select release to publish"
12+
required: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
ref: ${{ inputs.tag }}
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: 3.x
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install build
32+
- name: Build a source tarball
33+
run: python -m build --sdist
34+
- name: Store the distribution packages
35+
uses: actions/[email protected]
36+
with:
37+
name: python-package-distributions-${{ inputs.tag }}
38+
path: dist/
39+
40+
publish:
41+
needs:
42+
- build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: pypi-publish
46+
url: https://pypi.org/p/medpy
47+
permissions:
48+
id-token: write # IMPORTANT: mandatory for trusted publishing
49+
steps:
50+
- name: Download dists
51+
uses: actions/[email protected] # make sure that same major version as actions/upload-artifact
52+
with:
53+
name: python-package-distributions-${{ inputs.tag }}
54+
path: dist/
55+
- name: Publish package
56+
uses: pypa/[email protected]

.github/workflows/run-tests-gc.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Install the package and run the graph-cut tests
2+
# This test is kept separate, as the graphcut functionality is optional and unstable
3+
# Triggers on: All PRs that are mergable, but not for draft PRs
4+
# Triggers on: all published releases (incl pre-releases)
5+
6+
# Note: the dependency libboost_python will always be installed against the OS's main python version,
7+
# independent of the python version set-up. They are 22.04 = 3.10 and 20.04 = 3.8.
8+
9+
name: Run tests (graphcut only)
10+
11+
on:
12+
pull_request:
13+
types: [opened, synchronize, reopened, ready_for_review]
14+
release:
15+
types: [published]
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
run-tests-gc-ubuntu-22_04:
22+
if: github.event.pull_request.draft == false
23+
runs-on: ubuntu-22.04
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Python 3.10
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.10"
30+
- name: Install system dependencies for graphcut functionality
31+
run: sudo apt-get install -y libboost-python-dev build-essential
32+
- name: Install with test dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install -v .[test]
36+
- name: Test with pytest (graphcut test only)
37+
run: cd tests && pytest graphcut_/*
38+
39+
run-tests-gc-test-ubuntu-20_04:
40+
if: github.event.pull_request.draft == false
41+
runs-on: ubuntu-20.04
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Set up Python 3.8
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: "3.8"
48+
- name: Install system dependencies for graphcut functionality
49+
run: sudo apt-get install -y libboost-python-dev build-essential
50+
- name: Install with test dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
python -m pip install -v .[test]
54+
- name: Test with pytest (graphcut test only)
55+
run: cd tests && pytest graphcut_/*

.github/workflows/run-tests.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Install the package and run all tests except the graph-cut ones
2+
# Triggers on: All PRs that are mergable, but not for draft PRs
3+
# Triggers on: all published releases (incl pre-releases)
4+
5+
name: Run tests (wo graphcut)
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened, ready_for_review]
10+
release:
11+
types: [published]
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
run-tests:
18+
if: github.event.pull_request.draft == false
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: ["3.8", "3.9", "3.10", "3.11"]
24+
os: [ubuntu-latest, macos-latest]
25+
26+
runs-on: ${{ matrix.os }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- name: Install with test dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
python -m pip install .[test]
38+
- name: Test with pytest
39+
run: |
40+
pytest tests/features_/*
41+
pytest tests/filter_/*
42+
pytest tests/io_/*
43+
pytest tests/metric_/*

.gitignore

+17-24
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
TODO.txt
22

3-
# Images #
4-
##########
3+
4+
# Images
55
*.nii
66
*.mhd
77
*.raw
88

9-
# DOC dirs #
10-
############
9+
# Local virtual envs
10+
.venv/
11+
12+
# DOC dirs
1113
doc/build/
1214
doc/generated/
1315
doc/source/generated/
1416

15-
# Notebooks dirs #
16-
##################
17+
# Notebooks dirs
1718
.ipynb_checkpoints
1819

19-
# BUILD dirs #
20-
##############
20+
# BUILD dirs
2121
build/
2222
dist/
2323
MedPy.egg-info/
2424

25-
# Only locally used, temporary .py scripts. #
26-
#############################################
25+
# Only locally used, temporary .py scripts.
2726
_*.py
2827
!__init__.py
2928

30-
# Backup files #
31-
################
29+
# Backup files
3230
*.bak
3331

34-
# Compiled source #
35-
###################
32+
# Compiled source
3633
*.com
3734
*.class
3835
*.dll
@@ -42,8 +39,7 @@ _*.py
4239
*.pyc
4340
*.pyo
4441

45-
# Packages #
46-
############
42+
# Packages
4743
# it's better to unpack these files and commit the raw source
4844
# git has its own built in compression methods
4945
*.7z
@@ -55,29 +51,25 @@ _*.py
5551
*.tar
5652
*.zip
5753

58-
# Logs and databases #
59-
######################
54+
# Logs and databases
6055
*.log
6156
*.sql
6257
*.sqlite
6358

64-
# OS generated files #
65-
######################
59+
# OS generated files
6660
.DS_Store*
6761
ehthumbs.db
6862
Icon?
6963
Thumbs.db
7064
*~
7165

72-
# Eclipse and PyDev project files #
73-
###################################
66+
# Eclipse and PyDev project files
7467
.project
7568
.pydevproject
7669
.settings/
7770
.metadata/
7871

79-
# Suggestions by GitHub for Python projects #
80-
#############################################
72+
# Suggestions by GitHub for Python projects
8173
# Packages
8274
*.egg
8375
*.egg-info
@@ -96,6 +88,7 @@ pip-log.txt
9688
# Unit test / coverage reports
9789
.coverage
9890
.tox
91+
.hypothesis
9992

10093
#Translations
10194
*.mo

.gitmodules

-3
This file was deleted.

0 commit comments

Comments
 (0)