This repository was archived by the owner on Jun 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
feat: Use uv package manager #988
Draft
suejung-sentry
wants to merge
4
commits into
main
Choose a base branch
from
sshin/uv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,62 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
ARG PYTHON_IMAGE=python:3.12-slim-bookworm | ||
ARG PYTHON_IMAGE=ghcr.io/astral-sh/uv:python3.12-bookworm-slim | ||
|
||
# BUILD STAGE - Download dependencies from GitHub that require SSH access | ||
FROM $PYTHON_IMAGE as build | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
libffi-dev \ | ||
libpq-dev \ | ||
curl | ||
|
||
COPY requirements.txt / | ||
WORKDIR /pip-packages/ | ||
RUN pip wheel -r /requirements.txt | ||
RUN rm -rf /pip-packages/src | ||
ENV UV_LINK_MODE=copy \ | ||
UV_COMPILE_BYTECODE=1 \ | ||
UV_PYTHON_DOWNLOADS=never \ | ||
UV_PYTHON=python \ | ||
UV_PROJECT_ENVIRONMENT=/api | ||
|
||
# Then, add the rest of the project source code and install it | ||
# Installing separately from its dependencies allows optimal layer caching | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv sync --frozen | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv export --no-hashes --frozen --format requirements-txt > requirements.txt | ||
|
||
RUN grep -v '^-e ' requirements.txt > requirements.remote.txt | ||
|
||
# build all remote wheels | ||
RUN pip wheel -w wheels --find-links wheels -r requirements.remote.txt | ||
|
||
# build all local packages to wheels | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv build --all-packages --wheel -o wheels | ||
|
||
# RUNTIME STAGE - Copy packages from build stage and install runtime dependencies | ||
FROM $PYTHON_IMAGE | ||
|
||
# Our postgres driver psycopg2 requires libpq-dev as a runtime dependency | ||
RUN apt-get update | ||
RUN apt-get install -y \ | ||
git \ | ||
libpq-dev \ | ||
make \ | ||
curl \ | ||
libexpat1 \ | ||
&& pip install --upgrade pip | ||
|
||
WORKDIR /pip-packages/ | ||
COPY --from=build /pip-packages/ /pip-packages/ | ||
COPY --from=build /wheels/ /wheels/ | ||
|
||
RUN pip install --no-deps --no-index --find-links=/pip-packages/ /pip-packages/* | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv pip install --no-deps --no-index --find-links=wheels wheels/* --system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
[project] | ||
name = "api" | ||
version = "0.1.0" | ||
description = "Codecov's API layer" | ||
readme = "README.md" | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO - these are ported over to align with existing requirements.in. Go through and pin these to max versions in existing requirements.txt so not introducing any regressions by using an old version of deps |
||
"aiodataloader", | ||
"ariadne==0.23", | ||
"ariadne_django==0.3.0", | ||
"codecovopentelem", | ||
"celery>=5.3.6", | ||
"cerberus", | ||
"ddtrace", | ||
"Django>=4.2.16", | ||
"django-cors-headers", | ||
"django-csp", | ||
"django-dynamic-fixture", | ||
"django-filter", | ||
"django-model-utils", | ||
"django-postgres-extra>=2.0.8", | ||
"django-prometheus", | ||
"djangorestframework==3.15.2", | ||
"drf-spectacular", | ||
"drf-spectacular-sidecar", | ||
"elastic-apm", | ||
"google-cloud-pubsub", | ||
"gunicorn>=22.0.0", | ||
"idna>=3.7", | ||
"minio", | ||
"opentelemetry-instrumentation-django>=0.45b0", | ||
"opentelemetry-sdk>=1.24.0", | ||
"opentracing", | ||
"polars==1.12.0", | ||
"psycopg2", | ||
"PyJWT", | ||
"pydantic", | ||
"python-dateutil", | ||
"python-json-logger", | ||
"python-redis-lock", | ||
"pytz", | ||
"redis", | ||
"regex", | ||
"requests", | ||
"sentry-sdk>=2.18.0", | ||
"setproctitle", | ||
"shared", | ||
"simplejson", | ||
"starlette==0.40.0", | ||
"stripe>=9.6.0", | ||
"test-results-parser", | ||
"timestring", | ||
"urllib3>=1.26.19", | ||
"vcrpy", | ||
"whitenoise", | ||
"django-autocomplete-light", | ||
"django-better-admin-arrayfield", | ||
"certifi>=2024.07.04", | ||
] | ||
|
||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
py-modules = [] | ||
|
||
[tool.uv] | ||
dev-dependencies = [ | ||
"factory-boy", | ||
"fakeredis", | ||
"freezegun", | ||
"pre-commit", | ||
"pytest>=7.2.0", | ||
"pytest-cov", | ||
"pytest-asyncio", | ||
"pytest-django", | ||
"pytest-mock", | ||
"vcrpy", | ||
] | ||
|
||
[tool.uv.sources] | ||
codecovopentelem = { git = "https://github.com/codecov/opentelem-python", rev = "df1e241927d4794fc0e24f96431f0fb730edac21" } | ||
shared = { git = "https://github.com/codecov/shared", rev = "9c31870de026a8a3f026f0753b1991e8c832fadb" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO - look into the build for self-hosted?