diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 46 |
1 files changed, 25 insertions, 21 deletions
@@ -8,15 +8,14 @@ # Variables SYSTEM_PYTHON := python3 +PIP_COMPILE ?= pip-compile +PIP_SYNC ?= pip-sync LANG_CODE ?= es -VENV_DIR := venv PROJECT_NAME := yt-local -# Use venv python/pip when the venv exists, system otherwise -VENV_PYTHON := $(VENV_DIR)/bin/python -VENV_PIP := $(VENV_DIR)/bin/pip +# Prefer venv python, fall back to system +VENV_PYTHON := venv/bin/python PYTHON = $(if $(wildcard $(VENV_PYTHON)),$(VENV_PYTHON),$(SYSTEM_PYTHON)) -PIP = $(if $(wildcard $(VENV_PIP)),$(VENV_PIP),$(SYSTEM_PYTHON) -m pip) # Patterns for release artefacts (generate_release.py) RELEASE_DIR := yt-local @@ -45,30 +44,35 @@ help: ## Show this help message ## Venv bootstrap (internal) -------------------------------------------------- +PIPTOOLS_COMPILE = $(VENV_PYTHON) -m piptools compile --generate-hashes + ensure-venv: @if [ ! -f "$(VENV_PYTHON)" ]; then \ - echo "[INFO] Creating virtual environment in $(VENV_DIR)..."; \ - $(SYSTEM_PYTHON) -m venv $(VENV_DIR); \ - if [ -f requirements-dev.txt ]; then \ - echo "[INFO] Installing dependencies (dev)..."; \ - $(VENV_DIR)/bin/pip install -r requirements-dev.txt; \ - else \ - echo "[INFO] Installing dependencies..."; \ - $(VENV_DIR)/bin/pip install -r requirements.txt; \ - fi; \ - echo "[SUCCESS] Virtual environment ready"; \ + echo "[INFO] Creating virtual environment..."; \ + $(SYSTEM_PYTHON) -m venv venv; \ + echo "[INFO] Installing pip-tools..."; \ + $(VENV_PYTHON) -m pip install --upgrade pip setuptools wheel pip-tools; \ fi +## Lock files ----------------------------------------------------------------- + +lock: ensure-venv ## Compile pinned lock files from pyproject.toml + @echo "[INFO] Compiling requirements.lock..." + $(PIPTOOLS_COMPILE) pyproject.toml -o requirements.lock + @echo "[INFO] Compiling requirements-dev.lock..." + $(PIPTOOLS_COMPILE) --extra dev pyproject.toml -o requirements-dev.lock + @echo "[SUCCESS] Lock files updated" + ## Installation and Setup ----------------------------------------------------- -install: ensure-venv ## Install/update project dependencies +install: ensure-venv lock ## Install/update project dependencies @echo "[INFO] Installing dependencies..." - $(PIP) install -r requirements.txt + $(VENV_PYTHON) -m piptools sync requirements.lock @echo "[SUCCESS] Dependencies installed" -setup-dev: ensure-venv ## Install dev dependencies (tests, linting) +setup-dev: ensure-venv lock ## Install dev dependencies (tests, linting) @echo "[INFO] Installing dev dependencies..." - $(PIP) install -r requirements-dev.txt + $(VENV_PYTHON) -m piptools sync requirements-dev.lock @echo "[SUCCESS] Dev dependencies installed" ## Development ---------------------------------------------------------------- @@ -248,7 +252,7 @@ clean: ## Clean temporary files, caches, and release artefacts distclean: clean ## Clean everything including venv @echo "[INFO] Cleaning everything..." - rm -rf $(VENV_DIR) + rm -rf venv requirements.lock requirements-dev.lock @echo "[SUCCESS] Complete cleanup done" ## Project Information -------------------------------------------------------- @@ -258,7 +262,7 @@ info: ensure-venv ## Show project information @echo "" @echo " [INFO] Directory: $$(pwd)" @echo " [INFO] Python: $$($(PYTHON) --version 2>&1)" - @echo " [INFO] Pip: $$($(PIP) --version 2>&1 | cut -d' ' -f1-2)" + @echo " [INFO] pip: $$($(PYTHON) -m pip --version 2>&1)" @echo "" @echo " [INFO] Configured languages:" @for lang_dir in translations/*/; do \ |
