curl "https://raw.githubusercontent.com/pylover/python-makelib/master/install.sh" | sudo sh
Or
git clone <repo-url>
cd repo
sudo make install
sudo make install PREFIX=/opt
Or
git clone <repo-url>
cd repo
make clean dist
sudo tar -C /usr/local/lib -xvf dist/python-makelib-*.tar.gz
Create 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.mk
To 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 install
To create the activate.sh
script symbolic link:
# First needed only
make activate.sh
Then, activate your virtual environment using:
source activate.sh
To run all quality assurance checks such as: link
, test
, coverage
,
doctest
and etc:
make qa
These 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_NAME
variable will be ignored if thePREFIX
is set.
Prefix path for Python's binaries and libraries (aka: virtual environment). default is:
PREFIX ?= $(HOME)/.virtualenvs/$(VENV_NAME)
NOTE:
common.mk
must be included before any other file(s).
Run all quality assurance tests driven from imported files:
make qa
Find the version from the project's init.py and create a tagged commit, and push with --tags
make release
Delete everything inside the dist/* and build/* directories
make clean
Create a virtual environment by python -m venv $(PREFIX)
make venv
Delete the virtualenv
make venv-delete
Delete and re-create a fresh virtual environment
make fresh
Delete and re-create a fresh virtual environment + editable mode install
make fresh env
Create a symbolic link to activate.sh
:
make activate.sh
Normal project installation using the pip:
make install
Install PYDEPS_* packages:
make install-common
make install-dev
make install-doc
Editable project installation using pip -e
:
make editable-install
Uninstall project using pip uninstall
:
make uninstall
editable-install
+ ENV_DEPS
rules which expanded by including various
*.mk
files. default: ENV_DEPS = install-common install-dev
make env
Lint using flake8
make lint
Run tests using pytest
make test
Run a specific test
make test F=tests/test_foo.py::test_barfunc
Run test + coverage
make cover
Generate HTML code coverage report
make cover-html
Generate html documentation
make doc
Run documentation tests
make doctest
Documentation HTTP server
make livedoc
Create a tar.gz
(source) districution
make sdist
Create a wheel
(binary) districution
make wheel
sdist
+ wheel
make dist
To upload the source and binary(wheel
) files to pypi using twine
:
make pypi
NOTE:
dist.mk
must 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-serve
sudo make install
Edit _version.mk
, then:
make release