Skip to content

Commit 33e294e

Browse files
committed
Switch dependency managment to uv
1 parent 4b89544 commit 33e294e

17 files changed

Lines changed: 1907 additions & 2356 deletions

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
version: 2
44
updates:
55
# Enable version updates for python
6-
- package-ecosystem: "pip"
7-
directory: "/requirements"
6+
- package-ecosystem: "uv"
7+
directory: "/"
88
schedule:
9-
interval: "daily"
9+
interval: "weekly"
1010
open-pull-requests-limit: 16
1111
pull-request-branch-name:
1212
# so it's compatible with docker tags

.github/workflows/build-and-release.yaml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,21 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@v6
2020

21-
- name: Setup Python
22-
uses: actions/setup-python@v6
21+
- uses: astral-sh/setup-uv@v10
2322
with:
2423
python-version: '3.12.3'
25-
architecture: 'x64'
2624

2725
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install --no-deps -r requirements/requirements-lint.txt
26+
run: uv sync --locked
3127

3228
- name: Formatting (ruff)
33-
run: ruff format --check .
29+
run: uv run ruff format --check .
3430

3531
- name: Linting (ruff)
36-
run: ruff check --no-cache --output-format github .
37-
38-
- name: Install production requirements (for Mypy)
39-
run: |
40-
# Mypy needs production packages for typechecking
41-
pip install --no-deps -r requirements/requirements-prod.txt
32+
run: uv run ruff check --no-cache --output-format github .
4233

4334
- name: Mypy
44-
run: mypy
45-
46-
check-compiled-requirements:
47-
runs-on: ubuntu-24.04
48-
if: ${{ !contains(github.event.head_commit.message, '#notests') }}
49-
steps:
50-
- uses: actions/checkout@v6
51-
with:
52-
ref: ${{ github.event.pull_request.head.ref }}
53-
- uses: actions/setup-python@v6
54-
with:
55-
python-version: '3.12.3'
56-
57-
- name: Prepare environment
58-
run: |
59-
pip install --no-deps -r requirements/requirements-pip.txt
60-
pip install $(grep -rwoh requirements -e 'pip-tools==.*[^\]' | head -n 1)
61-
62-
- name: Compile Requirements Files
63-
run: |
64-
./scripts/pip-compile-all.sh
65-
66-
- name: Check If Output Matches Committed
67-
run: |
68-
DIFF="$(git diff)"
69-
if [ "$DIFF" ]; then
70-
echo "Compiled requirements differ from committed requirements!"
71-
echo "$DIFF"
72-
exit 1
73-
fi
35+
run: uv run mypy
7436

