Coder Social home page Coder Social logo

Comments (14)

djhoese avatar djhoese commented on June 8, 2024 1

Thanks for the notes on installing the dev files. Still waiting on unit tests before merging the PR.

from aggdraw.

djhoese avatar djhoese commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

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.

mfschmidt avatar mfschmidt commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

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.

mfschmidt avatar mfschmidt commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

It's a bug in setup.py! I think I've figured it out. My mistake. Updates coming soon...

from aggdraw.

mfschmidt avatar mfschmidt commented on June 8, 2024

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.

mfschmidt avatar mfschmidt commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

@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.

mfschmidt avatar mfschmidt commented on June 8, 2024

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.

djhoese avatar djhoese commented on June 8, 2024

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.

mfschmidt avatar mfschmidt commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.