Skip to content

Commit 39a2c6c

Browse files
authored
Merge pull request #32 from cisco-ie/packaging
Add PyPi packaging to Makefile
2 parents be05646 + 4c4ae9b commit 39a2c6c

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

Makefile

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,55 @@
11
TEST_DIR=tests
2+
#PYPI_URL=https://test.pypi.org/legacy/
3+
PYPI_URL=https://upload.pypi.org/legacy/
4+
DEFAULT_PYTHON_VERSION=three
25

36
## Sets up the virtual environment via pipenv.
47
.PHONY: setup
58
setup:
6-
pipenv --three install --dev
9+
pipenv --$(DEFAULT_PYTHON_VERSION) install --dev
710

8-
## Cleans test and packaging outputs.
11+
## Removes everything including virtual environments.
912
.PHONY: clean
10-
clean:
11-
rm -rf .coverage htmlcov/ build/ dist/
13+
clean: mostlyclean
14+
-pipenv --rm
15+
rm -f Pipfile.lock
16+
17+
## Removes test and packaging outputs.
18+
.PHONY: mostlyclean
19+
mostlyclean:
20+
rm -rf .coverage htmlcov/ .pytest_cache/ build/ dist/
1221

1322
## Runs tests.
1423
.PHONY: test
15-
test: clean
24+
test:
1625
pipenv run pytest $(TEST_DIR) -v -s --disable-warnings
1726

1827
## Creates coverage report.
1928
.PHONY: coverage
2029
coverage:
21-
pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings
30+
pipenv run pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings
2231
open htmlcov/index.html || xdg-open htmlcov/index.html
2332

24-
.DEFAULT:
25-
@$(MAKE) help
33+
## Packages for both Python 2 and 3 for PyPi.
34+
.PHONY: dist
35+
dist: mostlyclean
36+
-pipenv --rm
37+
pipenv --three install --dev --skip-lock
38+
pipenv run python setup.py sdist bdist_wheel
39+
pipenv --rm
40+
pipenv --two install --dev --skip-lock
41+
pipenv run python setup.py sdist bdist_wheel
42+
pipenv --rm
43+
pipenv --$(DEFAULT_PYTHON_VERSION) install --dev
44+
45+
## Uploads packages to PyPi.
46+
.PHONY: upload
47+
upload:
48+
pipenv run twine upload --repository-url $(PYPI_URL) dist/*
49+
50+
## Alias for packaging and upload together.
51+
.PHONY: pypi
52+
pypi: dist upload
2653

2754
## This help message.
2855
.PHONY: help

0 commit comments

Comments
 (0)