7537
build:
7638
runs-on: ${{ matrix.runs-on }}

Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,20 @@ RUN apt-get update \
5656
git \
5757
pkg-config \
5858
python3.12-dev \
59-
python3.12-venv \
60-
python3-pip \
6159
libmysqlclient-dev \
6260
&& rm -rf /var/lib/apt/lists/*
6361

64-
COPY /requirements/ /requirements/
65-
RUN python3.12 -m venv /opt/venv && \
66-
/opt/venv/bin/python3.12 -m pip install --no-cache --no-deps -r /requirements/requirements-prod.txt -r /requirements/requirements-test.txt && \
67-
/opt/venv/bin/python3.12 -m pip check
62+
WORKDIR /src
63+
COPY pyproject.toml uv.lock .python-version ./
64+
# Install uv, pinned to the version declared in pyproject.toml's [tool.uv]
65+
# required-version (the same canonical source CI's astral-sh/setup-uv step
66+
# reads), so there's exactly one place to bump it.
67+
RUN UV_VERSION="$(grep -m1 'required-version' pyproject.toml | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" \
68+
&& curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | sh
69+
ENV PATH="/root/.local/bin:${PATH}"
70+
ENV UV_PROJECT_ENVIRONMENT=/opt/venv
71+
ENV UV_PYTHON_DOWNLOADS=never
72+
RUN uv sync --locked --no-install-project --no-default-groups --group test
6873

6974

7075
# --- Stage 2 --- #

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ authorization token from Google or another service for syncing your mail. Your c
1717

1818
The sync engine will automatically begin syncing your account with the underlying provider. The `inbox-sync` command allows you to manually stop or restart the sync by running `inbox-sync stop [YOUR_ACCOUNT]@example.com` or `inbox-sync start [YOUR_ACCOUNT]@example.com`. Note that an initial sync can take quite a while depending on how much mail you have.
1919

20+
### Managing Dependencies
21+
22+
We use [`uv`](https://github.com/astral-sh/uv) to manage the pinning of our
23+
dependencies. New dependencies should be added to the appropriate section of
24+
`pyproject.toml` (`[project.dependencies]` for runtime dependencies, or the
25+
relevant `[dependency-groups]` entry for lint/test/dev-only dependencies) and
26+
then `uv lock` should be run to update `uv.lock`.
27+
28+
Run `uv sync` to install dependencies into a local virtualenv, and `uv run
29+
<command>` to run a command against it (e.g. `uv run pytest`).
30+
2031
### API Service
2132

2233
The API service provides a REST API for interacting with your data. To start

pyproject.toml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,106 @@
1+
[project]
2+
name = "sync-engine"
3+
version = "0.1.0"
4+
description = "Close's email sync engine."
5+
requires-python = "==3.12.*"
6+
dependencies = [
7+
"alembic==1.7.5",
8+
"arrow==0.17.0",
9+
"asn1crypto==0.24.0",
10+
"attrs==23.1.0",
11+
"authalligator-client @ https://github.com/closeio/authalligator-client/archive/e7cc8e0bc5b1f2285ab5997e2590a8eb056fc627.zip",
12+
"boto3==1.35.50",
13+
"botocore==1.35.50",
14+
"ciso8601==2.2.0",
15+
"click==8.1.7",
16+
"colorlog==6.5.0",
17+
"cryptography==48.0.1",
18+
"dnspython==2.6.1",
19+
"flanker @ https://github.com/closeio/flanker-new/archive/fa272d95345d45e8bb1f9bc32bc2c074bf52a484.zip",
20+
"Flask==3.1.3",
21+
"Flask-RESTful==0.3.9",
22+
"gdata==2.0.18",
23+
"gunicorn==23.0.0",
24+
"hiredis==2.3.2",
25+
"html2text==2020.1.16",
26+
"icalendar==4.0.9",
27+
"imapclient==2.2.0",
28+
"importlib-metadata==4.8.1",
29+
"importlib-resources==5.4.0",
30+
"ipython==9.12.0",
31+
"json_log_formatter==1.0",
32+
"limitlion==1.1.0",
33+
"lxml==6.1.0",
34+
"mysqlclient==2.2.5",
35+
"psutil==5.8.0",
36+
"Pympler==0.9",
37+
"PyNaCl==1.6.2",
38+
"python-dateutil==2.8.2",
39+
"python-json-logger==3.3.0",
40+
"pytz==2026.1.post1",
41+
"PyYAML==6.0.2",
42+
"redis==5.0.2",
43+
"requests==2.34.2",
44+
"requests-file==1.5.1",
45+
"s3transfer==0.10.3",
46+
"sentry-sdk<3",
47+
"setproctitle==1.2.2",
48+
"setuptools==82.0.0",
49+
"six==1.17.0",
50+
"sqlalchemy==1.4.54",
51+
"statsd==3.3.0",
52+
"tldextract==3.1.2",
53+
"structlog==23.1.0",
54+
"typing_extensions",
55+
"urllib3==2.7.0",
56+
"vobject==0.9.6.1",
57+
"WebOb==1.8.8",
58+
"Werkzeug==3.1.8",
59+
"zipp==3.20.2",
60+
"zstandard==0.23.0",
61+
]
62+
63+
[dependency-groups]
64+
lint = [
65+
"mypy==1.13.0",
66+
"ruff==0.8.2",
67+
"types-boto",
68+
"types-python-dateutil",
69+
"types-pytz",
70+
"types-PyYAML",
71+
"types-redis",
72+
"types-requests",
73+
]
74+
test = [
75+
"atomicwrites==1.4.1",
76+
"coverage==7.6.1",
77+
"exceptiongroup==1.2.2",
78+
"funcsigs==1.0.2",
79+
"freezegun==1.5.1",
80+
"hypothesis==6.113.0",
81+
"iniconfig==2.0.0",
82+
"mockredispy==2.9.3",
83+
"more-itertools==10.5.0",
84+
"packaging==24.2",
85+
"pbr==6.1.0",
86+
"pluggy==1.6.0",
87+
"pyparsing==3.1.4",
88+
"pytest==9.0.3",
89+
"pytest-cov==5.0.0",
90+
"pytest-timeout==2.3.1",
91+
"responses==0.25.3",
92+
"types-toml==0.10.8.20240310",
93+
"sortedcontainers==2.4.0",
94+
"toml==0.10.2",
95+
"tomli==2.2.1",
96+
]
97+
dev = [{include-group = "lint"}, {include-group = "test"}]
98+
99+
[tool.uv]
100+
required-version = "==0.12.7"
101+
# This is a service, not a library to be installed/imported by others.
102+
package = false
103+
1104
[tool.ruff]
2105
target-version = "py312"
3106
line-length = 79

requirements/requirements-dev.in

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

requirements/requirements-dev.txt

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

requirements/requirements-lint.in

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

0 commit comments

Comments
 (0)