Skip to content

Commit 5d83044

Browse files
authored
Merge pull request #97 from GeriLife/migrate-to-uv
Migrate to UV package manager for dependency management
2 parents 9f82369 + 3662c53 commit 5d83044

File tree

7 files changed

+573
-177
lines changed

7 files changed

+573
-177
lines changed

.github/workflows/django.yml renamed to .github/workflows/ci.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,34 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v4
23+
2324
- name: Set up Python ${{ matrix.python-version }}
2425
uses: actions/setup-python@v5
2526
with:
2627
python-version: ${{ matrix.python-version }}
27-
cache: "pip"
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
32+
- name: Cache UV dependencies
33+
uses: actions/cache@v3
34+
with:
35+
path: |
36+
~/.cache/uv
37+
key: ${{ runner.os }}-uv-python-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
38+
restore-keys: |
39+
${{ runner.os }}-uv-python-${{ matrix.python-version }}-
40+
${{ runner.os }}-uv-
41+
2842
- name: Install Dependencies
29-
run: pip install -r requirements.dev.txt
43+
run: uv sync --dev
44+
3045
- name: Run Tests
31-
run: coverage run --source='.' manage.py test
46+
run: uv run coverage run --source='.' manage.py test
47+
3248
- name: Upload Coverage
3349
uses: paambaati/[email protected]
3450
env:
3551
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
3652
with:
37-
coverageCommand: coverage xml
53+
coverageCommand: uv run coverage xml

CONTRIBUTING.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ such as bug reports, ideas, design, testing, and code.
1010
- [Development](#development)
1111
- [Prerequisites](#prerequisites)
1212
- [pipx](#pipx)
13+
- [UV Package Manager](#uv-package-manager)
1314
- [Pre-commit](#pre-commit)
1415
- [Activate virtual environment](#activate-virtual-environment)
1516
- [Install dependencies](#install-dependencies)
1617
- [Migrations](#migrations)
1718
- [Create superuser](#create-superuser)
1819
- [Run the server](#run-the-server)
20+
- [Package Management with UV](#package-management-with-uv)
21+
- [Adding New Dependencies](#adding-new-dependencies)
22+
- [Benefits of UV](#benefits-of-uv)
23+
- [Updating Dependencies](#updating-dependencies)
24+
- [Other Useful UV Commands](#other-useful-uv-commands)
1925
- [Privacy and Data Protection Guidelines](#privacy-and-data-protection-guidelines)
2026

2127
## Community Discussions
@@ -65,6 +71,14 @@ We also use the following tools for development.
6571
We recommend using [pipx](https://pypa.github.io/pipx/installation/) to
6672
install the development tools.
6773

74+
#### UV Package Manager
75+
76+
We use [uv](https://github.com/astral-sh/uv), a modern Python package manager built for speed and reliability. Install it using pipx:
77+
78+
```sh
79+
pipx install uv
80+
```
81+
6882
#### Pre-commit
6983

7084
We use pre-commit to run various code quality commands prior to each commit.
@@ -85,6 +99,12 @@ pre-commit install
8599

86100
Whenever you develop, make sure you are in the project's virtual environment.
87101

102+
Create a virtual environment using UV:
103+
104+
```sh
105+
uv venv .venv
106+
```
107+
88108
Linux / OSX:
89109

90110
```sh
@@ -99,11 +119,18 @@ Windows:
99119

100120
### Install dependencies
101121

102-
Once you have the above prerequisites installed, install the project development
103-
dependencies as follows.
122+
Once you have the above prerequisites installed, install the project dependencies using UV.
123+
124+
For production dependencies:
104125

105126
```sh
106-
pip install -r requirements.dev.txt
127+
uv sync
128+
```
129+
130+
For development dependencies (includes testing tools):
131+
132+
```sh
133+
uv sync --dev
107134
```
108135

109136
### Migrations
@@ -139,6 +166,66 @@ When all migrations are applied and you have a superuser, run the server as foll
139166
python manage.py runserver
140167
```
141168

169+
## Package Management with UV
170+
171+
### Adding New Dependencies
172+
173+
To add a new dependency to the project:
174+
175+
```sh
176+
# Add a regular dependency
177+
uv add package-name
178+
179+
# Add a development dependency
180+
uv add --dev package-name
181+
182+
# Add a dependency with a specific version
183+
uv add "package-name>=1.0,<2.0"
184+
```
185+
186+
These commands will automatically update your pyproject.toml file and create/update the lock file.
187+
188+
### Benefits of UV
189+
190+
UV provides several advantages over traditional package management tools:
191+
192+
- **Speed**: UV is dramatically faster at resolving and installing dependencies
193+
- **Reliability**: Consistent installations across environments with lock file support
194+
- **Dependency Groups**: Cleaner separation between production and development dependencies
195+
- **Modern Features**: Native support for PEP 517/518 standards with pyproject.toml
196+
- **Unified Interface**: Single tool for Python version management and package management
197+
198+
### Updating Dependencies
199+
200+
To update dependencies to their latest compatible versions:
201+
202+
```sh
203+
# Update all dependencies
204+
uv sync --upgrade
205+
206+
# Update specific dependency
207+
uv add --upgrade package-name
208+
```
209+
210+
### Other Useful UV Commands
211+
212+
```sh
213+
# View dependency tree
214+
uv tree
215+
216+
# Lock dependencies without installing
217+
uv lock
218+
219+
# Run a script within the project environment
220+
uv run python manage.py runserver
221+
222+
# Check for outdated packages
223+
uv list --outdated
224+
225+
# Remove a dependency
226+
uv remove package-name
227+
```
228+
142229
## Privacy and Data Protection Guidelines
143230

144231
As an open-source community committed to upholding the highest standards of privacy and data security, we align our practices with principles derived from the General Data Protection Regulation (GDPR) and other similar privacy frameworks. While some GDPR principles are more relevant at an organizational level, many can be directly applied to software development, especially in features involving user data. Below are key guidelines that contributors should follow:

dev.py

Lines changed: 0 additions & 135 deletions
This file was deleted.

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,25 @@ description = "Caregiving visualization tool to promote wellness in elder-care c
55
authors = ["Brylie Christopher Oxley <[email protected]>"]
66
license = "EUPL-1.2"
77
readme = "README.md"
8+
dependencies = [
9+
"crispy-bootstrap5>=2023.10,<2024.0",
10+
"django>=5.0,<6.0",
11+
"django-crispy-forms>=2.1,<3.0",
12+
"django-debug-toolbar>=4.2.0,<5.0",
13+
"django-environ>=0.11.2,<1.0",
14+
"faker>=21.0.0,<22.0",
15+
"numpy>=2.2.4<3.0.0",
16+
"pandas>=2.2.3",
17+
"plotly>=5.18.0,<6.0",
18+
"psycopg2-binary>=2.9.9,<3.0",
19+
"shortuuid>=1.0.11,<2.0",
20+
"whitenoise>=6.6.0,<7.0",
21+
]
22+
23+
[dependency-groups]
24+
dev = [
25+
"coverage>=7.3.3,<8.0",
26+
"factory-boy>=3.3.0,<4.0",
27+
"pytest>=7.4.3,<8.0",
28+
"pytest-django>=3.5.1,<4.0",
29+
]

requirements.dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)