Skip to content

Commit dcddb9d

Browse files
Merge pull request #66 from Promptly-Technologies-LLC/64-switch-from-poetry-to-uv
Migrate from poetry to uv for dependency management
2 parents fea83dd + fa3fd95 commit dcddb9d

19 files changed

+2174
-3185
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
python-version: ["3.12"]
15-
poetry-version: [latest]
1615
os: [ubuntu-latest]
1716

1817
runs-on: ${{ matrix.os }}
@@ -35,15 +34,16 @@ jobs:
3534
steps:
3635
- uses: actions/checkout@v4
3736

38-
- uses: actions/setup-python@v5
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v4
39+
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
3942
with:
4043
python-version: ${{ matrix.python-version }}
4144

42-
- name: Install and configure Poetry
43-
uses: snok/install-poetry@v1
44-
4545
- name: Install project
46-
run: poetry install
46+
run: uv sync --all-extras --dev
4747

4848
- name: Set env variables for pytest
4949
run: |
@@ -68,7 +68,7 @@ jobs:
6868
[ -n "$RESEND_API_KEY" ]
6969
7070
- name: Run type checking with mypy
71-
run: poetry run mypy .
71+
run: uv run mypy .
7272

7373
- name: Run tests with pytest
74-
run: poetry run pytest -s tests/
74+
run: uv run pytest tests/

README.md

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ to deploy to any major cloud hosting platform.
5555

5656
**Additional technologies:**
5757

