question about cython vs python3

609 views
Skip to first unread message

Neal Becker

unread,
Oct 23, 2012, 8:04:03 AM10/23/12
to cython...@googlegroups.com
I maintain Cython for Fedora. I've received a question:


----------------------
Andy Grover 2012-10-22 19:30:08 EDT
I have a pkg newly converted to build using Cython called python-kmod. I'm
trying to add a python3-kmod subpackage but am hitting this error when calling
"python3 setup.py build":

Traceback (most recent call last):
File "setup.py", line 23, in <module>
from Cython.Distutils import build_ext as _build_ext
ImportError: No module named 'Cython'

I think we need a python3 Cython subpackage that contains Cython libs for Python
3.
----------------------

I'm not sure how to respond. I don't think a python3 Cython package is needed,
since Cython is not intended as a run-time module. But I don't know what is the
use-case above. Is the above the normal intended build process using Cython?
What little I've used cython, I've used it as a cli. But if above represents
encouraged existing practice, then I suppose a python3 package is needed.

Stefan Behnel

unread,
Oct 23, 2012, 8:37:24 AM10/23/12
to cython...@googlegroups.com
Neal Becker, 23.10.2012 14:04:
The above is not exactly encouraged. Packagers/distributors/authors should
ship their readily generated C sources instead of requiring an arbitrary
Cython version on the user side that may or may not generate the expected C
sources for their code. Still, it's not wrong for packages to depend on
Cython at build time, so this should be supported.

Note that Cython usually installs as a binary package because it compiles
parts of itself during installation. That means that the installed package
is different for (almost) every Python x.y version, not only Python 2 vs. 3.

Alternatively, it can be installed as a pure Python package by passing the
"--no-cython-compile" option to setup.py. In that case, it will use 2to3 to
convert the sources to Python 3, which means that separate Python 2 and
Python 3 packages would still be needed.

Does this help?

Stefan

Neal Becker

unread,
Oct 23, 2012, 9:10:56 AM10/23/12
to cython...@googlegroups.com
Yes, that is helpful. I see that cython encourages building using:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

which (IMO unfortunately) requires then a cython version for each python version
that might be used. I say unfortunate, since the only purpose is to allow the
above import to succeed on each python version (and in fact they all would do
the same thing).

Bradley Froehle

unread,
Oct 23, 2012, 1:24:22 PM10/23/12
to cython...@googlegroups.com
Debian has an experimental Cython 3 package (http://packages.debian.org/experimental/cython3), although how to split the `cython` executable script between the cython & cython3 packages is still in the works (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=686045).

-Brad

Stefan Behnel

unread,
Oct 24, 2012, 3:17:27 AM10/24/12
to cython...@googlegroups.com
Bradley Froehle, 23.10.2012 19:24:
> Debian has an experimental Cython 3 package
> (http://packages.debian.org/experimental/cython3), although how to split
> the `cython` executable script between the cython & cython3 packages is
> still in the works
> (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=686045).

I don't see a reason to have both. The problem is only how to use it as a
build dependency. When users run it from the command line, it doesn't
matter which they use (as long as it's the same version, obviously). So one
set of command line scripts is enough.

Stefan

Neal Becker

unread,
Oct 24, 2012, 6:58:12 AM10/24/12
to cython...@googlegroups.com

Neal Becker

unread,
Oct 30, 2012, 9:44:13 AM10/30/12
to cython...@googlegroups.com
fedora now has both Cython and python3-Cython packages. It all went smoothly,
the only thing I did other than the fedora guidelines is to install the python3
bins as
cython3
cygdb3

Reply all
Reply to author
Forward
0 new messages