Comments (14)
Thanks for the notes on installing the dev files. Still waiting on unit tests before merging the PR.
from aggdraw.
freetype
is not a python library, it is a C library so it can't be listed as a dependency to "just work". pip
has no way of installing C libraries. You could use conda and add the conda-forge
channel and install aggdraw with conda. This will install aggdraw without compiling and I have aggdraw build on conda-forge with freetype support included.
If you know that you have freetype installed in the system and the aggdraw installed isn't finding it you can force it by setting the AGGDRAW_FREETYPE_ROOT
environment variable and pointing it to the prefix where freetype is installed (the parent directory of the lib
directory). However, it seems that aggdraw is finding the freetype library in the temporary directory built by pip which seems very strange to me. Perhaps this is a bug in the setup.py
that it is incorrectly finding a freetype library that isn't actually there (see printed messages in the output above).
@saimn had similar issues on ArchLinux and has been able to pip install aggdraw (#31).
Lastly, it is recommended that you don't installed aggdraw or any other third party python library with sudo
. Typically people make virtual environments or use conda
to not use the system environments. Although I wouldn't expect sudo
privileges to mess with the installation, I've seen weirder things by doing sudo pip
.
from aggdraw.
What packages do you install before installing aggdraw
? Do you installing anything specific with apt
before doing this pip install? Basically, how can I reproduce your environment?
from aggdraw.
Thanks, djhoese. Digging a little...
The setup.py uses three functions to determine freetype libraries, and my setup seems to have found the file 'libfreetype.so.6' with the ctype function. But it never could ascertain the correct full path for it. It's at /usr/lib/x86_64-linux-gnu/libfreetype.so.6. I'm going to clone the repo, add a path to setup.py, and see if it installs OK, or kicks the can down the road, or maybe I'm just wrong. :)
from aggdraw.
The part that confuses me about the output you had is this:
=== freetype found: '/tmp/pip-install-fyrbgiq4'
Which is the temporary directory created by pip. This print message means that setup.py found '/tmp/pip-install-fyrbgiq4/lib/libfreetype.so.6'...WTF.
from aggdraw.
Yeah, I was pasting snippets of code from setup.py into a python console and it basically got a filename without a full path and ended up thinking it was in /home/mike for me. That was my current directory when I invoked the python kernel. I assume /tmp is the working directory for the install and where the path defaults to after falling out of the _get_freetype_with_ctypes() function. Give me a few minutes and I may have something to share.
from aggdraw.
So the _with_ctypes
function used by setup.py
has to guess at some paths on linux due to some "issues" with ctypes on linux (find_library
doesn't return a full path to a library). It tries the current prefix for the current python interpreter which should be /usr
if python3 is in /usr/bin/python3
. I could see pip
modifying this to /tmp/pip-install-fyrbgiq4
so maybe pip is copying/linking the /usr/
directory to the temporary pip directory.
The _with_ctypes
will try sys.prefix
, then /usr
, then /usr/local
. Your freetype is installed in /usr/lib/x86_64-linux-gnu
which is not one of the directories it searches. So...it should be installing without trying to use libfreetype.
from aggdraw.
It's a bug in setup.py
! I think I've figured it out. My mistake. Updates coming soon...
from aggdraw.
Sorry, I wrote that poorly. More clearly and specifically, The function _get_freetype_with_ctypes() does this
from ctypes.util import find_library
ft_lib_path = find_library('freetype')
And find_library returns the string 'libfreetype.so.6'. This is the name of the file, but with no information about where it was found. Later in the function, it tries '/usr' and '/usr/local' and sys.prefix(), which is '/usr' for me. But my system copy of libfreetype.so.6 is in /usr/lib/x86_64-linux-gnu/, which is never checked. So the function knows there's a library, but doesn't know where, and returns '..', which is the working directory.
So, I hard-coded a path into the function to find the .so file, and it did, but then errored the same anyway because it could not find the c header, ft2build.h. I only have the compiled .so library on my system, not the development files.
from aggdraw.
In response to your previous question, I'm running Ubuntu 16.04 and I don't think I've done anything strange to configure it. And just to rule it out, I did my last test in a virtual environment with python 3.5.2 and pip 18.0. Same results.
from aggdraw.
@mfschmidt See the associated pull request (#35) where I have fixed this. I will merge this when the tests pass and make a new release. Just a dumb logic bug by me that I didn't think could happen.
from aggdraw.
I just pasted the code from your pull request into my environment. The setup churned for a little longer than before (still sub-second) and completed successfully. I opened python3 and imported aggdraw with no problems. Thank you for your help!
from aggdraw.
FYI This installs aggdraw without freetype support (so no fonts). You can test this with:
davidh@ubuntu:~/aggdraw$ python3
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from aggdraw import Font
>>> font = Font('black', '/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: cannot load font (no text renderer)
If you use the environment variable (mentioned above) to point to freetype (if not installed in a normal location) it should have this font functionality.
from aggdraw.
Yep, no fonts.
And setting AGGDRAW_FREETYPE_ROOT to /usr/lib/x86_64-linux-gnu resulted in the same errors from before, because I don't have development files available, just the compiled .so file.
For future reference for anyone else ending up here, to make everything work, including fonts, I did this:
unset AGGDRAW_FREETYPE_ROOT
pip uninstall aggdraw
That was just to clean up what I had already done, unnecessary for clean installs.
sudo apt install libfreetype6-dev
pip install aggdraw
Installing libfreetype6-dev first put the development files, including ft2build.h, into /usr/include/freetype2/ where aggdraw's setup.py could use freetype-config to find them. And if you install libfreetype6-dev first, the code fix wouldn't matter, because setup would find the correct files early, before ever searching the system libraries for them.
from aggdraw.
Related Issues (20)
- antigrain.com is squatted HOT 6
- multline text not supported HOT 1
- Line anti-aliasing issues due to missing sRGB mishandling HOT 5
- Resolve differences after agg 2.2 and agg 2.4 migration HOT 3
- aggdraw.Draw, aggdraw.Pen, aggdraw.Brush, etc... are not extendable (apparently) HOT 1
- Cannot install on Windows HOT 2
- MNT: Stop using ci-helpers in appveyor.yml HOT 1
- documentation has left the chat. HOT 1
- Latest Documentation? HOT 7
- pip install results in error Windows 10 21H1 HOT 4
- aggdraw does not some to be able to find fonts when installed in a venv HOT 3
- No arc symbols? HOT 1
- is there a way to draw squircle (rectangle with rounded edges) ? HOT 4
- Add support to release linux aarch64 wheels HOT 3
- PyPy3.8 support HOT 6
- Windows binaries are missing for aggdraw 1.3.13 on pypi.org HOT 4
- The value in the coordinates list cannot exceed 32767. HOT 1
- Diferences between pip version and source-compiled version HOT 4
- Misleading information in the document HOT 6
- freetype not linked correctly in latest macOS Python 3.11 wheels (1.3.17 and 1.3.18) HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aggdraw.