Skip to content
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

aggdraw does not some to be able to find fonts when installed in a venv #74

Open
eteq opened this issue May 28, 2021 · 3 comments
Open

Comments

@eteq
Copy link

eteq commented May 28, 2021

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?

@eteq
Copy link
Author

eteq commented May 28, 2021

(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)

@eteq
Copy link
Author

eteq commented May 28, 2021

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?

@djhoese
Copy link
Member

djhoese commented May 31, 2021

Normally pkgconfig is the last resort for finding freetype:

aggdraw/setup.py

Lines 101 to 110 in bd751fc

FREETYPE_ROOT = os.getenv('AGGDRAW_FREETYPE_ROOT')
for func in (_get_freetype_config, _get_freetype_with_ctypes,
_get_freetype_with_pkgconfig):
if FREETYPE_ROOT is None:
FREETYPE_ROOT = func()
if FREETYPE_ROOT is None:
print("=== freetype not available")
else:
print("=== freetype found: '{}'".format(FREETYPE_ROOT))

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:

['freetype-config', '--prefix']).strip().replace(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants