22
33VENV_NAME: =.venv
44REQS_PROD: =requirements.txt
5+ SETUP_FILE: =pyproject.toml
6+ SOURCES = src
7+
58DOCKER_DEV_SERVICE: =dev
6- DOCKER_CI_TEST_SERVICE: =test
7- DOCKER_ISOLATED_SERVICE: =isolated
9+ DOCKER_DEV_NO_GCP_SERVICE: =dev_no_gcp
10+ DOCKER_PROD_SERVICE: =prod
11+ DOCKER_TEST_SERVICE: =test
812
913GCP_PROJECT: =world-fishing-827
1014GCP_DOCKER_VOLUME: =gcp
1115
12- sources = python_app_template
16+ PYTHON_VERSION: =3.12
17+ UV_VERSION := 0.10.9
18+
19+ VENV: =uv venv
20+ PIP: =uv pip
21+ PIP_COMPILE: =uv pip compile
22+
1323
14- PYTHON: =python
15- PIP: =${PYTHON} -m pip
1624
1725# ---------------------
1826# DOCKER
@@ -34,29 +42,34 @@ docker-gcp: docker-volume
3442
3543.PHONY : docker-ci-test # # Runs tests using prod image, exporting coverage.xml report.
3644docker-ci-test :
37- docker compose run --rm ${DOCKER_CI_TEST_SERVICE }
45+ docker compose run --rm ${DOCKER_TEST_SERVICE }
3846
3947.PHONY : docker-shell # # Enters to docker container shell.
4048docker-shell : docker-volume
4149 docker compose run --rm -it ${DOCKER_DEV_SERVICE}
4250
43- .PHONY : reqs # # Compiles requirements.txt with pip-tools.
51+ .PHONY : docker- reqs # # Compiles requirements.txt with pip-tools.
4452reqs :
45- docker compose run --rm ${DOCKER_ISOLATED_SERVICE } -c \
46- ' pip-compile -o ${REQS_PROD} -v'
53+ docker compose run --rm ${DOCKER_DEV_NO_GCP_SERVICE } -c \
54+ ' ${PIP_COMPILE} -o ${REQS_PROD} ${SETUP_FILE } -v'
4755
48- .PHONY : reqs-upgrade # # Upgrades requirements.txt with pip-tools.
56+ .PHONY : docker- reqs-upgrade # # Upgrades requirements.txt with pip-tools.
4957reqs-upgrade :
50- docker compose run --rm ${DOCKER_ISOLATED_SERVICE } -c \
51- ' pip-compile -o ${REQS_PROD} -U -v'
58+ docker compose run --rm ${DOCKER_DEV_NO_GCP_SERVICE } -c \
59+ ' ${PIP_COMPILE} -o ${REQS_PROD} ${SETUP_FILE } -U -v'
5260
5361# ---------------------
5462# VIRTUAL ENVIRONMENT
5563# ---------------------
5664
65+ .PHONY : uv # # Installs UV
66+ uv :
67+ curl -LsSf https://astral.sh/uv/install.sh | UV_VERSION=$(UV_VERSION ) sh
68+ uv python pin ${PYTHON_VERSION}
69+
5770.PHONY : venv # # Creates virtual environment.
5871venv :
59- ${PYTHON} -m venv ${VENV_NAME}
72+ ${VENV} ${VENV_NAME}
6073
6174.PHONY : upgrade-pip # # Upgrades pip.
6275upgrade-pip :
@@ -68,48 +81,49 @@ install-test: upgrade-pip
6881
6982.PHONY : install # # Install the package in editable mode & all dependencies for local development.
7083install : upgrade-pip
71- ${PIP} install -e .[lint,dev,build,test]
84+ ${PIP} install -e .[lint,dev,build]
85+ make install-test
7286
7387.PHONY : test # # Run all unit tests exporting coverage.xml report.
7488test :
75- ${PYTHON} -m pytest -m " not integration" --cov-report term --cov-report=xml --cov=$(sources )
89+ python -m pytest -m " not integration" --cov-report term --cov-report=xml --cov=$(SOURCES )
7690
7791# ---------------------
7892# QUALITY CHECKS
7993# ---------------------
8094
8195.PHONY : hooks # # Install and pre-commit hooks.
8296hooks :
83- ${PYTHON} -m pre_commit install --install-hooks
84- ${PYTHON} -m pre_commit install --hook-type commit-msg
97+ python -m pre_commit install --install-hooks
98+ python -m pre_commit install --hook-type commit-msg
8599
86100.PHONY : format # # Auto-format python source files according with PEP8.
87101format :
88- ${PYTHON} -m black $(sources )
89- ${PYTHON} -m ruff check --fix $(sources )
90- ${PYTHON} -m ruff format $(sources )
102+ python -m black $(SOURCES )
103+ python -m ruff check --fix $(SOURCES )
104+ python -m ruff format $(SOURCES )
91105
92106.PHONY : lint # # Lint python source files.
93107lint :
94- ${PYTHON} -m ruff check $(sources )
95- ${PYTHON} -m ruff format --check $(sources )
96- ${PYTHON} -m black $(sources ) --check --diff
108+ python -m ruff check $(SOURCES )
109+ python -m ruff format --check $(SOURCES )
110+ python -m black $(SOURCES ) --check --diff
97111
98112.PHONY : codespell # # Use Codespell to do spell checking.
99113codespell :
100- ${PYTHON} -m codespell
114+ python -m codespell
101115
102116.PHONY : typecheck # # Perform type-checking.
103117typecheck :
104- ${PYTHON} -m mypy
118+ python -m mypy
105119
106120.PHONY : audit # # Use pip-audit to scan for known vulnerabilities.
107121audit :
108- ${PYTHON} -m pip_audit .
122+ python -m pip_audit .
109123
110124.PHONY : pre-commit # # Run all pre-commit hooks.
111125pre-commit :
112- ${PYTHON} -m pre_commit run --all-files
126+ python -m pre_commit run --all-files
113127
114128.PHONY : all # # Run the standard set of checks performed in CI.
115129all : lint codespell typecheck audit test
@@ -121,7 +135,7 @@ all: lint codespell typecheck audit test
121135
122136.PHONY : build # # Build a source distribution and a wheel distribution.
123137build : all clean
124- ${PYTHON} -m build
138+ python -m build
125139
126140.PHONY : publish # # Publish the distribution to PyPI.
127141publish : build
0 commit comments