Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

FontForge Python extension #4689

Closed
codingisacopingstrategy opened this issue Mar 15, 2011 · 19 comments
Closed

FontForge Python extension #4689

codingisacopingstrategy opened this issue Mar 15, 2011 · 19 comments

Comments

@codingisacopingstrategy
Copy link
Contributor

Dear HomeBrew,

I have been trying to add FontForge’s python extension as an option to the Homebrew formula, to make it possible to programmaticaly build font files.

I managed to install the python extension when building from source but I can’t seem to get it to work with Homebrew. If anyone is interested in this, my code is here:

https://gist.github.com/871313

This isn’t Homebrew specific. But maybe we can find what’s going on, as upstream doesn’t seem in a hurry to figure out Mac specific problems. Here is some more info on the issue:

http://sourceforge.net/mailarchive/forum.php?thread_name=20101231155535.GA4555%40khaled-laptop&forum_name=fontforge-devel

I was able to get the python fontforge module to work on my Mac as following:

$ brew install gettext pango potrace
$ cd src
$ git clone git://fontforge.git.sourceforge.net/gitroot/fontforge/fontforge;
$ cd fontforge
$ ./configure --enable-double --without-freetype-bytecode --enable-pyextension

In Makefile I changed

then python setup.py install  --prefix=$(prefix) --root=$(DESTDIR);

into

then python setup.py install;

and i ran

$ make
$ sudo make install

I tried to implement this in the formula, but somehow it isn’t working out.
I’m in a bit over my head with these makefiles

I also tried running the formula with sudo (because I figured it was a permissions issue) and with --HEAD.

If anyone can look into this,
thanks a lot!

Eric

@adamv
Copy link
Contributor

adamv commented Mar 16, 2011

I don't think the current FontForge release will compile against Python 2.7.x.

@codingisacopingstrategy
Copy link
Contributor Author

Ah ok. And to build Python modules from HomeBrew we need to use Homebrew’s Python 2.7? Because OS X 10.6 itself comes with 2.6 iirc

@adamv
Copy link
Contributor

adamv commented Mar 16, 2011

Homebrew's 2.7 won't help, FontForge uses an API that was removed or changed in 2.7.

@codingisacopingstrategy
Copy link
Contributor Author

Sorry, I meant, I’m using 2.6, since that’s the version that comes with OS X 10.6.
So this can’t be the problem in my case.

Still that’s bad news though; is this a reported bug?

@adamv
Copy link
Contributor

adamv commented Apr 4, 2011

I'm sorry for letting this slide so long; the current version of Fontforge works; updated the brew in 7b6d6cd

@adamv adamv closed this as completed Apr 4, 2011
@codingisacopingstrategy
Copy link
Contributor Author

Hey Adam, thanks!

Yet, I’m still not sure we were having the same problem :)
how do you build the python extension now then?
Don’t you have to build with --enable-pyextension ?
This is what I want to do, in order so I can

import fontforge

and use it in Python scripts.
But haven’t been able to get it to work.

cheers E

@jescalan
Copy link

Any word on this issue? I would love to get this working but have been struggling to find any documentation or anyone with similar problems...

@lhagan
Copy link

lhagan commented Mar 30, 2012

Still having this issue as well. I was able to get import fontforge to work by building from source as codingisacopingstrategy details above, but not by editing the homebrew formula. To install the fontforge python package, I did have to do:

cd pyhook
python setup.py install

after the make install step, though. Not sure why it didn't work from Make (I did make the Makefile edit).

@jescalan
Copy link

I tried for an extensive period of time to modify the recipe to work (most will have to run sudo python setup.py install), but there's really no way you can pause the install in the middle and run a sudo command in homebrew, and you can't go back and run it after as homebrew deletes the unzipped folder.

I was frustrated with this and created a standalone osx installer for fontforge with python extensions. Makes life even easier - I'm creating an application that needs to be available to the masses (including those not comfortable with the command line).

It's super ghetto and I don't know objective c well, but it works and I've tested it on multiple computers. Here's the repo - a built .app is in there, just open it up and hit the button : ) It will slowly improve (and include an uninstall), but if you know any objective c wizards or you are one yourself by all means feel free to contribute!

https://github.com/jenius/Fontforge-Installer

@codingisacopingstrategy
Copy link
Contributor Author

Jenius' installer is awesome. But for those of us already in the Homebrew ecosystem it would be very convenient to have the python extension in Homebrew too. @adamv you closed this issue but me and the other commenters here still don´t manage to install it. Could you give it another look? It appears as if there is a permissions problem (the makefile attempts sudo python setup.py), do you see a way around this?

@jescalan
Copy link

Definitely agreed - I tinkered with the recipe (and the core) for quite a while trying to figure out a way to get admin permissions, but it seems like homebrew is written very much such that it doesn't have to run anything as root, and by the time I had something that worked it essentially was no longer homebrew.

Seeing as this definitely needs to run a sudo command in the middle, this kind of change might require core modifications, or at least someone who knows a lot more than we do : )

@lhagan
Copy link

lhagan commented Apr 18, 2012

You don't actually have to install Python packages using sudo; in fact it's better not to. Instead, install them to your home folder (or anywhere else you have write access, for that matter). Step-by-step instructions here.

Even with this setup, I still couldn't get the Python package to install using homebrew, but maybe this will help someone else figure out how.

@jescalan
Copy link

I don't think that's an option - we can't reconfigure the user's computer and move around easy_install just to make this one operation go in without sudo. I think what we need is an option in homebrew to execute with admin privileges. To make it even more user-friendly, we could use applescript to pop up the standard enter admin password box rather than asking on the command line.

@lhagan
Copy link

lhagan commented Apr 19, 2012

True, but my point still stands that you don't have to (and I'd argue you should not) use sudo to install Python packages.

An example is PyQt, which you can install using Homebrew. It installs to something like: /usr/cellar/lib/python2.7/site-packages. It should be possible to do something similar with fontforge.

The tradeoff is that, as in my link above, the user still has to edit his PYTHONPATH manually since /usr/cellar/lib/python2.7/site-packages is of course not there by default. The PyQt formula tells the user to do this at the end of the process:

For non-homebrew Python, you need to amend your PYTHONPATH like so:
    export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH

Unless something has changed, I'd think this is the right way to fix this package since the approach has precedent.

@ummels
Copy link
Contributor

ummels commented Jun 2, 2012

Could you test my formula? As suggested by @lhagan , the formula installs the Python bindings into Homebrew's site-packages directory (actually, a symlink is created there), so you may need to change the PYTHONPATH environment variable to use the extension from Python.

@codingisacopingstrategy
Copy link
Contributor Author

That is awesome, thanks. I’ll get around to testing it—for the instant my Homebrew seems broken. I tried to use https://github.com/kennethreitz/osx-gcc-installer on 10.6 instead of XCode because it seems more light-weight, but I’m having a lot of trouble compiling things. I guess I’m better off with XCode no? Sorry for the off-topic…

@davelab6
Copy link
Contributor

davelab6 commented Jul 9, 2012

Eric, any news testing this?

adamv pushed a commit that referenced this issue Jul 27, 2012
Build the Python extension by default and install it to the right location.

Fixes #4689.
Closes #12535.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
@codingisacopingstrategy
Copy link
Contributor Author

Right, for anyone watching this thread, @ummels’ patch has been merged and it works nice and dandy!

If you use a system python, the brew give’s you a pointer how to change the Python Path.
Should be feasible enough for Homebrew’s intended audience of command line wielding dev’s.

Thanks a lot everybody who chimed in!

@jescalan
Copy link

jescalan commented Aug 1, 2012

Excellent, this is really exciting. I'll change my fontforge osx installer to just use the official formula then. Maybe I'll update the UI and make it look a little nicer as well, I've learned a bunch about mac dev since the last time I committed there : )

fgeller pushed a commit to fgeller/homebrew that referenced this issue Aug 22, 2012
Build the Python extension by default and install it to the right location.

Fixes Homebrew#4689.
Closes Homebrew#12535.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Sep 12, 2012
Build the Python extension by default and install it to the right location.

Fixes Homebrew#4689.
Closes Homebrew#12535.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012
Build the Python extension by default and install it to the right location.

Fixes Homebrew#4689.
Closes Homebrew#12535.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants