aggdraw does not some to be able to find fonts when installed in a venv
eteq opened this issue · comments
Minimal steps to reproduce (on Ubuntu 21.04, Python 3.9):
in terminal
% python -m venv aggdrawtest
% source aggdrawtest/bin/activate
% pip install aggdraw
% python
in python:
>>> import aggdraw
>>> aggdraw.Font('black', '/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: cannot load font (no text renderer)
By contrast, if I do sudo apt install python3-aggdraw
I see this in python:
>>> import aggdraw
>>> aggdraw.Font('black', '/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf')
<Font object at 0x7f3847abcd10>
Clearly something is going wrong in the venv install. Any ideas?
(note I see the same error if I do python setup.py install
in the same venv. Which really ought to be true but hey sanity checks are nice)
Aha! I figured out the problem, although I'm not sure what the best solution is here:
It turns out aggdraw
was not finding freetype because pkgconfig
was not installed. When I installed it, python setup.py install
worked. However, even if I do pip install pkgconfig
before the pip install aggdraw
, it still doesn't work. My hunch is that something is wrong with the wheel? At any rate, I have a workaround that works for me locally at least.
I'll try to make a PR to at least catch this error, but the wheel probably needs fixing too?
Normally pkgconfig is the last resort for finding freetype:
Lines 101 to 110 in bd751fc
Do you have the output from when you run pip install (or python setup.py install)? Some of the messages should show whats going on inside the setup.py.
We do not currently have wheels published for Python 3.9 (see #73) so no matter how you install it into a python 3.9 environment it will be building from source. The wheels (for non-3.9 versions) should have freetype expected/builtin.
I don't know anything about the debian packages. What version does it install? Is it built from source with freetype? Do they include any patches to this source to hardcode the location of the freetype library? There's a lot of stuff that could be going on to make this work better.
Do you get any result if you do which freetype-config
? If so, what about freetype-config --prefix
? I ask because:
Line 62 in bd751fc