Skip to content

Commit ef72002

Browse files
committed
finished complete release workflow
1 parent 6f2a32d commit ef72002

File tree

7 files changed

+155
-46
lines changed

7 files changed

+155
-46
lines changed

Makefile

+78-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# usage: make help
22

3-
.PHONY: clean clean-test clean-pyc clean-build docs help clean-pypi clean-build-pypi clean-pyc-pypi clean-test-pypi dist-pypi release-pypi clean-conda clean-build-conda clean-pyc-conda clean-test-conda test tag
3+
.PHONY: clean clean-test clean-pyc clean-build docs help clean-pypi clean-build-pypi clean-pyc-pypi clean-test-pypi dist-pypi release-pypi clean-conda clean-build-conda clean-pyc-conda clean-test-conda test tag bump bump-minor bump-major bump-dev bump-minor-dev bump-major-dev commit-tag git-pull git-not-dirty test-install
4+
5+
version_file = fastprogress/version.py
6+
version = $(shell python setup.py --version)
47

58
.DEFAULT_GOAL := help
69

@@ -57,39 +60,39 @@ clean-test-pypi: ## remove pypi test and coverage artifacts
5760
rm -fr .pytest_cache
5861

5962
dist-pypi: clean-pypi ## build pypi source and wheel package
63+
@echo "\n\n*** Building pypi packages"
6064
python setup.py sdist
6165
python setup.py bdist_wheel
6266
ls -l dist
6367

