I run Python 3.3 (Anaconda distribution) under Windows 7, 64-bit. I have attempted to install the Weasyprint app/library, which has a number of dependencies, of which Cairo is one. I have put a lot of work into solving this problem, which I summarize below. I have attempted to be totally complete with this bug report, so I would appreciate your taking a close look.
The environment I have is as follows: Windows 7 SP1 64-bit, Python 3.3 64 bit (CPython, as compiled and distributed by the www.python.org site), CFFI compiled (by me) under Visual Studio 2010 with a 64-bit environment, and Cairo's libcairo-2.dll also in the 64-bit version available from cairographics.org. From what I can tell, my version of the Cairo dll (which is the one I downloaded from the cairographics.org site) was compiled under Visual Studio 2008, which appears to be causing the problem. [This is only my guess, I am NOT an expert Windows programmer]
When I run weasyprint, it chokes during the import loading process, specifically when it calls CFFI (a DLL loader for Python) in order to load the GTK+-compatible library dll for Cairo. The error that I get is as follows:
Traceback (most recent call last):
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 399, in _make_ffi_library
backendlib = backend.load_library(name, flags)
OSError: cannot load library libcairo-2.dll: error 0x7e
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda\envs\py33\Scripts\weasyprint-script.py", line 9, in <module>
load_entry_point('WeasyPrint==0.20', 'console_scripts', 'weasyprint')()
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 2355, in load_entry_point
File "C:\Anaconda\envs\py33\lib\site-packages\pkg_resources.py", line 2061, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\__init__.py", line 309, in <module>
from .css import PARSER, preprocess_stylesheet
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\css\__init__.py", line 30, in <module>
from . import computed_values
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\css\computed_values.py", line 18, in <module>
from .. import text
File "c:\anaconda\envs\py33\lib\site-packages\weasyprint-0.20-py3.3.egg\weasyprint\text.py", line 18, in <module>
import cairocffi as cairo
File "c:\anaconda\envs\py33\lib\site-packages\cairocffi-0.5.1-py3.3.egg\cairocffi\__init__.py", line 39, in <module>
cairo = dlopen(ffi, 'libcairo-2.dll', 'cairo', 'libcairo-2')
File "c:\anaconda\envs\py33\lib\site-packages\cairocffi-0.5.1-py3.3.egg\cairocffi\__init__.py", line 34, in dlopen
return ffi.dlopen(names) # pragma: no cover
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 117, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "c:\anaconda\envs\py33\lib\site-packages\cffi-0.8-py3.3-win-amd64.egg\cffi\api.py", line 405, in _make_ffi_library
backendlib = backend.load_library(path, flags)
OSError: cannot load library C:\Windows\system32\libcairo-2.dll: error 0x7e
I have tried to rebuild the Cairo library using the "end to end" instructions, but the instructions are for use under Visual Studio 2008, and I have Visual Studio Express 2010 (with Windows SDK 7.1 installed), which does not have vcbuild.exe, and as a result I cannot follow the instructions given at http://cairographics.org/end_to_end_build_for_win32/). Furthermore, because my Python was built with VS 2010, I believe I am obligated to use a Cairo DLL compiled with the same version. Correct me if I am wrong.
I am not a Windows programmer, and am only delving into this mess because I want to get Weasyprint to work for another (Python language) project. I have done a minor bit of Windows programming a long time ago under Delphi, so I have a vague grasp of how this stuff works, but I have been unable to solve this problem.
I would be happy to put the work into compiling Cairo for my platform/configuration, and would make the resulting file(s) available for redistribution, but I will need at least some assistance in doing so.
-- GitLab Migration Automatic Message --
This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/167.