Aller au contenu

python_makefile.mk

1. Read-only variables

You can use them in your own Makefile but NEVER try to override these variables!

1.1 VENV_DIR

virtualenv directory
  • Value: $(ROOT_TOOLS)/venv

1.2 ENTER_VENV

"enter virtualenv" variable
you can use it in your Makefile scripts, for example:
$(ENTER_VENV) && pip freeze
  • Value: . $(VENV_DIR)/bin/activate

2. Overridable variables

Note

you can use/override/extend these variables in your own Makefile.

2.1 PYTHON

This variable must be specifically overriden BEFORE incuding any common makefiles

python interpreter configuration:
AUTO_3_8    => auto-download python 3.8
AUTO_3_9    => auto-download python 3.9
AUTO_3_10   => auto-download python 3.10
(path)      => use this binary
  • Default: AUTO_3_9

2.2 PYTHON_3_8_URL

python 3.8 download url
  • Default: https://github.com/indygreg/python-build-standalone/releases/download/20220318/cpython-3.8.13+20220318-x86_64-unknown-linux-gnu-install_only.tar.gz

2.3 PYTHON_3_9_URL

python 3.9 download url
  • Default: https://github.com/indygreg/python-build-standalone/releases/download/20220318/cpython-3.9.11+20220318-x86_64-unknown-linux-gnu-install_only.tar.gz

2.4 PYTHON_3_10_URL

python 3.10 download url
  • Default: https://github.com/indygreg/python-build-standalone/releases/download/20220318/cpython-3.10.3+20220318-x86_64-unknown-linux-gnu-install_only.tar.gz

2.5 BLACK

black binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: black

2.6 BLACK_REFORMAT_OPTIONS

black reformat options
  • Default: $(_MAX_LINE_LENGTH_MINUS_1)

2.7 BLACK_LINT_OPTIONS

black lint options
  • Default: $(BLACK_REFORMAT_OPTIONS) --quiet --check

2.8 ISORT

isort binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: isort

2.9 ISORT_REFORMAT_OPTIONS

isort reformat options
  • Default: $(VENV_DIR)

2.10 ISORT_LINT_OPTIONS

isort lint options
  • Default: $(ISORT_REFORMAT_OPTIONS) --check-only

2.11 MAX_LINE_LENGTH

max line length (for linting/reformating)
  • Default: 89

2.12 FLAKE8

flake8 binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: flake8

2.13 FLAKE8_LINT_OPTIONS

flake8 lint options
  • Default: $(MAX_LINE_LENGTH)

2.14 PYLINT

pylint binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: pylint

2.15 PYLINT_LINT_OPTIONS

pylint lint options
  • Default: pydantic,_ldap

2.16 MYPY

mypy binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: mypy

2.17 MYPY_LINT_OPTIONS

mypy lint options
  • Default: --ignore-missing-imports

2.18 BANDIT

bandit binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: bandit

2.19 BANDIT_LINT_OPTIONS

bandit lint options
  • Default: -ll -r

2.20 LINTIMPORTS

lint-imports binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: lint-imports

2.21 LINTIMPORTS_CONF_FILE

lint-imports configuration file
  • Default: $(ROOT_DIR)/.importlinter

2.22 PYTEST

pytest binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: pytest

2.23 PYTEST_CHECK_OPTIONS

pytest options (for unit testing)
  • Default: (empty)

2.24 PYTEST_COVERAGE_OPTIONS

pytest options (for coverage)
  • Default: term

2.25 TWINE

twine binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: twine

2.26 TWINE_REPOSITORY

twine repository
  • Default: (empty)

2.27 TWINE_USERNAME

twine username
  • Default: (empty)

2.28 TWINE_PASSWORD

twine password
  • Default: (empty)

2.29 TWINE_UPLOAD_EXTRA_OPTIONS

twine extra options
  • Default: (empty)

2.30 SAFETY

safety binary to use
(binary name or path) => use this binary name/path (if exists)
(empty)               => disable usage
  • Default: safety

2.31 SAFETY_ON_DEV_DEPS

if set to 1, run also safety on dev dependencies
if set to 0 (default), safety will be run only on runtime dependencies
  • Default: 0

2.32 SAFETY_CHECK_OPTIONS

safety check options
  • Default: (empty)

2.33 PIP_COMMON_OPTIONS

pip common options
  • Default: --disable-pip-version-check

2.34 PIP_INDEX_URL

pip index url
  • Default: (empty)

2.35 PIP_EXTRA_INDEX_URL

pip extra index url
  • Default: (empty)

2.36 PIP_INSTALL_OPTIONS

pip install extra options
  • Default: (empty)

2.37 PIP_TRUSTED_HOSTS

pip trusted hosts
(override it with += to add some trusted hosts)
  • Default: pypi.org files.pythonhosted.org
add a symlink of this name in the project root
(targetting the VENV_DIR)
(if empty => no symlink)
  • Default: venv

2.39 REQS_DIR

requirements dir
  • Default: $(ROOT_DIR)

2.40 REMOVE_DIST

remove "dist" directory during clean
  • Default: 1

2.41 REMOVE_BUILD

remove "build" directory during clean
  • Default: 1

2.42 APP_DIRS

python application dirs (space separated)
  • Default: (empty)

2.43 TEST_DIRS

tests application dirs (space separated)
  • Default: (empty)

2.44 EXTRA_PYTHON_FILES

extra python files to lint/reformat
(if they are outside of APP_DIRS/TEST_DIRS)
(space separated paths)
  • Default: (empty)

3. Targets ready to use

Note

You can't override these targets but you can use them!

3.1 devvenv

simple alias of devenv target
  • Dependencies: devenv

3.2 refresh_venv

Update all *requirements.txt files from *requirements-freezed.txt and pip repositories
  • Dependencies: remove_devenv remove_runenv _rm_requirements devenv

3.3 refresh

Deprecated alias of refresh_venv
  • Dependencies: refresh_venv

3.4 reformat_black

Reformat sources and tests with black

3.5 reformat_isort

Reformat sources and tests with isort

3.6 check_pytest

Check with pytest

3.7 coverage_pytest

Execute unit-tests and show coverage on console (with pytest)

4. Extendable targets

Note

You can extend these targets in your own Makefile with target_name:: syntax.

4.1 wheel

Build wheel (packaging)
  • Dependencies: devenv before_wheel

4.2 sdist

Build sdist (packaging)
  • Dependencies: devenv before_sdist

4.3 upload

Upload to Pypi
  • Dependencies: devenv sdist