Bug 50134

Summary: xpyb support in waf
Product: pycairo Reporter: Martin Scholz <scholz.m82>
Component: generalAssignee: Steve Chaplin <d74n5pohf9>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: Arfrever.FTA, scholz.m82
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix xpyb check in py2cairo
Fix xpyb check in pycairo

Description Martin Scholz 2012-05-19 19:08:01 UTC
Would be nice to know how to enable xpyb/XCB support in py2cairo for xpyb, so I don't need to totally rewrite the gentoo ebuilds for it.
Comment 1 Martin Scholz 2012-05-19 19:16:07 UTC
totally forgot to mention it is the waf I need the way for... :)
sometimes I'm to fast in typing
Comment 2 Steve Chaplin 2012-05-22 05:13:11 UTC
Add the following lines to wscript:

xpyb_version_required  = '1.3'

ctx.check_cfg(package='xpyb',
                atleast_version=xpyb_version_required,
                args='--cflags --libs',
                mandatory=False)

The changes are in the git repository.
Comment 3 Arfrever Frehtes Taifersar Arahesis 2012-08-11 19:33:21 UTC
http://cgit.freedesktop.org/py2cairo/commit/?id=2f1f3788fa2d9b693c77645edc44f35e7073aadd and http://cgit.freedesktop.org/pycairo/commit/?id=cbb102e3d0735028c624583264ce5243d93ef844 added only xpyb.pc file, but xpyb can be installed for different Python version.

xpyb currently supports only Python 2, so it can be installed e.g. for Python 2.7 and /usr/lib64/pkgconfig/xpyb.pc will exist, but pycairo built with Python 3.2 will detect xpyb.pc presence and at run time fail with:

>>> import cairo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cairo/__init__.py", line 18, in <module>
    from ._cairo import *
ImportError: cairo/_cairo.cpython-32.so: undefined symbol: PyCObject_Import
>>>

Please add 'import xcb' check in wscript:

try:
  import xcb
except ImportError:
  pass
else:
  ctx.check_cfg(package='xpyb', ...)
Comment 4 Arfrever Frehtes Taifersar Arahesis 2012-08-11 19:34:19 UTC
(In reply to comment #3)
> added only xpyb.pc file

added only check for xpyb.pc file
Comment 5 Steve Chaplin 2012-08-13 10:01:57 UTC
I don't think your fix is correct.
Waf is designed, I believe, so the version of Python used to configure and build a software package is independent from the version of Python that the package actually uses. Your fix assumes the version of Python waf uses is the same version of Python that the software package will use.

When xpyb is released for Python 3, is should probably use a different file name from 'xpyb.pc'.
For example for GTK+ the files used are
gtk+-2.0.pc
gtk+-3.0.pc
So each major version of a package has its own .pc file, to avoid clashing with the previous version's file.

I've commented out the code in wscript for Python 3, so that should fix the problem for the moment.
Comment 6 Arfrever Frehtes Taifersar Arahesis 2012-08-13 21:36:07 UTC
Created attachment 65519 [details] [review]
Fix xpyb check in py2cairo
Comment 7 Arfrever Frehtes Taifersar Arahesis 2012-08-13 21:36:52 UTC
Created attachment 65520 [details] [review]
Fix xpyb check in pycairo
Comment 8 Arfrever Frehtes Taifersar Arahesis 2012-08-13 21:38:10 UTC
Please review the new patches, which address the problem mentioned in comment #5.
Comment 9 Arfrever Frehtes Taifersar Arahesis 2012-09-12 02:10:37 UTC
Could these patches be applied?
Comment 10 Steve Chaplin 2012-09-20 02:45:25 UTC
The code update from comment 5 fixes the reported bug.
So it is unclear what additional bug your latest patch is addressing, especially as xpyb does not support yet Python 3.
Comment 11 Christoph Reiter 2017-07-05 15:26:20 UTC
Since 1.11 pycairo uses distutils for building. There is a good chance that
this bug no longer occurs with the new system. If there are still problems
please file a bug: https://github.com/pygobject/pycairo/issues

xpyb support can be enabled there by using: "python2 setup.py build --enable-xpyb" (It defaults to off)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.