Skip to content

BLD: migrate requirements/*.txt to [dependency-groups] in pyproject.toml #24670

Closed

Description

@rgommers

This follows up on this comment from @skirpichev: #23808 (comment) about f2py -c needing meson and ninja for Python 3.12 (or with --backend=meson on older Python versions).

Right now we do not use optional-dependencies at all. It is also the future replacement for test_requirements.txt & co. Here is an example of how it can be used: https://github.com/scipy/scipy/blob/9f7549abcc61f5dc72ca000cef7bc43066c74527/pyproject.toml#L74-L109

In numpy it could have an extra f2py section, and that would allow installing the needed dependencies with pip install numpy[f2py]. Of course you have to know that that's possible, and at that point you can equally well do pip install meson ninja , so this isn't all that urgent. An extra complication is that ninja is a system dependency, and using it from PyPI is a bit hacky. That's for example why meson and meson-python do not have a direct dependency on ninja; meson-python first checks if it's installed on the system and dynamically adds it in non-isolated installs if it's missing.

I'd say we don't want to do this for 1.26.0, but we can consider populating the optional dependencies table for 2.0.

Activity

  1. added this to the 2.0.0 release milestone on Sep 8, 2023
  2. self-assigned this
    on Sep 8, 2023
  3. rgommers commented on Jan 31, 2024

    @rgommers
    MemberAuthor

    I'm bumping this to the next release cycle, because I don't want to touch optional dependencies right before creating a release branch, and this isn't blocking/important for 2.0

  4. mattip commented on Aug 7, 2024

    @mattip
    Member

    This would be good to do, it would require some knowledge of packaging and maybe meson.

  5. mattip commented on Aug 21, 2024

    @mattip
    Member

    We discussed this a triage meeting and decided to remove it from the milestone, but it would be nice to have this, as well as #26289 to ship tests separately.

  6. removed this from the 2.2.0 release milestone on Aug 21, 2024
  7. InessaPawson commented on Oct 7, 2026

    @InessaPawson
    Member

    @rgommers We discussed this at today's community meeting, and the consensus was that we should definitely pursue it. The scope would be adding [dependency-groups] (PEP 735) in addition to [project.optional-dependencies].

    Are you still planning to work on this task? If not, I'd be happy to take it on.

  8. andyfaff commented on Oct 8, 2026

    @andyfaff
    Member

    Dependency groups are excellent. scipy has gone down this route and it's working well. As this proceeds it needs to go hand in hand with removing all of the requirements.txt files.

  9. rgommers commented on Oct 8, 2026

    @rgommers
    MemberAuthor

    +1 to what Andrew said. No need for optional-dependencies anymore, I don't think we have any. The goal of getting rid of everything in https://github.com/numpy/numpy/tree/main/requirements is unchanged, but it can now be migrated to dependency-groups instead.

  10. InessaPawson commented on Oct 8, 2026

    @InessaPawson
    Member

    @rgommers Thank you for clarifying the scope on this issue! Let me know if you need help.

  11. changed the title [-]Consider populating `optional-dependencies` in pyproject.toml[/-] [+]BLD: migrate requirements/*.txt to [dependency-groups] in pyproject.toml[/+] on Oct 8, 2026
  12. andyfaff commented on Oct 8, 2026

    @andyfaff
    Member

    I have a question about the existing requirements files. A lot of them, such as pytest, have specific version pins without comments as to why they're pinned. Are the pins work arounds, or there for another reason?

  13. mattip commented on Oct 8, 2026

    @mattip
    Member

    some of the pins are to prevent the fast release cycles from causing churn in NumPy as the library developers change the APIs and deprecate parts we use. For instance #31635, maybe there are others.

  14. ikrommyd commented on Oct 9, 2026

    @ikrommyd
    Member

    +100 on this from me. Dependency groups are way nicer than requirement txt files.

  15. seberg commented on Oct 21, 2026

    @seberg
    Member

    I guess these are all gone now, so closing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions