-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (100 loc) · 3.56 KB
/
Makefile
File metadata and controls
119 lines (100 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Load environment variables from .env file
ifneq (,$(wildcard .env))
include .env
export
endif
.PHONY: check-types check-all install-dev clean setup install run versions version help release build-package update-version publish-package verify-package
# Python version to use
PYTHON_VERSION := 3.11.2
# Source files
PYTHON_FILES := sonos_lastfm.py utils.py
# Install development dependencies
install-dev:
uv pip install build mypy ruff setuptools wheel types-setuptools
# Check types with mypy
check-types:
mypy --strict --python-version=3.12 $(PYTHON_FILES)
# Run ruff type checking and linting
check-ruff:
ruff check --select=ALL --target-version=py312 $(PYTHON_FILES)
# Run all checks
check-all: check-types check-ruff
# Clean up cache directories and build artifacts
clean:
rm -rf .mypy_cache .ruff_cache __pycache__ */__pycache__ .venv dist build *.egg-info
# Setup Python environment
setup:
@echo "Setting up Python environment..."
uv venv
@echo "Python environment setup complete. Run 'make install' to install dependencies."
# Install dependencies
install:
@echo "Installing dependencies..."
uv pip install -r requirements.txt
uv pip install -e .
@echo "Dependencies installed successfully."
# Run the scrobbler
run:
@echo "Running Sonos Last.fm scrobbler..."
uv run -m sonos_lastfm
# Show available Python versions
versions:
@echo "Available Python versions:"
uv python list
# Show current Python version
version:
@echo "Current Python version:"
uv python --version
# Update version in all files
update-version:
@if [ -z "$(NEW_VERSION)" ]; then \
echo "Error: NEW_VERSION is not set"; \
exit 1; \
fi
@echo "Updating version to $(NEW_VERSION)"
@sed -i '' "s/version = \"[0-9.]*\"/version = \"$(NEW_VERSION)\"/" pyproject.toml
@sed -i '' "s/__version__ = \"[0-9.]*\"/__version__ = \"$(NEW_VERSION)\"/" src/sonos_lastfm/__init__.py
# Build Python package
build-package:
@echo "Building package..."
uv pip install build
uv run --with build python -m build --wheel --sdist
# Publish package to PyPI
publish-package:
@echo "Publishing to PyPI..."
@if [ -z "$(PYPI_TOKEN)" ]; then \
echo "Error: PYPI_TOKEN not found in .env file"; \
exit 1; \
fi
uv publish --token $(PYPI_TOKEN)
# Verify package installation
verify-package:
@echo "Verifying package installation..."
uv run --with sonos-lastfm --no-project -- python -c "import sonos_lastfm"
# Full release process
release:
@echo "Starting release process..."
@echo "Current version: $$(grep -o 'version = "[0-9.]*"' pyproject.toml | cut -d'"' -f2)"
@read -p "Enter new version: " version; \
make clean && \
make update-version NEW_VERSION=$$version && \
make build-package && \
make publish-package && \
make verify-package && \
echo "Release v$$version completed successfully!"
# Help
help:
@echo "Available commands:"
@echo " make setup - Set up Python environment with uv"
@echo " make install - Install project dependencies"
@echo " make install-dev - Install development dependencies"
@echo " make check-types - Run mypy type checker"
@echo " make check-ruff - Run ruff linter"
@echo " make check-all - Run all checks"
@echo " make clean - Clean up generated files"
@echo " make run - Run the scrobbler"
@echo " make versions - Show available Python versions"
@echo " make version - Show current Python version"
@echo " make release - Full release process (clean, version, build, check, commit, tag, publish)"
@echo " make verify-package - Verify package installation"
@echo " make help - Show this help message"