curl "https://raw.githubusercontent.com/pylover/python-makelib/master/install.sh" | sudo shOr
git clone <repo-url>
cd repo
sudo make install
sudo make install PREFIX=/optOr
git clone <repo-url>
cd repo
make clean dist
sudo tar -C /usr/local/lib -xvf dist/python-makelib-*.tar.gzCreate a Makefile in your project's root:
PKG_NAMESPACE = foo.bar
PKG_NAME = foo-bar
AUTHOR = "Alice"
AUTHOR_EMAIL = "[email protected]"
DESCRIPTION = "An awesome Python project"
# Common development depenndencies
PYDEPS_COMMON += \
'baz' \
'qux'
# documentation building depenndencies
PYDEPS_DOC += \
'foo'
# local development and debugging dependencies such as debugging and etc.
PYDEPS_DEV += \
'foo', \
'bar'
# Assert the python-makelib version
PYTHON_MAKELIB_VERSION_REQUIRED = 1.7
# Ensure the python-makelib is installed
PYTHON_MAKELIB_PATH = /usr/local/lib/python-makelib
ifeq ("", "$(wildcard $(PYTHON_MAKELIB_PATH))")
MAKELIB_URL = https://github.com/pylover/python-makelib
$(error python-makelib is not installed. see "$(MAKELIB_URL)")
endif
# Then, include one of files below:
include $(PYTHON_MAKELIB_PATH)/venv-lint.mk
# Or
include $(PYTHON_MAKELIB_PATH)/venv-lint-pypi.mk
# Or
include $(PYTHON_MAKELIB_PATH)/venv-lint-test.mk
# Or
include $(PYTHON_MAKELIB_PATH)/venv-lint-test-pypi.mk
# Or
include $(PYTHON_MAKELIB_PATH)/venv-lint-test-doc.mk
# Or
include $(PYTHON_MAKELIB_PATH)/venv-lint-test-doc-pypi.mkTo delete previous virtual environment and create a fresh one, then install all you need to develop the project, run:
make fresh env To delete previous virtual environment and create a fresh one, then install
the project normally using pip install ., run:
make fresh installTo create the activate.sh script symbolic link:
# First needed only
make activate.sh Then, activate your virtual environment using:
source activate.shTo run all quality assurance checks such as: link, test, coverage,
doctest and etc:
make qaThese variables may set by user before including any *.mk file(s).
Full qualified package name for your project, for example: yhttp.ext.pony.
default is the name of Makefile's directory.
PKG_NAMESPACE ?= $(shell basename $(HERE))Name of the Python package, the same as the setup.py's setup(name=...).
default is the name of Makefile's directory.
PKG_NAME ?= $(shell basename $(HERE))The Python virtual environment to deal with it. default is the PKG_NAME.
VENV_NAME ?= $(PKG_NAME)NOTE: the
VENV_NAMEvariable will be ignored if thePREFIXis set.
Prefix path for Python's binaries and libraries (aka: virtual environment). default is:
PREFIX ?= $(HOME)/.virtualenvs/$(VENV_NAME)NOTE:
common.mkmust be included before any other file(s).
Run all quality assurance tests driven from imported files:
make qaFind the version from the project's init.py and create a tagged commit, and push with --tags
make releaseDelete everything inside the dist/* and build/* directories
make clean Create a virtual environment by python -m venv $(PREFIX)
make venvDelete the virtualenv
make venv-deleteDelete and re-create a fresh virtual environment
make freshDelete and re-create a fresh virtual environment + editable mode install
make fresh envCreate a symbolic link to activate.sh:
make activate.shNormal project installation using the pip:
make installInstall PYDEPS_* packages:
make install-common
make install-dev
make install-docEditable project installation using pip -e:
make editable-installUninstall project using pip uninstall:
make uninstalleditable-install + ENV_DEPS rules which expanded by including various
*.mk files. default: ENV_DEPS = install-common install-dev
make envLint using flake8
make lintRun tests using pytest
make testRun a specific test
make test F=tests/test_foo.py::test_barfuncRun test + coverage
make coverGenerate HTML code coverage report
make cover-htmlGenerate html documentation
make docRun documentation tests
make doctestDocumentation HTTP server
make livedocCreate a tar.gz (source) districution
make sdistCreate a wheel (binary) districution
make wheelsdist + wheel
make distTo upload the source and binary(wheel) files to pypi using twine:
make pypiNOTE:
dist.mkmust be included beforepypi.mk
Web API projects stuff.
Path to a directory which contains the web API documentation HTML files.
default: apidoc.
Serve API documentation HTML files:
make webapi-servesudo make installEdit _version.mk, then:
make release