Skip to content

matplotlib dev pulls in contourpy that pins numpy<2, preventing numpy dev testing #26847

Closed as not planned

Description

@pllim

Hello. Looks like contourpy started pinning numpy<2 in both their dev branch and releases. matplotlib pulls in contourpy as a required dependency. As a result, that forces CI to downgrade numpy to 1.26 even when I am asking for numpy "nightly" wheel in an environment where I also asks for matplotlib nightly wheel.

Is it possible for matplotlib to coordinate with contourpy developers so matplotlib dev does not end up forcing numpy to downgrade from 2.0.dev to 1.x? 🙏

Latest release:

https://github.com/contourpy/contourpy/blob/2606b9e2eb93b0f1127dfeca3d868cd78f4c874d/pyproject.toml#L29-L31

Dev:

https://github.com/contourpy/contourpy/blob/9be748cab37556f32e416c6d620ba7a25aea4316/pyproject.toml#L28-L30

Activity

  1. pllim commented on Sep 20, 2023

    @pllim
    Author

    p.s. I bet you have this same problem in your CI unless you force numpy to upgrade again afterwards but your CI seems to skip nightly installs for pushes to main.

  2. QuLogic commented on Sep 20, 2023

    @QuLogic
    Member
  3. ksunden commented on Sep 20, 2023

    @ksunden
    Member

    Pinning is the official numpy recommendation, at least for releases (at least for users of the C API, because the problem is that they are anticipating an ABI break)

    We have elected here to pin on release branches only, and leave the main branch unpinned.

    I suspect some of it can be worked around with careful ordering and/or pip install --no-build-isolation --no-deps trickery, though mildly frustrating.

    I expect when the ABI breaks happen we will have to sort out nightlies regardless though, as our wheels uploaded there are made with current released numpy, not nightly numpy...

    (And even then may require a recompiled contourpy as well as mpl)

  4. pllim commented on Sep 20, 2023

    @pllim
    Author

    So, are you suggesting that I cannot install matplotlib if I were to test against numpy 2.0.dev? 🤔

    p.s. For reasons beyond my control, astropy uses tox to manage test environments. I don't know an easy way to force numpy to upgrade again after the downgrade using their mini-language. Also, since you are not testing against numpy dev, then there is also a risk of astropy picking up incompatibility between matplotlib and numpy instead of astropy stuff.

  5. ksunden commented on Sep 20, 2023

    @ksunden
    Member

    At present it all works.

    Once the ABI break hits, the wheels that we currently upload to nightlies are not built against np2.0. Since the ABI break has not happened yet, this is just something that hasn't been an issue.

    So to test against numpy 2.0 (post ABI break) you will need mpl compiled against 2.0, which either means doing a source install (rather than a wheel install) or our nightlies will have to be updated to compile against np2.0.

    Currently we just upload the most recent run from main of our CIBW action, which uses current released numpy. (Until recently it actually used oldest_supported_numpy, but since np 1.25, backwards compatible mode is available and default, so now there is no reason to build against older versions)

    but if/when numpy nightly is ABI incompatible with released numpy (which is expected, and the reason for pinning), then we may have to rethink what we do for nightly wheel uploads.

  6. QuLogic commented on Sep 20, 2023

    @QuLogic
    Member

    p.s. I bet you have this same problem in your CI unless you force numpy to upgrade again afterwards but your CI seems to skip nightly installs for pushes to main.

    Nightly tests are on a schedule. And we do test against NumPy 2 because nightly deps are installed after our dependencies, and Matplotlib itself is installed with --no-deps. We don't build against it though, but that's because of build isolation, which will be turned off with #26621.

  7. pllim commented on Sep 21, 2023

    @pllim
    Author

    may have to rethink what we do for nightly wheel uploads

    What are your options?

    In the meantime, I can probably separate out testing of matplotlib dev and numpy dev into different jobs, but I can see the tech debt hitting us downstream in the long run.

  8. ksunden commented on Sep 21, 2023

    @ksunden
    Member

    I think one option would be to build our nightlies using the numpy nightlies rather than using numpy stable.

    That would probably mean more complicated CI on our end since I think we would have to have a job that specifically builds that to upload as I don't think we want the job that runs on main/our release process to use nightlies for building our wheel artifacts.

    It's not 100% clear to me what the ABI break will look like. They have said something about it being "behind a feature flag", so it may be that the nightlies continue to be ABI compatible for most of the cycle and its only a small amount at the end that we have to worry about it at all, or it may be that nightlies are where they flip the switch early and we need to adapt sooner.

  9. ianthomas23 commented on Sep 21, 2023

    @ianthomas23
    Member

    I suspect some of it can be worked around with careful ordering and/or pip install --no-build-isolation --no-deps trickery, though mildly frustrating.

    This made me laugh! In my experience most Open Source involvement is at least mildly frustrating.

    The numpy<2 pin in contourpy is following the official recommendation.

    To test contourpy against numpy 2.0 in CI there is a post-build step of

    python -m pip install --pre --upgrade --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
    

    which works fine to test contourpy against numpy>=2.

    I figure other projects need to do something similar. If anyone has any better suggestions I am all ears.

  10. pllim commented on Sep 21, 2023

    @pllim
    Author

    Brute force reinstall does work, but it resulted in warning from pip resolver, and duplicate code. Not pretty but better than nothing. spacetelescope/jdaviz#2472

  11. story645 commented on Sep 21, 2023

    @story645
    Member

    Not pretty but better than nothing. spacetelescope/jdaviz#2472

    Total tangent but really liking the trivial label and thinking we should adopt something similar/make more use of our only needs one review label.

  12. tacaswell commented on Oct 3, 2023

    @tacaswell
    Member

    I'm going to close this as something we can not fix at the Matplotlib level (because it is pip respecting the pinning of released versions of down stream packages who are following a shared upstream's pinning request).

    For better or worse, if you want to live on the edge of things sometimes you have to fight the packaging system a bit.

  13. neutrinoceros commented on Feb 28, 2024

    @neutrinoceros
    Contributor

    contourpy is now publishing nightly builds without the pin
    xref contourpy/contourpy#362

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions