Skip to content

Commit

Permalink
197 set up versioneer and test releasing (Project-MONAI#225)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wyli authored Mar 30, 2020
1 parent 32f8adb commit ec1d73d
Show file tree
Hide file tree
Showing 12 changed files with 2,482 additions and 73 deletions.
15 changes: 0 additions & 15 deletions .flake8

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
monai/_version.py export-subst
51 changes: 49 additions & 2 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
flake8-py3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
Expand All @@ -24,7 +24,8 @@ jobs:
pip install flake8 flake8-mypy flake8-bugbear flake8-comprehensions flake8-executable flake8-pyi mccabe pycodestyle pyflakes
pip install pep8-naming
flake8 --version
flake8 . --count --statistics --config .flake8
python -c 'import monai; monai.config.print_config()'
flake8 . --count --statistics
test-py3:
container:
Expand All @@ -51,3 +52,49 @@ jobs:
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml

packaging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install setuptools
run: |
python -m pip install --user --upgrade setuptools wheel
- name: Test source archive and wheel file
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
root_dir=$PWD
echo "$root_dir"
set -e
# build tar.gz and wheel
python setup.py sdist bdist_wheel
tmp_dir=$(mktemp -d)
cp dist/monai* "$tmp_dir"
rm -r build dist monai.egg-info
cd "$tmp_dir"
ls -al
# install from wheel
python -m pip install monai*.whl
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
python -m pip uninstall -y monai
rm monai*.whl
# install from tar.gz
python -m pip install monai*.tar.gz
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
python -m pip uninstall -y monai
rm monai*.tar.gz
# clean up
cd "$root_dir"
rm -r "$tmp_dir"
6 changes: 3 additions & 3 deletions .github/workflows/setupapp.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy
name: deploy

on:
push:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
- name: Import
run: |
python -c 'import monai; print(monai.__version__)'
python -c 'import monai; monai.config.print_config()'
- name: Uninstall
run: |
pip uninstall -y monai
Expand All @@ -56,7 +56,7 @@ jobs:
steps:
- name: Import
run: |
python -c 'import monai; print(monai.__version__)'
python -c 'import monai; monai.config.print_config()'
cd /opt/monai
ls -al
ngc --version
16 changes: 15 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Ideally, the new branch should be based on the latest `master` branch.
1. Wait for the pull request to be merged.

### Coding style
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).
Coding style is checked by flake8, using [a flake8 configuration](./setup.cfg) similar to [PyTorch's](https://github.com/pytorch/pytorch/blob/master/.flake8).

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

[github ci]: https://github.com/Project-MONAI/MONAI/actions
[monai issue list]: https://github.com/Project-MONAI/MONAI/issues


## Admin tasks

### Release a new version
- Prepare [a release note](https://github.com/Project-MONAI/MONAI/releases)
- Checkout a new branch `releasing-version-N`
- Create a tag, for example `git tag -a 0.1a -m "version 0.1a"`
- [Generate distribution archives](https://packaging.python.org/tutorials/packaging-projects/) `python3 setup.py sdist bdist_wheel`
- Test the package locally `pip install monai`
- Upload the package to [PyPI](https://pypi.org/project/monai/)
- Publish the release note

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.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include versioneer.py
include monai/_version.py
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ coverage:

# Disable comments on PR
comment: false

ignore:
- "versioneer.py"
- "monai/_version.py"
5 changes: 4 additions & 1 deletion monai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
import os
import sys

from ._version import get_versions
from .utils.module import load_submodules

__version__ = get_versions()['version']
del get_versions

__copyright__ = "(c) 2020 MONAI Consortium"
__version__ = "0.0.1"

__basedir__ = os.path.dirname(__file__)

Expand Down
Loading

0 comments on commit ec1d73d

Please sign in to comment.