setuptools does not generate .c files out of .pyx files

203 views
Skip to first unread message

Francesc Alted

unread,
Mar 24, 2011, 6:11:51 AM3/24/11
to cython...@googlegroups.com
Hi,

I've recently go nuts with this issue:

http://www.velocityreviews.com/forums/t693861-cython-setuptools-not-
working-with-pyx-only-with-c-files.html

For what is worth, I solved this explicitly by using:

"""
def get_cython_extfiles(extnames):
extdir = 'tables'
extfiles = {}

for extname in extnames:
extfile = os.path.join(extdir, extname)
extpfile = '%s.pyx' % extfile
extcfile = '%s.c' % extfile
if not exists(extcfile) or newer(extpfile, extcfile):
# For some reason, setup in setuptools does not compile
# Cython files (!) Do that manually...
print "cythoning %s to %s" % (extpfile, extcfile)
os.system("cython %s" % extpfile)
extfiles[extname] = extcfile

return extfiles

cython_extnames = [
'utilsExtension',
'hdf5Extension',
'tableExtension',
'linkExtension',
'_comp_lzo',
'_comp_bzip2' ]

cython_extfiles = get_cython_extfiles(cython_extnames)
"""

and then using extensions like this:

extensions = [
Extension( "tables.utilsExtension",
include_dirs=inc_dirs,
define_macros=def_macros,
sources=[ cython_extfiles['utilsExtension'],
... (other C files),

Hmm, I'm wondering if it would be better if Cython comes with its own
'setup' module. That would make it more resistant to setuptools-like
tools.

--
Francesc Alted

Stefan Behnel

unread,
Mar 24, 2011, 6:17:45 AM3/24/11
to cython...@googlegroups.com
Francesc Alted, 24.03.2011 11:11:

> I've recently go nuts with this issue:
>
> http://www.velocityreviews.com/forums/t693861-cython-setuptools-not-
> working-with-pyx-only-with-c-files.html
> [...]

> Hmm, I'm wondering if it would be better if Cython comes with its own
> 'setup' module. That would make it more resistant to setuptools-like
> tools.

FWIW, I think I heard that this setuptools bug is fixed in distribute (as
are many others).

Stefan

Robert Bradshaw

unread,
Mar 24, 2011, 4:01:07 PM3/24/11
to cython...@googlegroups.com

See http://wiki.cython.org/enhancements/distutils_preprocessing This
also handles things like dependency checking for cimports and
includes.

- Robert

Francesc Alted

unread,
Mar 25, 2011, 3:48:13 AM3/25/11
to cython...@googlegroups.com
A Dijous 24 Març 2011 21:01:07, Robert Bradshaw va escriure:

> > Hmm, I'm wondering if it would be better if Cython comes with its
> > own 'setup' module. That would make it more resistant to
> > setuptools-like tools.
>
> See http://wiki.cython.org/enhancements/distutils_preprocessing This
> also handles things like dependency checking for cimports and
> includes.

Ah, that's great. I'll probably end using this. Thanks!

--
Francesc Alted

Reply all
Reply to author
Forward
0 new messages