58-
- [Poetry](https://python-poetry.org/): Python dependency manager
58+
- [uv](https://docs.astral.sh/uv/): Python dependency manager
5959
- [Pytest](https://docs.pytest.org/en/7.4.x/): testing framework
6060
- [Docker](https://www.docker.com/): development containerization
6161
- [Github Actions](https://docs.github.com/en/actions): CI/CD pipeline
@@ -72,56 +72,73 @@ to deploy to any major cloud hosting platform.
7272
For comprehensive installation instructions, see the [installation
7373
page](https://promptlytechnologies.com/fastapi-jinja2-postgres-webapp/docs/installation.html).
7474

75-
### Python and Docker
75+
### uv
7676

77-
- [Python 3.12 or higher](https://www.python.org/downloads/)
78-
- [Docker and Docker Compose](https://docs.docker.com/get-docker/)
77+
MacOS and Linux:
7978

80-
### PostgreSQL headers
79+
``` bash
80+
wget -qO- https://astral.sh/uv/install.sh | sh
81+
```
8182

82-
For Ubuntu/Debian:
83+
Windows:
8384

8485
``` bash
85-
sudo apt update && sudo apt install -y python3-dev libpq-dev
86+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
8687
```
8788

88-
For macOS:
89+
See the [uv installation
90+
docs](https://docs.astral.sh/uv/getting-started/installation/) for more
91+
information.
92+
93+
### Python
94+
95+
Install Python 3.12 or higher from either the official [downloads
96+
page](https://www.python.org/downloads/) or using uv:
8997

9098
``` bash
91-
brew install postgresql
99+
# Installs the latest version
100+
uv python install
92101
```
93102

94-
For Windows:
103+
### Docker and Docker Compose
95104

96-
- No installation required
105+
Install Docker Desktop and Coker Compose for your operating system by
106+
following the [instructions in the
107+
documentation](https://docs.docker.com/compose/install/).
97108

98-
### Python dependencies
109+
### PostgreSQL headers
99110

100-
1. Install Poetry
111+
For Ubuntu/Debian:
101112

102113
``` bash
103-
pipx install poetry
114+
sudo apt update && sudo apt install -y python3-dev libpq-dev
104115
```
105116

106-
2. Install project dependencies
117+
For macOS:
107118

108119
``` bash
109-
poetry install
120+
brew install postgresql
110121
```
111122

112-
3. Activate shell
123+
For Windows:
124+
125+
- No installation required
126+
127+
### Python dependencies
128+
129+
From the root directory, run:
113130

114131
``` bash
115-
poetry shell
132+
uv venv
133+
uv sync
116134
```
117135

118-
(Note: You will need to activate the shell every time you open a new
119-
terminal session. Alternatively, you can use the `poetry run` prefix
120-
before other commands to run them without activating the shell.)
136+
This will create an in-project virtual environment and install all
137+
dependencies.
121138

122139
### Set environment variables
123140

124-
Copy .env.example to .env with `cp .env.example .env`.
141+
Copy `.env.example` to `.env` with `cp .env.example .env`.
125142

126143
Generate a 256 bit secret key with `openssl rand -base64 32` and paste
127144
it into the .env file.
@@ -134,6 +151,9 @@ account, verify a domain, get an API key, and paste the API key into the
134151

135152
### Start development database
136153

154+
To start the development database, run the following command in your
155+
terminal from the root directory:
156+
137157
``` bash
138158
docker compose up -d
139159
```
@@ -155,14 +175,31 @@ Navigate to http://localhost:8000/
155175
mypy .
156176
```
157177

158-
### Contributing
178+
## Developing with LLMs
179+
180+
In line with the [llms.txt standard](https://llmstxt.org/), we have
181+
provided a Markdown-formatted prompt—designed to help LLM agents
182+
understand how to work with this template—as a text file:
183+
[llms.txt](docs/static/llms.txt).
184+
185+
One use case for this file, if using the Cursor IDE, is to rename it to
186+
`.cursorrules` and place it in your project directory (see the [Cursor
187+
docs](https://docs.cursor.com/context/rules-for-ai) on this for more
188+
information). Alternatively, you could use it as a custom system prompt
189+
in the web interface for ChatGPT, Claude, or the LLM of your choice.
190+
191+
We have also exposed the full Markdown-formatted project documentation
192+
as a [single text file](docs/static/documentation.txt) for easy
193+
downloading and embedding for RAG workflows.
194+
195+
## Contributing
159196

160197
Your contributions are welcome! See the [issues
161198
page](https://github.com/promptly-technologies-llc/fastapi-jinja2-postgres-webapp/issues)
162199
for ideas. Fork the repository, create a new branch, make your changes,
163200
and submit a pull request.
164201

165-
### License
202+
## License
166203

167204
This project is created and maintained by [Promptly Technologies,
168205
LLC](https://promptlytechnologies.com/) and licensed under the MIT

docs/customization.qmd

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ title: "Customization"
44

55
## Development workflow
66

7-
### Dependency management with Poetry
7+
### Dependency management with `uv`
88

9-
The project uses Poetry to manage dependencies:
9+
The project uses `uv` to manage dependencies:
1010

11-
- Add new dependency: `poetry add <dependency>`
12-
- Add development dependency: `poetry add --dev <dependency>`
13-
- Remove dependency: `poetry remove <dependency>`
14-
- Update lock file: `poetry lock`
15-
- Install dependencies: `poetry install`
16-
- Update all dependencies: `poetry update`
11+
- Add new dependency: `uv add <dependency>`
12+
- Add development dependency: `uv add --dev <dependency>`
13+
- Remove dependency: `uv remove <dependency>`
14+
- Update lock file: `uv lock`
15+
- Install all dependencies: `uv sync`
16+
- Install only production dependencies: `uv sync --no-dev`
17+
- Upgrade dependencies: `uv lock --upgrade`
1718

18-
If you are using VSCode or Cursor as your IDE, you will need to select the Poetry-managed Python version as your interpreter for the project. To find the location of the Poetry-managed Python interpreter, run `poetry env info` and look for the `Path` field. Then, in VSCode, go to `View > Command Palette`, search for `Python: Select Interpreter`, and either select Poetry's Python version from the list (if it has been auto-detected) or "Enter interpreter path" manually.
19+
### IDE configuration
20+
21+
If you are using VSCode or Cursor as your IDE, you will need to select the `uv`-managed Python version as your interpreter for the project. Go to `View > Command Palette`, search for `Python: Select Interpreter`, and select the Python version labeled `('.venv':venv)`.
22+
23+
If your IDE does not automatically detect and display this option, you can manually select the interpreter by selecting "Enter interpreter path" and then navigating to the `.venv/bin/python` subfolder in your project directory.
1924

2025
### Testing
2126

docs/installation.qmd

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ If you use VSCode with Docker to develop in a container, the following VSCode De
99
``` json
1010
{
1111
"name": "Python 3",
12-
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
13-
"postCreateCommand": "sudo apt update && sudo apt install -y python3-dev libpq-dev graphviz && pipx install poetry && poetry install && poetry shell",
12+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
13+
"postCreateCommand": "sudo apt update && sudo apt install -y python3-dev libpq-dev graphviz && uv venv && uv sync",
1414
"features": {
15+
"ghcr.io/va-h/devcontainers-features/uv:1": {
16+
"version": "latest"
17+
},
1518
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
1619
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {}
1720
}
@@ -24,10 +27,34 @@ Simply create a `.devcontainer` folder in the root of the project and add a `dev
2427

2528
## Install development dependencies manually
2629

27-
### Python and Docker
30+
### uv
2831

29-
- [Python 3.12 or higher](https://www.python.org/downloads/)
30-
- [Docker and Docker Compose](https://docs.docker.com/get-docker/)
32+
MacOS and Linux:
33+
34+
``` bash
35+
wget -qO- https://astral.sh/uv/install.sh | sh
36+
```
37+
38+
Windows:
39+
40+
``` bash
41+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
42+
```
43+
44+
See the [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/) for more information.
45+
46+
### Python
47+
48+
Install Python 3.12 or higher from either the official [downloads page](https://www.python.org/downloads/) or using uv:
49+
50+
``` bash
51+
# Installs the latest version
52+
uv python install
53+
```
54+
55+
### Docker and Docker Compose
56+
57+
Install Docker Desktop and Docker Compose for your operating system by following the [instructions in the documentation](https://docs.docker.com/compose/install/).
3158

3259
### PostgreSQL headers
3360

@@ -49,31 +76,25 @@ For Windows:
4976

5077
### Python dependencies
5178

52-
1. Install Poetry
79+
From the root directory, run:
5380

5481
``` bash
55-
pipx install poetry
82+
uv venv
5683
```
5784

58-
2. Install project dependencies
85+
This will create an in-project virtual environment. Then run:
5986

6087
``` bash
61-
poetry install
88+
uv sync
6289
```
6390

64-
(Note: if `psycopg2` installation fails with a `ChefBuildError`, you just need to install the PostgreSQL headers first and then try again.)
65-
66-
3. Activate shell
67-
68-
``` bash
69-
poetry shell
70-
```
91+
This will install all dependencies.
7192

72-
(Note: You will need to activate the shell every time you open a new terminal session. Alternatively, you can use the `poetry run` prefix before other commands to run them without activating the shell.)
93+
(Note: if `psycopg2` installation fails, you probably just need to install the PostgreSQL headers first and then try again.)
7394

7495
### Configure IDE
7596

76-
If you are using VSCode or Cursor as your IDE, you will need to select the Poetry-managed Python version as your interpreter for the project. To find the location of the Poetry-managed Python interpreter, run `poetry env info` and look for the `Path` field. Then, in VSCode, go to `View > Command Palette`, search for `Python: Select Interpreter`, and either select Poetry's Python version from the list (if it has been auto-detected) or "Enter interpreter path" manually.
97+
If you are using VSCode or Cursor as your IDE, you will need to select the `uv`-managed Python version as your interpreter for the project. Go to `View > Command Palette`, search for `Python: Select Interpreter`, and select the Python version labeled `('.venv':venv)`.
7798

7899
It is also recommended to install the [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) and [Quarto](https://marketplace.visualstudio.com/items?itemName=quarto.quarto) IDE extensions.
79100

docs/static/auth_flow.png

11.6 KB
Loading

docs/static/data_flow.png

5.68 KB
Loading

0 commit comments

Comments
 (0)