[cairo] Merging py2cairo into pycairo

Simon Sapin simon.sapin at exyr.org
Thu Dec 20 23:59:05 PST 2012


Hi,

I think that py2cairo should be merge into pycairo so that we get a 
single git repository and releases with a single tarball each that 
installs in both Python 2 and 3, with the same code base.

Why
---

py2cairo and pycairo are really the same project: they import the under 
the same Python name, they provide the same API, any change to one 
generally should be made to the other, some projects (such as WeasyPrint 
and CairoSVG) have the same code using either depending on the Python 
version.

More practical reasons are ease of maintenance and distribution. A 
single code base is always easier to maintain than two. Making (almost) 
the same patch twice to add the same functionality is silly. A single 
code base also reduces the risk of the two versions diverging. As to 
distribution: I hope to have a single pycairo entry in PyPI (Python 
Package Index) so that WeasyPrint can just use

     install_requires=[…, 'pycairo']

in its setup.py file. Without the merge (but assuming new releases with 
my patch to add py2cairo’s setup.py file back) every project using 
pycairo would need something like this:

     py3 = sys.version_info >= (3,)
     install_requires=[…, 'pycairo' if py3 else 'py2cairo']


Who
---

I’m willing to do the work, but first I’d like to make sure it has a 
chance of getting "upstream" in a cairographics.org release.


How
---

There are well-known techniques to have the same code running on both 
Python 2 and 3, including for C extension modules:

http://python3porting.com/cextensions.html

Some tricks can help with "polyglot" code, but the ultimate approach is 
conditional compilation:

     #if PY_MAJOR_VERSION >= 3
         /* … */
     #else
         /* … */
     #endif

The result would be more verbose than eg. py2cairo alone, but I believe 
that conditional code can be kept to a manageable minimum.

The documentation would be merge too, and the (small) Python 2/3 API 
differences be noted inline. I hope we can get HTTP redirects setup on 
http://www.cairographics.org/documentation/pycairo/{2,3}/**

At some point in the process I want to do a git "merge commit" so that 
the history of both repositories is retained, and setup tox so that 
tests can easily (and automatically) be run in multiple Python versions.


Licenses
--------

The current pycairo is under a LGPLv3 license, while py2cairo has a dual 
LGPLv2.1 / MPLv1.1 license. What does it mean for a potential merge? 
Should I keep only LGPLv3? Who do I need to ask about this?


Thoughts?
-- 
Simon Sapin


More information about the cairo mailing list