Skip to content

Commit

Permalink
Improve Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 6, 2021
1 parent b3b90fb commit b2980fe
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 24 deletions.
16 changes: 15 additions & 1 deletion Makefile
@@ -1,3 +1,17 @@
include util.mk

# make release bump=minor (major,minor,patch)

# =============
# Configuration
# =============

$(eval imagecast := $(venv)/bin/imagecast)


# =====
# Setup
# =====

# Install requirements for development.
setup-package: virtualenv-dev
@test -e $(imagecast) || $(pip) install --upgrade --editable=.[service]
65 changes: 42 additions & 23 deletions util.mk
@@ -1,36 +1,45 @@
# ============
# Main targets
# ============
# =============
# Configuration
# =============

$(eval venv := .venv)
$(eval pip := $(venv)/bin/pip)
$(eval python := $(venv)/bin/python)
$(eval pytest := $(venv)/bin/pytest)
$(eval bumpversion := $(venv)/bin/bumpversion)
$(eval twine := $(venv)/bin/twine)

# -------------
# Configuration
# -------------

$(eval venvpath := .venv_util)
$(eval pip := $(venvpath)/bin/pip)
$(eval python := $(venvpath)/bin/python)
$(eval bumpversion := $(venvpath)/bin/bumpversion)
$(eval twine := $(venvpath)/bin/twine)
# =====
# Setup
# =====

# Setup Python virtualenv
setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python3 --no-site-packages $(venvpath)
@test -e $(python) || python3 -m venv $(venv)

# Install requirements for development.
virtualenv-dev: setup-virtualenv
@test -e $(pytest) || $(pip) install --upgrade --requirement=requirements-test.txt

# -------
# Install requirements for releasing.
install-releasetools: setup-virtualenv
@$(pip) install --quiet --requirement requirements-release.txt --upgrade


# =======
# Release
# -------
# =======

# Release this piece of software
# Synopsis:
# make release bump=minor (major,minor,patch)
release: bumpversion push sdist pypi-upload
# Release this piece of software.
# Uses the fine ``bumpversion`` utility.
#
# Synopsis::
#
# make release bump={patch,minor,major}

release: bumpversion push sdist pypi-upload

# ===============
# Utility targets
# ===============
bumpversion: install-releasetools
@$(bumpversion) $(bump)

Expand All @@ -43,5 +52,15 @@ sdist:
pypi-upload: install-releasetools
twine upload --skip-existing --verbose dist/*.tar.gz

install-releasetools: setup-virtualenv
@$(pip) install --quiet --requirement requirements-release.txt --upgrade

# ==============
# Software tests
# ==============

.PHONY: test
pytest: setup-package

@# Run pytest.
$(pytest) test -vvv

test: pytest

0 comments on commit b2980fe

Please sign in to comment.