ImperialCollegeLondon / ImperialCollegeLondon/python-template

Dependency versions have no upper bound when `uv` is selected as packaging tool

Open
#529 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
14
Forks
8
PR merge metrics
No merged PRs in 30d

Description

The way we specify dependency versions in `pyproject.toml` for `uv` is like so:

```toml
[dependency-groups]
dev = [
"ruff>=VERSION",
"mypy>=VERSION",
"pre-commit>=VERSION",
"pytest>=VERSION",
"pytest-cov>=VERSION",
"pytest-mock>=VERSION",
]
# etc.
```

where `VERSION` is a placeholder value, filled in by our `cookiecutter` hook using values from the various `*requirements.txt` files. The problem is that there is no upper bound on these versions and no lock file included in the template, so users may end up with an incompatible version of one of these dependencies. The usual way to specify dep versions with `uv` is like so:

```toml
dependencies = [
"matplotlib<4.0.0,>=3.10.1",
# etc.
```

Assuming the package uses semver, this should reduce the chance of breakage, even if there's no lockfile.

When fixing this, we should bear in mind #507, which will give us the option of simplifying the template, including possibly by dropping the hook script altogether.

I see a few ways of going about this:

1. We keep the `*requirements.txt` files and hook as they are currently, even though the files won't end up in any generated project anymore. The reason for doing this would be so we can keep the templating in `pyproject.toml` file and still get version updates from dependabot. In this case, we will need to change the hook to specify version ranges in the form above (i.e. calculate what the next major version will be), which is annoying.
2. We drop these files and have a `pyproject.toml` file without any templating in it, which dependabot will be able to parse and update directly. In this case, we will still probably want a hook to drop the unneeded doc dependencies when the `mkdocs` option is set to false. This will also be annoying, but probably less so than option 1.

I'm marking this as on hold for now because I think we should do #507 first. Alternatively, we could do this issue at the same time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #507, then inspect pyproject.toml, the *requirements.txt files, and the cookiecutter hook that fills dependency versions. Compare the available approaches and verify that generated projects receive bounded dependency versions while preserving the mkdocs option behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.