Comments (6)
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:
- Patch the tool to add the code above so that it’s run as early as possible
- 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.
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.
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.
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.
I documented this trick: http://pythonhosted.org/cairocffi/overview.html#compatibility-with-pycairo
from cairocffi.
👍
from cairocffi.
Related Issues (20)
- All tests fail with ModuleNotFoundError: No module named 'cairocffi._generated.ffi' HOT 2
- Minor fix for m1 Macs with CFFI issues
- No module named 'cairocffi._generated' HOT 6
- libffi errors after cffi update to 1.15.1 HOT 5
- test_xcb tests are considered too unstable HOT 5
- Test failures with cairo 1.17.6 HOT 4
- Support for Offline Builds HOT 4
- The "changelog" link in the README displays only versions, not changes HOT 2
- please include LICENSE in the PyPI tarball
- Can't install new release HOT 7
- Cairocffi not building with XCB support in 1.5.0 HOT 15
- 1.5.0 is no longer compatible with Msys2 Mingw HOT 6
- Fixing cairocffi[xcb] installation issues once for all HOT 24
- Offline installation is not possible to due build script HOT 2
- Hack to import constants.py breaks installation via PyInstaller HOT 5
- API compatibility with Pycairo: TextExtents
- API compatibility with Pycairo: Composite Operators
- Basic Usage example doesn't work on 1.6.0 and 1.6.1 HOT 2
- Documentation links to 32-bit GTK version HOT 1
- Interoperability issue with pycairo for ImageSurface.create_for_data and numpy data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cairocffi.