Giter Site home page Giter Site logo

Comments (6)

SimonSapin avatar SimonSapin commented on May 11, 2024

Hi,

I think you’re looking for cairocffi.install_as_pycairo(). What this function does is that if import cairo for from cairo import … is run later, cairocffi is imported instead of pycairo.

So if you’re using a Python library that itself uses pycairo, run this code:

import cairocffi
cairocffi.install_as_pycairo()

… before importing that library. Every thing should just work.

For a Python command-line tool where you’re not writing any Python code it’s a bit more tricky. Either:

  1. Patch the tool to add the code above so that it’s run as early as possible
  2. Write your own command line script that has the above code and then calls the tool’s main() function. Hopefully the tool has a well-delimited main function that you can import.

Does this help?

from cairocffi.

codeodor avatar codeodor commented on May 11, 2024

Yes, I think I'm going to have to do the latter, though I was hoping there was a way for you to distribute it that way for other folks who may not be comfortable or knowledgable enough to consider patching it themselves.

Thanks for the advice!

from cairocffi.

SimonSapin avatar SimonSapin commented on May 11, 2024

Yet another option is to have a cairo.py in your sys.path containing this:

from cairocffi import *

But this is more brittle because you have to make sure it takes priority over pycairo (or that pycairo is not installed, or use a virtualenv with --no-site-packgaes, …)

from cairocffi.

codeodor avatar codeodor commented on May 11, 2024

Actually, that's probably easier for my case. Thanks!

I did already have the virtualenv set up with that flag, and did not have pycairo set up to begin with.

from cairocffi.

SimonSapin avatar SimonSapin commented on May 11, 2024

I documented this trick: http://pythonhosted.org/cairocffi/overview.html#compatibility-with-pycairo

from cairocffi.

codeodor avatar codeodor commented on May 11, 2024

👍

from cairocffi.

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.