Skip to content

Dependency management improvements #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 29, 2025
Merged

Dependency management improvements #188

merged 4 commits into from
May 29, 2025

Conversation

Preocts
Copy link
Owner

@Preocts Preocts commented May 29, 2025

This change is a collection of improvements on how the dependencies of a project are managed. Each commit has a detailed breakdown of its changes.

Added

  • requests as a dependency just to have something to demonstrate

Changed

  • A single constraints.txt file to rule all version pinning
  • nox session install is now dev
  • nox session update is now update-deps
  • nox session upgrade is now upgrade-deps

Preocts added 2 commits May 28, 2025 23:40
Turns out I've been using the constraint file incorrectly for years. I
love learning moments like this!

The `constraints.txt` file **is** the lockfile for the project. It
contains all the versions that *should* be used *if* they are needed. Is
is not the source of **what** should be installed, only what version.

So, instead of having N different `requirements*.in` files with N
different `requirements*.txt` generated from `pip-compile`; we have a
single `constraints.txt` that all of our `requirements*.txt` files
reference. Glorious.

This solves for the scaling problem that I ran into when, for example,
`requirements-doc.txt` had a version conflicct with something in
`requirements-test.txt`. Initially, I thought to somehow cross-reference
all the `.txt` files with themselves in some horrible chained constraint
system. That worked about as well as it sounds.

Note, I have to remove the dynamic dependencies here from the
`pyproject.toml`. That's fine. Eventually, I'll be moving to `uv` which
simplifies most of this juggling. For now, however, I want to understand
the underlying machanics before abstracting them away.
Moving toward simplicity of use, the `noxfile.txt` now has a session
called `dev`. This session creates, if needed, the `.venv` and installs
all development requirements.

Additionally, the `update` and `upgrade` sessions have been renamed to
`update-deps` and `upgrade-deps` respectively. They now use the new,
awesome pattern of a single constraint file for dependencies.

Finally, added the `--no-annotations` to the `pip-compile` commands and
what a difference that makes! I have yet to understand when and why
`pip-compile` will expand `requirements/requirements.txt` to
`/home/preocts/project-name/requirements/requirements.txt`. In practice,
the results are different depending on the OS being used as well. Since
it all lead to noisy diffs without much value, removing it seems ideal!
@Preocts Preocts self-assigned this May 29, 2025
Preocts added 2 commits May 29, 2025 01:17
Okay, this is the ugly part of the path I'm taking. It is now required
to install the correct requirement*.txt files for each session.
Previously it was a simple `.[test]` reference when installing the
package.

This too shall pass.

Already thinking about pivoting into listing all requirements in the
`pyproject.toml`. With dependency groups being supported this should be
amazing. It will hindge on `pip-compile` being able to extract from
dependency groups. That's the next PR!
Adjust the contributing docs with the new expected nox workflows. Add
some leading links at the top of the readme pointing to the secondary
files.

Reading, strangely, isn't the strongest skill of many.
@Preocts Preocts marked this pull request as ready for review May 29, 2025 06:34
@Preocts Preocts enabled auto-merge (squash) May 29, 2025 06:34
@Preocts Preocts disabled auto-merge May 29, 2025 06:35
@Preocts Preocts merged commit 6b34d20 into main May 29, 2025
18 checks passed
@Preocts Preocts deleted the improvements branch May 29, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant