Repository navigation
Description
Bug summary
Since the release of Matplotlib 3.9.1 I have been experiencing CI failures on ContourPy on Windows only that did not occur with Matplotlib 3.9.0. There is some info in my PR contourpy/contourpy#406 that works around it by pinning matplotlib<3.9.1 on Windows. I am not really sure what the problem is, but I now have a simple reproducer.
Code for reproduction
from contourpy import contour_generator
import matplotlib.pyplot as plt
print("START")
cont_gen = contour_generator(z=[[0, 1], [2, 3]])
try:
cont_gen.filled(2.0, 1.0)
except Exception as e:
print("EXCEPTION HANDLER", e)
print("END")Actual outcome
If you run the above code with matplotlib 3.9.1 and contourpy 1.2.1 (the latest releases) it works OK with correct output of
START
EXCEPTION HANDLER upper_level must be larger than lower_level
END
Note the code imports some of matplotlib but does not use it, and the contourpy code here does not use it either.
If you use matplotlib 3.9.1 or nightly wheel and contourpy nightly wheel then it silently crashes for me with just
START
But if you comment out the import matplotlib... line it works OK again. Use of matplotlib 3.9.0 and any contourpy (1.2.1 or nightly wheel) is always OK.
For my installations here I am pip installing into python-only conda environments, i.e.
conda create -n temp python=3.12
conda activate temp
pip install matplotlib contourpyExpected outcome
See above.
Additional information
There is a relevant post by @BertJorissen on the pybind11 gitter which has some in-depth analysis and leads me to believe that this is not just a ContourPy problem.
Operating system
Windows only
Matplotlib Version
>= 3.9.1
Matplotlib Backend
No response
Python version
I see same results for python 3.8 to 3.12.
Jupyter version
No response
Installation
pip
Activity
ianthomas23 commentedon Jul 12, 2024
I suppose the first stage here is to confirm if any other Matplotlib devs can reproduce this on Windows.
BertJorissen commentedon Jul 14, 2024
Hi Ian
my problem originated from using inheritance on an Pybind11-class, which has a function that throws some error.
I see that your function above calls
SerialContourGenerator, which is a child class from the Pybind11-ContourGenerator, which will throw astd::invalid_argument-exception. It thus seems to be the same issue indeed.The error comes from matplotlib, as both my test program and contourpy work happily next to each other, but they crash when matplotlib has been loaded (but not necessarily used).
From comparing the releases 3.9.0 and 3.9.1, there does not seem to be any problem that I can point out immediately.
I see however that the wheels are also repaired on windows. I'm not sure if this is necessary. When I turned this repairing on before, my package seemed to behave weirdly.
Best
Bert
story645 commentedon Jul 14, 2024
I can't reproduce b.c I keep getting this error when trying to install nightly:
ianthomas23 commentedon Jul 15, 2024
@story645 I use something like this:
python -m pip install "matplotlib==3.9.1" python -m pip install --only-binary=:all: --pre --upgrade --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple contourpyto give matplotlib 3.9.1, numpy 2.0.0 and contourpy 1.3.0.dev1
story645 commentedon Jul 17, 2024
Thanks @ianthomas23 and ran your code and can reproduce:
ianthomas23 commentedon Jul 24, 2024
I've created a repo to demonstrate this at https://github.com/ianthomas23/mpl-test. If you look at the github action run https://github.com/ianthomas23/mpl-test/actions/runs/10079751371 you'll see that it uses the reproducer code from above both with and without the matplotlib import for various combinations of mpl and contourpy versions. The interesting addition is a run that builds mpl 3.9.1 from source using MSVC and this passes the tests, compared to the official wheel (built using the
cibuildwheelmachinery in the mpl repo) which fails the tests.nquetschlich commentedon Jul 24, 2024
I am very happy that I stumbled over this issue because since two weeks, also the CI pipeline for one of our open-source projects fails on windows without any (useful) error message (see, e.g., https://github.com/cda-tum/mqt-predictor/actions/runs/9824223458/job/27126370262).
Unfortunately I do not have the time to create a minimal working example, but downgrading Matplotlib to <v3.9.1 solved the issue (see munich-quantum-toolkit/predictor#258).
I just wanted to mention it, seems like we ran into the same issue as you did.
ianthomas23 commentedon Aug 1, 2024
I have labelled this "release critical" as there is evidence of 3 downstream libraries suffering crashes on Windows using Matplotlib 3.9.1, so it is not specific to ContourPy. I need help with this.
tacaswell commentedon Aug 1, 2024
So to summerize:
Given that locally built wheels work I suspect that this is not a problem in Matplotlib source, but is something is the build process. My two suspicions are:
It looks like delvewheel had releases on April 17 (1.6.0), Jun 20 (1.7.0) and July 3 (1.7.1). We did 3.9.1 on July 4 and 3.9.0 on May 15 so that means we likely got delvewheel 1.6.0 for mpl3.9.0 and 1.7.1 for mpl3.9.1.
It looks like pybinb11 had release on Mar 27 (2.12.0), Jun 25 (2.13.0) and Jun 26 (2.13.1) which means we likely got 2.12.0 for mpl3.9.0 and 2.13.1 for mpl3.9.1. However, given that locally built wheels work (and CI has kept working), I am a bit skeptical that it is pybind11 alone. However, I do have some concern that there could be some interaction between c-extensions using pybind11 with different versions of pybind11 conflicting with each other. I have never seen any discussion of this being a concern and I trust the pybind11 devs that if this were a known issue they would make it well known, but I do not actually understand how pybind11 works well enough to to explain why it is not a possible problem so would like my assumption checked.
Open technical question:
delvewheeldoes it then break? If so, can you try multiple versions to see if that affects it.Open policy question:
I'm going to put this on our meeting agenda for the call today.
72 remaining items
deps: Bump matplotlib version
jfuruness commentedon Sep 12, 2024
On github actions, on windows, using pypy3 and matplotlib 3.9.2, I get what seems to be the same error. Oddly though, I only get the error on certain repos of mine that use matplotlib, and not others:
tacaswell commentedon Sep 12, 2024
@jfuruness I suspect your issues is that you are using pypy310 which we do not provide wheels for (yet) and something is going wrong with your local build. Please see the install docs on building from source on windows.
jfuruness commentedon Sep 13, 2024
@tacaswell Ah I didn't realize, thank you for the explanation. Looking at a few of the past prior releases I don't see wheels for pypy310, is there a plan to add these in the future (and perhaps a gh issue I could follow)?
QuLogic commentedon Sep 13, 2024
We were waiting for NumPy wheels numpy/numpy#24728; it looks like those are out, but they didn't close the issue, so I wasn't notified.
jfuruness commentedon Sep 13, 2024
@QuLogic Ah makes sense, sounds good! Thank you both for you support of matplotlib!
Update matplotlib deps used in slides
pin matplotlib<3.9.1 as temp fix for windows CI
pin matplotlib<3.9.1 as temp fix for windows CI
pin matplotlib<3.9.1 as temp fix for windows CI
pin matplotlib<3.9.1 as temp fix for windows CI
pin matplotlib<3.9.1 as temp fix for windows CI
fix: patch basilisk flames_env package versions
fix: make `bioconductor-flames` compile for `linux` again (#68065)