Skip to content

Commit ec1d73d

Browse files
authored
197 set up versioneer and test releasing (#225)
* set up versioning with versioneer 0.18 * revise setup cfg * update contributing.md * ci to display version numbers * ignore autogenerated files * Adds packaging tests - tests for python 3.x - adds license for setup.py - adds python3.x required in setup.cfg
1 parent 32f8adb commit ec1d73d

12 files changed

+2482
-73
lines changed

Diff for: .flake8

-15
This file was deleted.

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
monai/_version.py export-subst

Diff for: .github/workflows/pythonapp.yml

+49-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
flake8-py3:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v2
1414
- name: Set up Python 3.7
1515
uses: actions/setup-python@v1
1616
with:
@@ -24,7 +24,8 @@ jobs:
2424
pip install flake8 flake8-mypy flake8-bugbear flake8-comprehensions flake8-executable flake8-pyi mccabe pycodestyle pyflakes
2525
pip install pep8-naming
2626
flake8 --version
27-
flake8 . --count --statistics --config .flake8
27+
python -c 'import monai; monai.config.print_config()'
28+
flake8 . --count --statistics
2829
2930
test-py3:
3031
container:
@@ -51,3 +52,49 @@ jobs:
5152
uses: codecov/codecov-action@v1
5253
with:
5354
file: ./coverage.xml
55+
56+
packaging:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v2
60+
with:
61+
fetch-depth: 0
62+
- name: Set up Python 3.x
63+
uses: actions/setup-python@v1
64+
with:
65+
python-version: '3.x'
66+
- name: Install setuptools
67+
run: |
68+
python -m pip install --user --upgrade setuptools wheel
69+
- name: Test source archive and wheel file
70+
run: |
71+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
72+
root_dir=$PWD
73+
echo "$root_dir"
74+
set -e
75+
76+
# build tar.gz and wheel
77+
python setup.py sdist bdist_wheel
78+
tmp_dir=$(mktemp -d)
79+
cp dist/monai* "$tmp_dir"
80+
rm -r build dist monai.egg-info
81+
cd "$tmp_dir"
82+
ls -al
83+
84+
# install from wheel
85+
python -m pip install monai*.whl
86+
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
87+
python -c 'import monai; print(monai.__file__)'
88+
python -m pip uninstall -y monai
89+
rm monai*.whl
90+
91+
# install from tar.gz
92+
python -m pip install monai*.tar.gz
93+
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
94+
python -c 'import monai; print(monai.__file__)'
95+
python -m pip uninstall -y monai
96+
rm monai*.tar.gz
97+
98+
# clean up
99+
cd "$root_dir"
100+
rm -r "$tmp_dir"

Diff for: .github/workflows/setupapp.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy
1+
name: deploy
22

33
on:
44
push:
@@ -44,7 +44,7 @@ jobs:
4444
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
4545
- name: Import
4646
run: |
47-
python -c 'import monai; print(monai.__version__)'
47+
python -c 'import monai; monai.config.print_config()'
4848
- name: Uninstall
4949
run: |
5050
pip uninstall -y monai
@@ -56,7 +56,7 @@ jobs:
5656
steps:
5757
- name: Import
5858
run: |
59-
python -c 'import monai; print(monai.__version__)'
59+
python -c 'import monai; monai.config.print_config()'
6060
cd /opt/monai
6161
ls -al
6262
ngc --version

Diff for: CONTRIBUTING.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Ideally, the new branch should be based on the latest `master` branch.
4242
1. Wait for the pull request to be merged.
4343

4444
### Coding style
45-
Coding style is checked by flake8, using [a flake8 configuration](https://github.com/Project-MONAI/MONAI/blob/master/.flake8) similar to [PyTorch's](https://github.com/pytorch/pytorch/blob/master/.flake8).
45+
Coding style is checked by flake8, using [a flake8 configuration](./setup.cfg) similar to [PyTorch's](https://github.com/pytorch/pytorch/blob/master/.flake8).
4646

4747
License information: all source code files should start with this paragraph:
4848
```
@@ -111,3 +111,17 @@ All code review comments should be specific, constructive, and actionable.
111111

112112
[github ci]: https://github.com/Project-MONAI/MONAI/actions
113113
[monai issue list]: https://github.com/Project-MONAI/MONAI/issues
114+
115+
116+
## Admin tasks
117+
118+
### Release a new version
119+
- Prepare [a release note](https://github.com/Project-MONAI/MONAI/releases)
120+
- Checkout a new branch `releasing-version-N`
121+
- Create a tag, for example `git tag -a 0.1a -m "version 0.1a"`
122+
- [Generate distribution archives](https://packaging.python.org/tutorials/packaging-projects/) `python3 setup.py sdist bdist_wheel`
123+
- Test the package locally `pip install monai`
124+
- Upload the package to [PyPI](https://pypi.org/project/monai/)
125+
- Publish the release note
126+
127+
Note that the release should be tagged with a [PEP440](https://www.python.org/dev/peps/pep-0440/) compliant [semantic versioning](https://semver.org/spec/v2.0.0.html) number.

Diff for: MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include versioneer.py
2+
include monai/_version.py

Diff for: codecov.yml

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ coverage:
2626

2727
# Disable comments on PR
2828
comment: false
29+
30+
ignore:
31+
- "versioneer.py"
32+
- "monai/_version.py"

Diff for: monai/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
import os
1313
import sys
1414

15+
from ._version import get_versions
1516
from .utils.module import load_submodules
1617

18+
__version__ = get_versions()['version']
19+
del get_versions
20+
1721
__copyright__ = "(c) 2020 MONAI Consortium"
18-
__version__ = "0.0.1"
1922

2023
__basedir__ = os.path.dirname(__file__)
2124

0 commit comments

Comments
 (0)