Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cairo python bindings? #9

Open
JamesRamm opened this issue Nov 14, 2014 · 6 comments
Open

Enable cairo python bindings? #9

JamesRamm opened this issue Nov 14, 2014 · 6 comments

Comments

@JamesRamm
Copy link

How to enable cairo python bindings in the mapnik build?

HAVE_CAIRO is defined and mapnik builds with cairo support. But mapnik.have_pycairo() returns false.

@JamesRamm
Copy link
Author

Browsing the code, looks like I need to make sure HAVE_PYCAIRO is defined aswell - mapnik_python.cpp checks for both HAVE_CAIRO and HAVE_PYCAIRO.

I suppose this will not be enough though, because mapnik_python.cpp is gonna attempt to #include pycairo.h and it looks like the cairo build undertaken when building the dependencies didn't do anything about pycairo.. hmf.

So I'm thinking I need to install pycairo, then ensure that my python\include directory where pycairo.h is hopefully gonna turn up is in my list of includes for mapnik-gyp...
Is this the 'normal' way of building with pycairo support?

@JamesRamm
Copy link
Author

Any info on this?
related: mapnik/mapnik-packaging#22

I suspect I am simply not correctly defining library paths in the gyp file, but there isn't much to go on to figure it out....

@JamesRamm
Copy link
Author

Adding cairo.lib to the libraries section of the _mapnik target in the gyp file seems to have done the trick. Also need to add the -lcairo flag.

Easy when you know how - this could really do with documenting.

@JamesRamm
Copy link
Author

Mapnik built with pycairo, but attempting to render to a pycairo context causes the python interpreter to hang.
Seg fault perhaps?

Clearly there is something not right in the build...

@springmeyer
Copy link
Member

I think you are on the right track. I've never tried to get pycairo working on windows, so thanks for helping with this. Can you describe how to installed pycairo exactly?

@JamesRamm
Copy link
Author

Here is what I've done (evidently it is wrong as mapnik won't render with cairo, but mapnik does build happily)

Ok..the version of pycairo I had installed when building was py2cairo-1.10.0 and I just downloaded the installer from gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/) and ran it. That gave me a pycairo.h file in my python installation and a package called cairo containing _cairo.pyd.

In the gyp & bat file, I made sure that the python version being used was the one to which I had installed pycairo. In the _mapnik target section I added cairo.lib and pycairo.h.

This was it. Mapnik builds and tests pass.

Then I tried to run python with mapnik/cairo. First it complained about missing dll's and I followed a tutorial in issue #22 to fill in the missing deps. Cairo then works from python, but attempting to call mapnik.render with a cairo Context ends up with python.exe hanging/crashing.

There is obv. something bad happening at some point, but I am at a loss as to where. Do we need to build our own pycairo bindings?.

I'll put up a step-by-step of what I changed in the build files a little later...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants