Skip to content

Commit 9b6f6f5

Browse files
authored
Replace pip and pyenv with uv (#21)
1 parent 0fecf02 commit 9b6f6f5

28 files changed

+620
-289
lines changed

.github/workflows/test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919

2020
steps:
2121
- name: Checkout repository
22-
uses: actions/checkout@v5
22+
uses: actions/checkout@v6
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v7
2326

2427
- name: Set up Python
2528
uses: actions/setup-python@v6
@@ -32,7 +35,7 @@ jobs:
3235
sudo chmod +x /usr/local/bin/yq
3336
3437
- name: Install cookiecutter
35-
run: pip install cookiecutter
38+
run: uv pip install --system cookiecutter
3639

3740
- name: Run cookiecutter template
3841
run: |

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ Since this is a Cookiecutter template you should expect to encounter Jinja2 temp
77
When being asked to test functionality that requires you to create a new project from the template create them in the `workspaces` directory.
88

99
When creating new files for optional services make sure you include them in the post_gen_project.py configuration so that unneeded files are removed. For example, if the caching functionality is not enabled the system should remove all of the caching related files.
10+
11+
## Key Technologies
12+
13+
This template uses **uv** for Python version management and package installation instead of pyenv and pip. uv provides 10-100x faster installations and automatically handles Python version downloads. All makefiles, dockerfiles, and CI workflows use uv.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Transform any Python idea into a production-ready project in minutes. This Cooki
1313
- **AI Ready**: Pre-configured AGENTS.md file following the open standard compatible with Cursor, Aider, GitHub Copilot, and other AI coding assistants
1414
- **Incredibly Flexible**: Mix and match features to create exactly what you need, from simple libraries to full web applications with automatic cleanup of unused code
1515
- **Modern Python Standards**: Python 3.10+ with async/await support, type hints, contemporary best practices, and pyproject.toml configuration
16+
- **Zero Manual Setup**: UV automatically downloads and installs the correct Python version - no need for pyenv or manual Python installation
1617

1718
## Quick Start
1819

@@ -34,7 +35,8 @@ Every project created with this template includes these essential components:
3435

3536
- **[Makefile](https://www.gnu.org/software/make/manual/html_node/Introduction.html) automation**: Powerful task automation covering setup, testing, formatting, linting, and deployment with simple commands like `make install`, `make test`, and `make publish`
3637
- **Modern pyproject.toml**: Centralized project configuration using the modern Python standard, eliminating legacy setup.py files and consolidating all metadata, dependencies, and tool settings in one place
37-
- **Virtual environment management**: Seamless virtual environment creation and activation with automatic [pyenv](https://github.com/pyenv/pyenv) integration for managing Python versions across development teams
38+
- **[uv](https://docs.astral.sh/uv/)**: Lightning-fast Python package installer and virtual environment manager written in Rust, providing 10-100x faster installations than pip with automatic Python version management
39+
- **Virtual environment management**: Seamless virtual environment creation using uv, automatically installing the correct Python version from `.python-version` and managing dependencies efficiently
3840
- **[Pre-commit](https://pre-commit.com/) hooks**: Automated code quality checks that run before every commit, catching formatting issues, security vulnerabilities, and common mistakes before they enter your repository
3941

4042
### Code Quality

hooks/post_gen_project.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
remove_paths.add(f'docs/dev/github.md')
9797

9898
if not INCLUDE_REQUIREMENTS_FILES:
99-
remove_paths.add('.github/workflows/lockfiles.yaml')
10099
remove_paths.add(f'docs/dev/dependencies.md')
101100

102101
if not INCLUDE_AGENT_INSTRUCTIONS:
@@ -132,6 +131,5 @@ def run_command(command):
132131

133132

134133
run_command('make all')
135-
if INCLUDE_REQUIREMENTS_FILES:
136-
run_command('make dependencies')
134+
run_command('make lock')
137135
run_command('make chores')

hooks/pre_gen_project.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import shutil
23
import sys
34

45
MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$"
@@ -7,6 +8,27 @@
78

89
if not re.match(MODULE_REGEX, module_name):
910
print("ERROR: %s is not a valid Python module name!" % module_name)
10-
1111
# exits with status 1 to indicate failure
1212
sys.exit(1)
13+
14+
# Check if UV is installed
15+
if not shutil.which("uv"):
16+
print("\n" + "=" * 80)
17+
print("ERROR: UV is not installed!")
18+
print("=" * 80)
19+
print("\nThis template requires UV for Python package management.")
20+
print("\nTo install UV, run one of the following commands:")
21+
print("\n # On macOS and Linux:")
22+
print(" curl -LsSf https://astral.sh/uv/install.sh | sh")
23+
print("\n # Using pip:")
24+
print(" pip install uv")
25+
print("\n # Using pipx:")
26+
print(" pipx install uv")
27+
print("\n # Using Homebrew:")
28+
print(" brew install uv")
29+
print("\nFor more installation options, visit: https://docs.astral.sh/uv/getting-started/installation/")
30+
print("\nAfter installing UV, you can regenerate this project using cookiecutter's replay feature:")
31+
print(" cookiecutter --replay gh:tedivm/robs_awesome_python_template")
32+
print("\nOr run the original cookiecutter command again.")
33+
print("=" * 80 + "\n")
34+
sys.exit(1)

{{cookiecutter.__package_slug}}/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
!/pyproject.toml
1313
!/README.md
1414
!/setup.*
15-
!/requirements*
15+
!/uv.lock

{{cookiecutter.__package_slug}}/.github/dependabot.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,37 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "weekly"
8+
cooldown:
9+
default-days: 7
10+
open-pull-requests-limit: 5
11+
rebase-strategy: auto
12+
groups:
13+
github-actions:
14+
patterns:
15+
- "*"
16+
17+
- package-ecosystem: "pip"
18+
directory: "/"
19+
schedule:
20+
interval: "weekly"
21+
cooldown:
22+
default-days: 7
23+
open-pull-requests-limit: 5
24+
rebase-strategy: auto
25+
groups:
26+
python-dependencies:
27+
patterns:
28+
- "*"
29+
30+
- package-ecosystem: "uv"
31+
directory: "/"
32+
schedule:
33+
interval: "weekly"
34+
cooldown:
35+
default-days: 7
36+
open-pull-requests-limit: 5
37+
rebase-strategy: auto
38+
groups:
39+
uv-dependencies:
40+
patterns:
41+
- "*"

{{cookiecutter.__package_slug}}/.github/workflows/alembic.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ jobs:
88
alembic:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
12+
13+
{%- raw %}
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v7
1216

1317
- uses: actions/setup-python@v6
1418
with:
@@ -19,3 +23,4 @@ jobs:
1923

2024
- name: Check for Un-Generated Migrations
2125
run: make check_ungenerated_migrations
26+
{%- endraw %}

{{cookiecutter.__package_slug}}/.github/workflows/black.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ jobs:
88
black:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
12+
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v7
1215

1316
- uses: actions/setup-python@v6
1417
with:

{{cookiecutter.__package_slug}}/.github/workflows/dapperdata.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ jobs:
88
dapperdata:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
12+
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v7
1215

1316
- uses: actions/setup-python@v6
1417
with:

0 commit comments

Comments
 (0)