From b43ae8ac8e34cd16f16c10d28478412aa8d3b328 Mon Sep 17 00:00:00 2001 From: Remington Campbell Date: Thu, 24 Oct 2019 13:17:48 -0700 Subject: [PATCH 1/2] Add packaging Makefile targets --- Makefile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Makefile b/Makefile index 7b260c4..cd55c0a 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,29 @@ coverage: pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings open htmlcov/index.html || xdg-open htmlcov/index.html +## Packages for both Python 2 and 3 for PyPi. +.PHONY: packaging +packaging: + pipenv --rm + rm Pipfile.lock + pipenv --three install --dev + pipenv run python setup.py sdist bdist_wheel + pipenv --rm + rm Pipfile.lock + pipenv --two install --dev + pipenv run python setup.py sdist bdist_wheel + pipenv --rm + rm Pipfile.lock + +## Uploads packages to PyPi. +.PHONY: upload +upload: + pipenv run twine upload dist/* + +## Alias for packaging and upload together. +.PHONY: pypi +pypi: packaging upload setup + .DEFAULT: @$(MAKE) help From 4c4ae9b12c382449614294bf3b4813e03410b3ce Mon Sep 17 00:00:00 2001 From: Remington Campbell Date: Fri, 25 Oct 2019 17:42:05 -0700 Subject: [PATCH 2/2] Add PyPi packaging --- Makefile | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index cd55c0a..4ffc67c 100644 --- a/Makefile +++ b/Makefile @@ -1,51 +1,55 @@ TEST_DIR=tests +#PYPI_URL=https://test.pypi.org/legacy/ +PYPI_URL=https://upload.pypi.org/legacy/ +DEFAULT_PYTHON_VERSION=three ## Sets up the virtual environment via pipenv. .PHONY: setup setup: - pipenv --three install --dev + pipenv --$(DEFAULT_PYTHON_VERSION) install --dev -## Cleans test and packaging outputs. +## Removes everything including virtual environments. .PHONY: clean -clean: - rm -rf .coverage htmlcov/ build/ dist/ +clean: mostlyclean + -pipenv --rm + rm -f Pipfile.lock + +## Removes test and packaging outputs. +.PHONY: mostlyclean +mostlyclean: + rm -rf .coverage htmlcov/ .pytest_cache/ build/ dist/ ## Runs tests. .PHONY: test -test: clean +test: pipenv run pytest $(TEST_DIR) -v -s --disable-warnings ## Creates coverage report. .PHONY: coverage coverage: - pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings + pipenv run pytest --cov=src/ --cov-report=term-missing --cov-report=html --disable-warnings open htmlcov/index.html || xdg-open htmlcov/index.html ## Packages for both Python 2 and 3 for PyPi. -.PHONY: packaging -packaging: - pipenv --rm - rm Pipfile.lock - pipenv --three install --dev +.PHONY: dist +dist: mostlyclean + -pipenv --rm + pipenv --three install --dev --skip-lock pipenv run python setup.py sdist bdist_wheel pipenv --rm - rm Pipfile.lock - pipenv --two install --dev + pipenv --two install --dev --skip-lock pipenv run python setup.py sdist bdist_wheel pipenv --rm - rm Pipfile.lock + pipenv --$(DEFAULT_PYTHON_VERSION) install --dev ## Uploads packages to PyPi. .PHONY: upload upload: - pipenv run twine upload dist/* + pipenv run twine upload --repository-url $(PYPI_URL) dist/* ## Alias for packaging and upload together. .PHONY: pypi -pypi: packaging upload setup - -.DEFAULT: - @$(MAKE) help +pypi: dist upload ## This help message. .PHONY: help