Fix issues related to venv
This commit is contained in:
96
Makefile
96
Makefile
@@ -1,21 +1,25 @@
|
|||||||
# LetzShop API Makefile (Windows Compatible)
|
# Multitenant ecommerce application Makefile (Windows Compatible)
|
||||||
.PHONY: install install-dev install-docs install-all dev test test-coverage lint format check docker-build docker-up docker-down clean help
|
.PHONY: install install-dev install-docs install-all dev test test-coverage lint format check docker-build docker-up docker-down clean help
|
||||||
|
|
||||||
|
# Detect if we're in a virtual environment and set Python path accordingly
|
||||||
|
PYTHON := python
|
||||||
|
PIP := pip
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# INSTALLATION & SETUP
|
# INSTALLATION & SETUP
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
install:
|
install:
|
||||||
pip install -r requirements.txt
|
$(PIP) install -r requirements.txt
|
||||||
|
|
||||||
install-dev: install
|
install-dev: install
|
||||||
pip install -r requirements-dev.txt
|
$(PIP) install -r requirements-dev.txt
|
||||||
|
|
||||||
install-test:
|
install-test:
|
||||||
pip install -r requirements-test.txt
|
$(PIP) install -r requirements-test.txt
|
||||||
|
|
||||||
install-docs:
|
install-docs:
|
||||||
pip install -r requirements-docs.txt
|
$(PIP) install -r requirements-docs.txt
|
||||||
|
|
||||||
install-all: install install-dev install-test install-docs
|
install-all: install install-dev install-test install-docs
|
||||||
|
|
||||||
@@ -28,13 +32,13 @@ setup: install-all migrate-up
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
$(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||||
|
|
||||||
dev-with-docs:
|
dev-with-docs:
|
||||||
@echo Starting API and documentation servers...
|
@echo Starting API and documentation servers...
|
||||||
@start /B uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
@start /B $(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||||
@timeout /t 3 >nul
|
@timeout /t 3 >nul
|
||||||
@mkdocs serve --dev-addr=0.0.0.0:8001
|
@$(PYTHON) -m mkdocs serve --dev-addr=0.0.0.0:8001
|
||||||
|
|
||||||
dev-full: dev-with-docs
|
dev-full: dev-with-docs
|
||||||
@echo Development environment ready!
|
@echo Development environment ready!
|
||||||
@@ -47,63 +51,62 @@ dev-full: dev-with-docs
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
migrate-create:
|
migrate-create:
|
||||||
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create message="your_description") else (alembic revision --autogenerate -m "$(message)")
|
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create message="your_description") else ($(PYTHON) -m alembic revision --autogenerate -m "$(message)")
|
||||||
|
|
||||||
migrate-create-manual:
|
migrate-create-manual:
|
||||||
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create-manual message="your_description") else (alembic revision -m "$(message)")
|
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create-manual message="your_description") else ($(PYTHON) -m alembic revision -m "$(message)")
|
||||||
|
|
||||||
migrate-up:
|
migrate-up:
|
||||||
@echo Running database migrations...
|
@echo Running database migrations...
|
||||||
alembic upgrade head
|
$(PYTHON) -m alembic upgrade head
|
||||||
@echo Migrations completed successfully
|
@echo Migrations completed successfully
|
||||||
|
|
||||||
migrate-down:
|
migrate-down:
|
||||||
@echo Rolling back last migration...
|
@echo Rolling back last migration...
|
||||||
alembic downgrade -1
|
$(PYTHON) -m alembic downgrade -1
|
||||||
@echo Rollback completed
|
@echo Rollback completed
|
||||||
|
|
||||||
migrate-status:
|
migrate-status:
|
||||||
@echo Current migration status:
|
@echo Current migration status:
|
||||||
alembic current
|
$(PYTHON) -m alembic current
|
||||||
@echo.
|
@echo.
|
||||||
@echo Migration history:
|
@echo Migration history:
|
||||||
alembic history --verbose
|
$(PYTHON) -m alembic history --verbose
|
||||||
|
|
||||||
backup-db:
|
backup-db:
|
||||||
@echo Creating database backup...
|
@echo Creating database backup...
|
||||||
@python scripts/backup_database.py
|
@$(PYTHON) scripts/backup_database.py
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# TESTING
|
# TESTING
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
test:
|
test:
|
||||||
pytest tests/ -v
|
$(PYTHON) -m pytest tests/ -v
|
||||||
|
|
||||||
test-unit:
|
test-unit:
|
||||||
pytest tests/ -v -m unit
|
$(PYTHON) -m pytest tests/ -v -m unit
|
||||||
|
|
||||||
test-integration:
|
test-integration:
|
||||||
pytest tests/ -v -m integration
|
$(PYTHON) -m pytest tests/ -v -m integration
|
||||||
|
|
||||||
test-coverage:
|
test-coverage:
|
||||||
pytest tests/ --cov=app --cov=models --cov=utils --cov=middleware --cov-report=html --cov-report=term-missing
|
$(PYTHON) -m pytest tests/ --cov=app --cov=models --cov=utils --cov=middleware --cov-report=html --cov-report=term-missing
|
||||||
|
|
||||||
test-fast:
|
test-fast:
|
||||||
pytest tests/ -v -m "not slow"
|
$(PYTHON) -m pytest tests/ -v -m "not slow"
|
||||||
|
|
||||||
# Run slow tests only
|
|
||||||
test-slow:
|
test-slow:
|
||||||
pytest tests/ -v -m slow
|
$(PYTHON) -m pytest tests/ -v -m slow
|
||||||
|
|
||||||
test-auth:
|
test-auth:
|
||||||
pytest tests/test_auth.py -v
|
$(PYTHON) -m pytest tests/test_auth.py -v
|
||||||
|
|
||||||
test-products:
|
test-products:
|
||||||
pytest tests/test_products.py -v
|
$(PYTHON) -m pytest tests/test_products.py -v
|
||||||
|
|
||||||
test-inventory:
|
test-inventory:
|
||||||
pytest tests/test_inventory.py -v
|
$(PYTHON) -m pytest tests/test_inventory.py -v
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# CODE QUALITY
|
# CODE QUALITY
|
||||||
@@ -111,14 +114,20 @@ test-inventory:
|
|||||||
|
|
||||||
format:
|
format:
|
||||||
@echo Running black...
|
@echo Running black...
|
||||||
black . --exclude venv
|
$(PYTHON) -m black . --exclude venv
|
||||||
@echo Running isort...
|
@echo Running isort...
|
||||||
isort . --skip venv
|
$(PYTHON) -m isort . --skip venv
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@echo Running linting...
|
@echo Running linting...
|
||||||
flake8 . --max-line-length=120 --extend-ignore=E203,W503,I201,I100 --exclude=venv,__pycache__,.git
|
$(PYTHON) -m ruff check . --exclude venv
|
||||||
mypy . --ignore-missing-imports --exclude venv
|
$(PYTHON) -m mypy . --ignore-missing-imports --exclude venv
|
||||||
|
|
||||||
|
# Alternative lint if still using flake8
|
||||||
|
lint-flake8:
|
||||||
|
@echo Running linting...
|
||||||
|
$(PYTHON) -m flake8 . --max-line-length=120 --extend-ignore=E203,W503,I201,I100 --exclude=venv,__pycache__,.git
|
||||||
|
$(PYTHON) -m mypy . --ignore-missing-imports --exclude venv
|
||||||
|
|
||||||
# Combined format and lint
|
# Combined format and lint
|
||||||
check: format lint
|
check: format lint
|
||||||
@@ -136,15 +145,15 @@ qa: format lint test-coverage docs-check
|
|||||||
|
|
||||||
docs-serve:
|
docs-serve:
|
||||||
@echo Starting documentation server...
|
@echo Starting documentation server...
|
||||||
mkdocs serve --dev-addr=0.0.0.0:8001
|
$(PYTHON) -m mkdocs serve --dev-addr=0.0.0.0:8001
|
||||||
|
|
||||||
docs-build:
|
docs-build:
|
||||||
@echo Building documentation...
|
@echo Building documentation...
|
||||||
mkdocs build --clean --strict
|
$(PYTHON) -m mkdocs build --clean --strict
|
||||||
|
|
||||||
docs-deploy:
|
docs-deploy:
|
||||||
@echo Deploying documentation...
|
@echo Deploying documentation...
|
||||||
mkdocs gh-deploy --clean
|
$(PYTHON) -m mkdocs gh-deploy --clean
|
||||||
|
|
||||||
docs-clean:
|
docs-clean:
|
||||||
@if exist site rmdir /s /q site
|
@if exist site rmdir /s /q site
|
||||||
@@ -152,7 +161,7 @@ docs-clean:
|
|||||||
|
|
||||||
docs-check:
|
docs-check:
|
||||||
@echo Checking documentation for issues...
|
@echo Checking documentation for issues...
|
||||||
mkdocs build --strict --verbose
|
$(PYTHON) -m mkdocs build --strict --verbose
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# DOCKER
|
# DOCKER
|
||||||
@@ -193,7 +202,22 @@ clean:
|
|||||||
|
|
||||||
verify-setup:
|
verify-setup:
|
||||||
@echo Running setup verification...
|
@echo Running setup verification...
|
||||||
@python scripts/verify_setup.py
|
@$(PYTHON) scripts/verify_setup.py
|
||||||
|
|
||||||
|
# Check Python and virtual environment
|
||||||
|
check-env:
|
||||||
|
@echo Checking Python environment...
|
||||||
|
@echo Python version:
|
||||||
|
@$(PYTHON) --version
|
||||||
|
@echo.
|
||||||
|
@echo Python location:
|
||||||
|
@where $(PYTHON)
|
||||||
|
@echo.
|
||||||
|
@echo Virtual environment active:
|
||||||
|
@$(PYTHON) -c "import sys; print('YES' if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix) else 'NO')"
|
||||||
|
@echo.
|
||||||
|
@echo Python executable:
|
||||||
|
@$(PYTHON) -c "import sys; print(sys.executable)"
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# HELP
|
# HELP
|
||||||
@@ -227,7 +251,8 @@ help:
|
|||||||
@echo.
|
@echo.
|
||||||
@echo === CODE QUALITY ===
|
@echo === CODE QUALITY ===
|
||||||
@echo format - Format code (black + isort)
|
@echo format - Format code (black + isort)
|
||||||
@echo lint - Run linting (flake8 + mypy)
|
@echo lint - Run linting (ruff + mypy)
|
||||||
|
@echo lint-flake8 - Run linting (flake8 + mypy - alternative)
|
||||||
@echo check - Format + lint
|
@echo check - Format + lint
|
||||||
@echo ci - Full CI pipeline
|
@echo ci - Full CI pipeline
|
||||||
@echo qa - Quality assurance (format, lint, test, docs check)
|
@echo qa - Quality assurance (format, lint, test, docs check)
|
||||||
@@ -249,6 +274,7 @@ help:
|
|||||||
@echo === UTILITIES ===
|
@echo === UTILITIES ===
|
||||||
@echo clean - Clean build artifacts
|
@echo clean - Clean build artifacts
|
||||||
@echo verify-setup - Verify project setup
|
@echo verify-setup - Verify project setup
|
||||||
|
@echo check-env - Check Python and virtual environment
|
||||||
@echo.
|
@echo.
|
||||||
@echo === DAILY WORKFLOW ===
|
@echo === DAILY WORKFLOW ===
|
||||||
@echo make dev # Start development
|
@echo make dev # Start development
|
||||||
|
|||||||
Reference in New Issue
Block a user