-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mplcairo-0.1 #6
Comments
I think "preshing's cairo.dll" (https://github.com/preshing/cairo-windows/releases) statically links it. See also (3).
This is intentional (the pth trick, see e.g. https://www.reddit.com/r/Python/comments/1g94vc/are_pth_file_hacks_elegant_or_evil/; I use
The following works for me:
(one can One can also do
to check that the pth file is working.
Indeed. Did this change recently? That part of the docs was written a few months ago and I am happy to fix it (not that this changes anything to the build strategy I think(?), as I still cannot "steal" the symbols from |
The
I see. I missed that the multi-line statements were in an
I was not reporting that mplcairo does not function (it seems to works well!) but that simply importing mplcairo leads to segfaults when closing the Python interpreter window without quitting the interpreter first (at least it does on my computer).
No, I did not change this recently. I was just wondering if there was a specific reason why those cairo binaries should not work. Anyway, it's probably best to leave it to the distributor of binaries which freetype enabled cairo library to link/ship. |
So overall, is there a problem or something that needs to be fixed? I don't think I follow your point.
Oh, I see, I misread the original message. I can reproduce this (on Windows only), or rather I can get the "Python stopped working" window pop up. Likely some stuff that gets torn down in the wrong order? I don't have experience with debugging on Windows so any insights would be welcome here. Edit: I figured out that this happens during deallocation of the MathTextParser class (
pycairo binaries are not useful on Windows anyways because I can't steal the symbols from them (unlike on POSIX systems, where after importing (at the Python level) pycairo, the cairo symbols become available to everyone). So in a sense the whole discussion in the README was indeed written in a somewhat confusing way. What I should have referred to is anaconda and conda-forge's cairo (not pycairo), which on Windows is built without FreeType support and thus cannot be used. AFAICT you do not distribute cairo (not pycairo) binaries so I didn't need to mention you for that specific point. I have updated the README, does it look clearer now? You can point to your cairo of choice by setting the LINK environment variable, as documented in https://github.com/anntzer/mplcairo#windows. As a side note, if you have some time to spare and are interested in looking into it, generating wheels with Raqm support (for complex text layout, e.g. Arabic and Hebrew) would be greatly appreciated (likely relevant code in _raqm.cpp and _os.cpp, I think just dumping raqm.dll next to every other file should be sufficient). |
freetype.dll needs to be included in the official wheels. Or linked statically. |
Why? The official wheels include cairo.dll, which statically link freetype. |
Because the
|
|
A clean non-conda install (from python.org) also works. |
You probably have |
Ah, I see, I was implicitly relying on freetype.dll being provided by conda's matplotlib package (or rather its dependency freetype) that was installed in the root environment. Thanks for pointing that out! I plan to just grab freetype.dll from conda and put it next to cairo.dll. Sounds good? |
How does the wheel at https://ci.appveyor.com/project/anntzer/mplcairo/build/artifacts look for you? |
Interestingly, on Linux, I can get the same segfault on Py3.7 (not Py3.6) by importing both mplcairo and pandas into the same IPython (not plain python), and then exiting IPython (again, |
@cgohlke Can you check whether the following patch fixes the issue re: segfault at shutdown for you? It does fix the issue I described in the previous comment, and the suggested cause (see comment) at least seems plausible...
|
Unfortunately not. I just tried mplcairo-0.1.post6+g5a4ec01.d20180814 with your patch on Python 3.7. |
Reported the issue upstream to pybind11 (I can repro it independently of mplcairo), let's see if something comes out of it. If not, I can probably make the MathTextParser instance live at Python-level and refetch it everytime (the cost is negligible compared to the actual parse), which may also help... |
Actually I just wrote d7390dd, which should fix (work around) the issue. Can you give it a try? |
I think all issues are fixed now (on master), feel free to request a reopen if not. |
@cgohlke I realized that in the 0.1 release, I was not loading the function pointers for vector output (matplotlib/matplotlib#12636); upon fixing this (469de4d), it appears that the cairo.dll build I'm using (from https://github.com/preshing/cairo-windows) gives blank output when rendering pdfs (already reported to the packager: https://preshing.com/20170529/heres-a-standalone-cairo-dll-for-windows/#IDComment1047546463). |
This works for me (is that what you meant?):
|
Does the pdf contain a plot, or is it blank? (I get a blank pdf with my build.) If this works, would you mind if I put the wheels you provide on PyPI? I will acknowledge you, of course. |
Windows 10 x64, Python 3.6.6 x64, matplotlib 3.0.2, mplcairo 0.1.
|
As noted in this issue the Windows 0.1 wheel is actually broken unless you are using conda's matplotlib. |
Can you repackage those wheels and upload them to PyPi as 0.1.1-ish for Windows only? https://www.lfd.uci.edu/~gohlke/pythonlibs/#mplcairo isn't a PyPi index (and uses Javascript obfuscation to prevent programmatic downloading), and I don't want to package 4 different wheels and select one at install time (and I don't know if Poetry understands that either). (On Linux, I have to |
Can you check whether mplcairo-0.1-1-cp36-cp36m-win_amd64.whl at https://github.com/anntzer/mplcairo/releases/tag/v0.1 works for you? If yes it'll go on PyPI. mplcairo naturally depends on cairo. On Unix systems, I decided to push the "how to find cairo" problem to pycairo (mostly because downstream packagers would rip out libcairo.so if I bundled it in anyways). Right now there's no pycairo manylinux wheels, so you need to get the dependencies from apt (for example). If you want to change that, you should comment on the pycairo tracker. |
the 64-bit wheel, I think cp37, works for me. (will you upload all 4?) It seems that mplcairo _util.h needs Cairo headers. |
I don't want to upload wheels I cannot build myself (or via CI). You may be able to use a local wheel index (https://stackoverflow.com/questions/51873465/pip-install-from-wheel-and-repository), not sure if poetry knows how to handle that but that belongs to their tracker. If you're building from source then you'll need the cairo headers for sure. |
Added a py37 wheel to https://github.com/anntzer/mplcairo/releases/tag/v0.1. Please confirm it works for you. |
I noticed a few issues with mplcairo-0.1:
the Windows wheel is missing freetype.dll.
the file mplcairo.pth seems wrong, containing literal "\n" instead of line breaks.
on Windows, I get a segfault when closing the Python interpreter window after executing
import mplcairo
. I am unable to get a stacktrace.the documentation claims that the cairo binaries at https://www.lfd.uci.edu/~gohlke/pythonlibs/ are not built with freetype support, however I am sure they are.
The text was updated successfully, but these errors were encountered: