I am trying to compile fontforge from source with Python 3. I recently manged to compile it on Ubuntu workstation and now have to install it on a Debian or Ubuntu Server and run into a strange error.
I am using the Version https://github.com/fontforge/fontforge/archive/20161012.tar.gz
as imho this one has the import psMat
problem solved.
My compile steps:
./bootstrap
PYTHON="python3" ./configure
make -j3
make install
The relevant configure output:
Configuration:
Source code location .
Build code location
Destination prefix /usr/local
Compiler gcc -std=gnu99 -std=gnu99
Summary of optional features:
real (floating pt) double
programs yes
native scripting yes
python scripting yes
python extension yes
freetype debugger no
raw points mode no
tile path no
gb12345 encoding no
potrace or autotrace yes
...
But when I do python3 -c "import fontforge; f = fontforge.font()"
it results in:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'font'
A python3 -c "import fontforge; print(dir(fontforge))"
gives a:
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
Somehow the fontforge module is empty?
More details
make install
outputs an
Libraries have been installed in:
/usr/local/lib/python3.4/site-packages
And indeed:
ls -la /usr/local/lib/python3.4/site-packages
total 48
drwxr-sr-x 2 root staff 4096 Nov 30 21:53 .
drwxrwsr-x 4 root staff 4096 Nov 30 21:53 ..
-rwxr-xr-x 1 root staff 1429 Nov 30 21:53 fontforge.la
-rwxr-xr-x 1 root staff 13992 Nov 30 21:53 fontforge.so
-rwxr-xr-x 1 root staff 1405 Nov 30 21:53 psMat.la
-rwxr-xr-x 1 root staff 13968 Nov 30 21:53 psMat.so
I tried it on Debian 8 and Ubuntu 16.04. I also tried it with the additional --enable-python-scripting --enable-pyextension --enable-python-extension
options for ./configure
. Also a ldconfig
after make install didn't help.
When I did install it on my Workstation I did use a Virtual Enviroment and a custom--prefix
. However, I also also tried this on the Debian server but without success.
The servers have been fresh installs before testing.
I also tried with the latest version from git.
Does anybody has an idea what is wrong with my installation process?
Update
I did another test, this time with an virtual env again. When I did a
python -c "import fontforge;print(fontforge)"
<module 'fontforge' (namespace)>
it seems that an import fontforge doesn't load the .so file but the fontforge directory in /root/venv/lib/python3.4/site-packages
which contains the .so file.
Moving those .so files to the parent dir and remove the fontforge dir:
mv /root/venv/lib/python3.4/site-packages/fontforge/* /root/venv/lib/python3.4/site-packages
rm /root/venv/lib/python3.4/site-packages/fontforge
But now:
python -c "import fontforge"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libuninameslist.so.1: cannot open shared object file: No such file or directory
But the libuninameslist.so.1 file is in /usr/local/lib
.
Update 2
If I add /usr/local/lib/python3.4/site-packages
to the sys.path
everything looks fine.
python3 -c "import sys; sys.path.append('/usr/local/lib/python3.4/site-packages'); import fontforge; f=fontforge.font(); print(f)";
<Font: Untitled1>