Skip to content

Commit 535468b

Browse files
authored
ref: refresh devinfra python dependencies docs (#15190)
1 parent 98b5f54 commit 535468b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

develop-docs/development-infrastructure/python-dependencies.mdx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ data if they turn out to be malicious.
1414

1515
Any new dependency needs to be thoroughly reviewed and approved by [owners-python-build](https://github.com/orgs/getsentry/teams/owners-python-build/members). This group is already automatically tagged in your PR to `sentry` or `getsentry` as soon as you edit relevant files. For other repos you might need to do it manually.
1616

17+
Dependencies must:
18+
- be on [internal pypi](https://github.com/getsentry/pypi)
19+
- not be added to repos as non-specifier requirements (see sentry's `tools/lint_requirements.py`)
20+
1721
To add or update a dependency:
1822

1923
1. Clone https://github.com/getsentry/pypi/.
2024
2. `cd` into your clone and run `python3 -m add_pkg PKGNAME` (or `python3 -m add_pkg PKGNAME==PKGVERSION` if you want a version other than the latest).
2125
3. Commit the resulting changes to a branch, open a PR in `getsentry/pypi`, and tag someone on your team (any engineer can approve PRs on this repo).
2226
4. Once your PR is merged, go back to the main repo whose dependencies you want to change (`sentry`, `getsentry`, etc.).
23-
5. In that repo, add to or update the dependency in `pyproject.toml`.
27+
5. In that repo, add to or update the dependency in `pyproject.toml` (or `requirements*.txt` if the repo isn't [using `uv` yet](https://www.notion.so/Standard-Spec-python-uv-2248b10e4b5d8045b8fff30f8b8b67ca)).
2428
- In sentry, you can do this with the [bump-version action](https://github.com/getsentry/sentry/actions/workflows/bump-version.yml).
2529
- Click the **Run workflow** dropdown.
2630
- Fill in your package name and version.
2731
- Click the **Run workflow** button.
28-
- Some projects are still using `requirements*.txt`, in which case update those files.
29-
- The eventual goal is that every python project will [use `uv` to lock python dependencies](https://www.notion.so/Standard-Spec-python-uv-2248b10e4b5d8045b8fff30f8b8b67ca).
30-
- Note that dependencies should pinned with lower bounds only, to encourage updating to latest versions.
32+
33+
<Alert level="warning" title="Note">
34+
Dependencies should pinned with lower bounds `>=`, to encourage updating to latest versions.
35+
</Alert>
36+
3137
6. Run `make freeze-requirements` (or `uv lock`). You might need to wait a few minutes for the changes to `getsentry/pypi` to be deployed before this will work without erroring.
3238
7. Commit your changes (which should consist of changes to both one of the `requirements` files and its corresponding lockfile) to a branch and open a PR in the relevant repo. If it's not obvious, explain why you're adding or updating the dependency. Tag `owners-python-build` if they haven't already been auto-tagged.
3339
8. Merge your PR, pull `master`, and run `devenv sync`.
@@ -36,15 +42,12 @@ To add or update a dependency:
3642
## Depending on forks
3743

3844
If you need to make modifications to a dependency and need to deploy the result
39-
before it is accepted upstream, you can fork the dependency.
45+
before it is accepted upstream, you must fork the dependency and publish it to pypi and internal pypi.
4046

41-
Depending on forks is generally discouraged unless necessary, and you should
42-
make sure that the changes in your fork are **not required for self-hosted to
43-
function,** because they won't be included in the PyPI distribution of Sentry.
47+
1. Fork into the `getsentry` organization and make your changes.
48+
2. Add craft configuration to publish to pypi+internal pypi ([example](https://github.com/getsentry/sentry-forked-djangorestframework-stubs/pull/1)).
49+
3. Add the dependency to your repository.
4450

45-
1. Fork into the `getsentry` organization.
46-
2. Depend on the fork using `library-name @ https://github.com/getsentry/<repo>/archive/<40 char sha>.zip` in `getsentry`'s `requirements-base.txt`.
47-
3. The requirement in `sentry` stays the same, because we upload `sentry` to PyPI, and PyPI does not allow us to depend on URLs.
4851

4952
## Unclear?
5053

0 commit comments

Comments
 (0)