6468
release-pypi: dist-pypi ## release pypi package
65-
@echo "\n\nUploading" dist/* "to pypi\n"
66-
@echo "XXX: disabled for now"
67-
#twine upload dist/*
69+
@echo "\n\n*** Uploading" dist/* "to pypi\n"
70+
twine upload dist/*
6871

6972

7073
### Conda ###
7174

7275
clean-conda: clean-build-conda clean-pyc-conda clean-test-conda ## remove all build, test, coverage and python artifacts
7376

7477
clean-build-conda: ## remove conda build artifacts
75-
@echo "conda build purge"
76-
conda build purge
77-
@echo "rm -fr conda-dist/"
78+
@echo "\n\n*** conda build purge"
79+
conda build purge-all
80+
@echo "\n\n*** rm -fr conda-dist/"
7881
rm -fr conda-dist/
7982

8083
clean-pyc-conda: ## remove conda python file artifacts
8184

8285
clean-test-conda: ## remove conda test and coverage artifacts
8386

8487
dist-conda: clean-conda ## build conda package
88+
@echo "\n\n*** Building conda package"
8589
mkdir "conda-dist"
8690
conda-build ./conda/ --output-folder conda-dist
8791
ls -l conda-dist/noarch/*tar.bz2
8892

8993
release-conda: dist-conda ## release conda package
90-
@echo "\n\nUploading" conda-dist/noarch/*tar.bz2 "to [email protected]\n"
91-
@echo "XXX: disabled for now"
92-
#anaconda upload conda-dist/noarch/*tar.bz2 -u fastai
94+
@echo "\n\n*** Uploading" conda-dist/noarch/*tar.bz2 "to [email protected]\n"
95+
anaconda upload conda-dist/noarch/*tar.bz2 -u fastai
9396

9497

9598

@@ -99,25 +102,81 @@ release-conda: dist-conda ## release conda package
99102

100103
clean: clean-pypi clean-conda ## clean pip && conda package
101104

102-
dist: dist-pypi dist-conda ## build pip && conda package
105+
dist: clean dist-pypi dist-conda ## build pip && conda package
103106

104107
release: dist release-pypi release-conda ## release pip && conda package
105108

106-
git-update: ## git pull
107-
@echo "Making sure we have the latest checkout"
108-
git pull
109-
110109
install: clean ## install the package to the active python's site-packages
111110
python setup.py install
112111

112+
test: ## run tests with the default python
113+
python setup.py --quiet test
114+
115+
116+
### git ###
117+
118+
git-pull: ## git pull
119+
@echo "\n\n*** Making sure we have the latest checkout"
120+
git pull
121+
git status
122+
123+
git-not-dirty:
124+
@echo "*** Checking that everything is committed"
125+
[[ -n $(git status -s) ]] && $(error uncommitted git files)
126+
113127

114128
### Tagging ###
115129

116-
tag: ## tag the release with current version
117-
@git tag $$(python setup.py --version) && git push --tags || echo 'Version already released, update your version!'
130+
commit-tag: ## commit and tag the release
131+
@echo "\n\n*** Commit $(version) version"
132+
git commit -m "version $(version) release" $(version_file)
118133

119-
test: ## run tests with the default python
120-
python setup.py test
134+
@echo "\n\n*** Tag $(version) version"
135+
git tag -a $(version) -m "$(version)" && git push --tags
136+
137+
@echo "\n\n*** Push all changes"
138+
git push
139+
140+
141+
### Testing new package installation
142+
143+
test-install: ## test conda/pip package by installing that version them
144+
@echo "\n\n*** Install/uninstall $(version) pip version"
145+
@pip uninstall -y fastprogress
146+
pip install fastprogress==$(version)
147+
pip uninstall -y fastprogress
148+
149+
@echo "\n\n*** Install/uninstall $(version) conda version"
150+
@# skip, throws error when uninstalled @conda uninstall -y fastprogress
151+
conda install -y -c fastai fastprogress==$(version)
152+
@# leave conda package installed: conda uninstall -y fastprogress
153+
154+
155+
### Version bumping ###
156+
157+
# Support semver, but using python's .dev0 instead of -dev0
158+
159+
bump-patch: ## bump patch-level unless has .devX, then don't bump, but remove .devX
160+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2, $$3, $$4+1); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
161+
162+
bump: bump-patch ## alias to bump-patch (as it's used often)
163+
164+
bump-minor: ## bump minor-level unless has .devX, then don't bump, but remove .devX
165+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2, $$3+1, $$4); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
166+
167+
bump-major: ## bump major-level unless has .devX, then don't bump, but remove .devX
168+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=$$5 ? join(".", $$2, $$3, $$4) :join(".", $$2+1, $$3, $$4); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
169+
170+
bump-patch-dev: ## bump patch-level and add .dev0
171+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2, $$3, $$4+1, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
172+
173+
bump-dev: bump-patch-dev ## alias to bump-patch-dev (as it's used often)
174+
175+
bump-minor-dev: ## bump minor-level and add .dev0
176+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2, $$3+1, $$4, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
177+
178+
bump-major-dev: ## bump major-level and add .dev0
179+
@perl -pi -e 's|((\d+)\.(\d+).(\d+)(\.\w+\d+)?)|$$o=$$1; $$n=join(".", $$2+1, $$3, $$4, "dev0"); print STDERR "*** Changing version: $$o => $$n\n"; $$n |e' $(version_file)
121180

122181

123182
# # XXX: untested

RELEASE.md

+67-23
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,79 @@
22

33
## TL;DR
44

5-
Test code:
6-
```
7-
make git-update
8-
make test
9-
```
105

11-
XXX: version bump + commit
6+
1. Test code:
7+
```
8+
make git-pull
9+
make test
10+
make git-not-dirty || echo "Commit changes before proceeding"
11+
```
12+
13+
The next stage requires a clean tree to start with, so commit any uncommitted code. If you `git stash` make sure to rerun `make test`.
14+
15+
2. Bump and Tag and Commit:
16+
17+
```
18+
make git-not-dirty && make bump && make commit-tag
19+
```
20+
21+
This will do patch-level bump, for major/minor bump targets see below.
1222

13-
Release:
14-
```
15-
make release
16-
make tag
17-
```
23+
3. Release:
24+
25+
```
26+
make release
27+
```
28+
29+
4. Test uploads by installing them:
30+
31+
```
32+
make test-install
33+
```
34+
35+
5. Update fastai repo
36+
37+
If this was a bug fix, update `fastai` dependency files: `conda/meta.yaml` and `setup.py` with this release's `fastprogress` version number.
1838

19-
Test uploads by installing them:
20-
```
21-
pip install fastprogress
22-
conda install -c fastai fastprogress
23-
```
2439

25-
If this was a bug fix, update `fastai` dependency files: `conda/meta.yaml` and `setup.py` with this release's `fastprogress` version number.
2640

2741
## Detailed information
2842

2943
The following is needed if the combined release instructions were failing. So that each step can be done separately.
3044

45+
3146
### Bump the version
3247

33-
Edit `setup.py` and change the version number.
48+
You can either edit `fastprogress/version.py` and change the version number by hand.
49+
50+
Or run one of these `make` targets:
51+
52+
Target | Function
53+
-------------------| --------------------------------------------
54+
bump-major | bump major-level unless has .devX, then don't bump, but remove .devX
55+
bump-minor | bump minor-level unless has .devX, then don't bump, but remove .devX
56+
bump-patch | bump patch-level unless has .devX, then don't bump, but remove .devX
57+
bump | alias to bump-patch (as it's used often)
58+
bump-major-dev | bump major-level and add .dev0
59+
bump-minor-dev | bump minor-level and add .dev0
60+
bump-patch-dev | bump patch-level and add .dev0
61+
bump-dev | alias to bump-patch-dev (as it's used often)
62+
63+
64+
We use semver version convention w/o python adjustment to `.devX`, instead of `-devX`:
3465

35-
### PyPI
66+
* release: `major.minor.patch`, 0.1.10
67+
* dev or rc: `major.minor.patch.devX`, 0.1.10.dev0
68+
69+
For fastprogress, due to its simplicity and usage, there is probably no need for intermediary `.devX` stage. So just normal `bump` will do when a new version is released.
70+
71+
72+
73+
### PyPI details
3674

3775
To build a PyPI package and release it on [pypi.org/](https://pypi.org/project/fastprogress/):
3876

39-
1. Build the package (source and wheel)
77+
1. Build the pip packages (source and wheel)
4078

4179
```
4280
make dist-pypi
@@ -48,7 +86,7 @@ To build a PyPI package and release it on [pypi.org/](https://pypi.org/project/f
4886
make release-pypi
4987
```
5088

51-
Note: PyPI won't allow re-uploading the same package filename, even if it's a minor fix. If you delete the file from pypi or test.pypi it still won't let you do it. So either a micro-level version needs to be bumped (A.B.C++) or some [post release string added](https://www.python.org/dev/peps/pep-0440/#post-releases) in `setup.py`.
89+
Note: PyPI won't allow re-uploading the same package filename, even if it's a minor fix. If you delete the file from pypi or test.pypi it still won't let you do it. So either a patch-level version needs to be bumped (A.B.C++) or some [post release string added](https://www.python.org/dev/peps/pep-0440/#post-releases) in `version.py`.
5290

5391
3. Test that the uploaded package is found and gets installed:
5492

@@ -62,11 +100,11 @@ To build a PyPI package and release it on [pypi.org/](https://pypi.org/project/f
62100

63101

64102

65-
### Conda
103+
### Conda details
66104

67105
To build a Conda package and release it on [anaconda.org](https://anaconda.org/fastai/fastprogress):
68106

69-
1. Build the fastprogress package:
107+
1. Build the fastprogress conda package:
70108

71109
```
72110
make dist-conda
@@ -89,3 +127,9 @@ To build a Conda package and release it on [anaconda.org](https://anaconda.org/f
89127
```
90128
conda install -c fastai fastprogress
91129
```
130+
131+
### Others
132+
133+
`make clean` removes any intermediary build artifacts.
134+
135+
`make` will show all possible targets with a short description of what they do.

conda/meta.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ requirements:
2121
build:
2222
- python
2323
- setuptools
24+
- pytest-runner
2425
run:
2526
- python
2627

fastprogress/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from .fastprogress import master_bar, progress_bar, force_console_behavior
1+
from .fastprogress import master_bar, progress_bar, force_console_behavior
2+
from .version import __version__

fastprogress/version.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__all__ = ['__version__']
2+
__version__ = '0.1.10'

setup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import setuptools
22

3+
# note: version is maintained inside fastprogress/version.py
4+
exec(open('fastprogress/version.py').read())
5+
36
with open("README.md", "r") as fh:
47
long_description = fh.read()
58

69
setuptools.setup(
710
name="fastprogress",
8-
version="0.1.10",
11+
version=__version__,
912
author="Sylvain Gugger",
1013
license = "Apache License 2.0",
1114
description="A nested progress with plotting options for fastai",

tests/test_basic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@
66
import fastprogress
77

88
def test_basic():
9-
assert fastprogress # just import test for now
10-
#assert fastprogress.__version__
9+
assert fastprogress.__version__

0 commit comments

Comments
 (0)