Skip to content

Move dependency management to uv#590

Open
molpopgen wants to merge 1 commit intomainfrom
uv
Open

Move dependency management to uv#590
molpopgen wants to merge 1 commit intomainfrom
uv

Conversation

@molpopgen
Copy link
Collaborator

@molpopgen molpopgen commented Mar 13, 2026

  • Move contents from setup.[py|cfg] into pyproject.toml
  • Update github workflows
  • Delete old requirements files

See #589

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.06%. Comparing base (4bc3f95) to head (e9a6a59).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #590      +/-   ##
==========================================
- Coverage   99.81%   99.06%   -0.75%     
==========================================
  Files           5        5              
  Lines        1600     1600              
==========================================
- Hits         1597     1585      -12     
- Misses          3       15      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@molpopgen
Copy link
Collaborator Author

Issues:

  • Our use of jupyter-book requires pinning ipython to a version that requires python >= 3.10. While it may be true that the package itself works as far back as 3.7, we do not test that that is true and it appears that current tooling includes the entire development environment as having the same minimum version.
  • It is not clear that dev.yaml is needed in the work flows any longer?
  • The window tests are failing sporadically.

@molpopgen molpopgen force-pushed the uv branch 5 times, most recently from d9078b3 to 3923460 Compare March 13, 2026 19:25
@molpopgen molpopgen marked this pull request as ready for review March 13, 2026 19:39
@molpopgen
Copy link
Collaborator Author

@grahamgower @apragsdale -- this is ready for a look.

I have shoe-horned most tasks into a place where they now work. The problem is the windows tests. They fail because the modules in demes-spec are not finding ruamel. I cannot reproduce this issue locally, which makes sense because I'm on Linux and the Linux tests are also passing in CI.

@grahamgower
Copy link
Member

The failing tests are in test_cli.py and test_spec.py. What these tests have in common is that they use subprocess.* to run python. These subprocesses are unable to import basic dependencies such as attr and ruamel, so my guess is that the uv virtual environment is not active for the subprocess. I don't think the previous tests used a virtual environment, and so didn't encounter this issue? This is likely a common problem experienced by other projects using uv and running cli tests, so it might be worth finding out what others have done here.

Copy link
Member

@grahamgower grahamgower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of duplication between the _setup.cfg and pyproject.toml - is this intentional? And what's the role of _setup.cfg here, versus setup.cfg? Which files are generated by uv? Is it just uv.lock?

_setup.cfg Outdated
long_description_content_type = text/markdown
url = https://github.com/popsim-consortium/demes-python
classifiers =
Development Status :: 4 - Beta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon we're out of beta now.

"Topic :: Scientific/Engineering :: Bio-Informatics"
]

requires-python = ">=3.10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the _setup.cfg file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct -- the _setup file is to rename it so that it doesn't confuse uv / conflict with pyproject.

More generally, our pinning to 3.7 was wrong due to other pinned dependencies that this PR revealed. (Briefly, our pinnings related to docs required >= 3.10).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demes can be installed and used on 3.7, but building the docs on CI needed a more recent version due to jupyterbook annoyances. I don't think that was incorrect. That said, I don't mind if you want to bump things to the latest supported python version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to keep a pinning to >= 3.7 then we would need to figure out how to downgrade the jupyter-book dependencies. But I do think that we should just try to track currently supported Python versions. Moving forward, uv will force this on use b/c a given uv version will only support a handful of Python versions.

pyproject.toml Outdated
readme = {file = "README.md", content-type = "text/markdown"}
license = {text = "ISC"}
classifiers = [
"Development Status :: 4 - Beta",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer in beta.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our version number is still < 1??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevertheless, I'd argue demes is now Development Status :: 5 - Production/Stable (https://pypi.org/classifiers/).

@molpopgen
Copy link
Collaborator Author

There seems to be a lot of duplication between the _setup.cfg and pyproject.toml - is this intentional? And what's the role of _setup.cfg here, versus setup.cfg? Which files are generated by uv? Is it just uv.lock?

_setup.cfg is to move setup.cfg out of the way. It is currently expected that most/all of that material is now in pyproject. _setup.cfg will be deleted prior to merging. setup.cfg itself now only contains config for flake8 and mypy. The former does not support pyproject configuration** and I had trouble getting the latter working but will try again.

**This situation is unfortunate and can be "fixed" by adding a dependency on flake8-pyproject

uv.lock is the only file generated by uv.

@molpopgen
Copy link
Collaborator Author

The failing tests are in test_cli.py and test_spec.py. What these tests have in common is that they use subprocess.* to run python. These subprocesses are unable to import basic dependencies such as attr and ruamel, so my guess is that the uv virtual environment is not active for the subprocess. I don't think the previous tests used a virtual environment, and so didn't encounter this issue? This is likely a common problem experienced by other projects using uv and running cli tests, so it might be worth finding out what others have done here.

agreed, but the issue remains that it is windows-specific. Does anyone here have the ability to locally explore this problem?

@jeromekelleher
Copy link
Member

If they're only failing on windows I'd consider pytest.skip - most likely not a real problem just annoying infrastructure differences

@molpopgen molpopgen force-pushed the uv branch 3 times, most recently from c9c4e0f to bf8f3f8 Compare March 16, 2026 15:30
@molpopgen
Copy link
Collaborator Author

A note for everyone listening that may save you future pain:

Any call to something like subprocess.run should use sys.executable (in an f-string, and after import sys) to make sure that you are using the correct Python version! (This change fixes the windows tests issue. Google was no help here.)

@molpopgen
Copy link
Collaborator Author

I think there is one outstanding issue remaining: we have a dev.yaml test file that tests a pip-install of the developer dependencies. I argue that we remove this and all the requirements files. Developers can/should now use uv locally, and the requirements files are pinned and thus difficult to maintain.

@molpopgen
Copy link
Collaborator Author

molpopgen commented Mar 16, 2026

I think there is one outstanding issue remaining: we have a dev.yaml test file that tests a pip-install of the developer dependencies. I argue that we remove this and all the requirements files. Developers can/should now use uv locally, and the requirements files are pinned and thus difficult to maintain.

Actually, we may be able to keep the CI file but redirect pip to look at pyproject.toml....

* move dependency management to uv
* move (most) config info to pyproject.toml
* bump minimum supported Python version
* bump development status metadata
* update github workflows
* remove requirements files
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.

3 participants