Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Required executables
  2. ifeq (, $(shell which python3))
  3. $(error "No python3 on PATH.")
  4. endif
  5. ifeq (, $(shell which pipenv))
  6. $(error "No pipenv on PATH.")
  7. endif
  8. # Suppress warning if pipenv is started inside .venv
  9. export PIPENV_VERBOSITY = 1
  10. # Use relative .venv folder instead of home-folder based
  11. export PIPENV_VENV_IN_PROJECT = 1
  12. # Ignore existing venvs
  13. export PIPENV_IGNORE_VIRTUALENVS = 1
  14. # Make sure we are running with an explicit encoding
  15. export LC_ALL = C
  16. export LANG = C.UTF-8
  17. # Set configuration folder to venv
  18. export PYPE_CONFIG_FOLDER = $(shell pwd)/.venv/.pype-cli
  19. # Process variables
  20. VERSION = $(shell python3 setup.py --version)
  21. PY_FILES := setup.py my_module tests
  22. all: clean venv build
  23. venv: clean
  24. @echo Initialize virtualenv, i.e., install required packages etc.
  25. pipenv --three install --dev
  26. shell:
  27. @echo Initialize virtualenv and open a new shell using it
  28. pipenv shell
  29. clean:
  30. @echo Clean project base
  31. find . -type d \
  32. -name ".venv" -o \
  33. -name ".tox" -o \
  34. -name ".ropeproject" -o \
  35. -name ".mypy_cache" -o \
  36. -name ".pytest_cache" -o \
  37. -name "__pycache__" -o \
  38. -iname "*.egg-info" -o \
  39. -name "build" -o \
  40. -name "dist" \
  41. |xargs rm -rfv
  42. find . -type f \
  43. -name "pyproject.toml" -o \
  44. -name "Pipfile.lock" \
  45. |xargs rm -rfv
  46. test:
  47. @echo Run all tests in default virtualenv
  48. pipenv run py.test tests
  49. testall:
  50. @echo Run all tests against all virtualenvs defined in tox.ini
  51. pipenv run tox -c setup.cfg tests
  52. isort:
  53. @echo Check for incorrectly sorted imports
  54. pipenv run isort --check-only $(PY_FILES)
  55. isort-apply:
  56. @echo Check for incorrectly sorted imports
  57. pipenv run isort $(PY_FILES)
  58. mypy:
  59. @echo Run static code checks against source code base
  60. pipenv run mypy my_module
  61. pipenv run mypy tests
  62. lint:
  63. @echo Run code formatting checks against source code base
  64. pipenv run flake8 my_module tests
  65. build: test mypy isort lint
  66. @echo Run setup.py-based build process to package application
  67. pipenv run python setup.py bdist_wheel
  68. publish: all
  69. @echo Release to pypi.org and create git tag
  70. pipenv run twine upload dist/*
  71. git tag -a $(VERSION) -m "Version $(VERSION)"
  72. git push --tags
  73. run:
  74. @echo Execute my_module directly
  75. pipenv run python -m my_module
  76. fetch-latest-boilerplate:
  77. @echo Fetch latest python3-boilerplate version from github
  78. git remote add py3template git@github.com:BastiTee/python3-boilerplate.git \
  79. ||true
  80. git pull py3template master --allow-unrelated-histories ||true
  81. @echo ----------------------------------------------------
  82. @echo Resolve all merge conflicts and commit your changes!
  83. @echo ----------------------------------------------------