Cython + setuptools not working with .pyx,only with .c-files

  • Thread starter Diez B. Roggisch
  • Start date
D

Diez B. Roggisch

Hi,


I'm trying to build a Cython-extension as Egg.

However, this doesn't work - I can either use distutils to build the
extension, creating a myextension.c-file on the way.

If that's there, I can use setuptools to build the egg.

But when I remove the .c-file, the .pyx-file isn't used to re-generate it.

This is my setup.py:

----
import os
import glob
from setuptools import setup, Extension
#from distutils.core import setup
#from distutils.extension import Extension

from Cython.Distutils import build_ext


objs = [...] # a static lib I want to wrap

setup(
name='MyExtension',
version="0.1",
description='',
author='Diez B. Roggisch',
author_email='...',
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("myextension", ["myextension.pyx"],
libraries=["crypto"],
extra_objects = objs)],

-----


I can of course check in the myextension.c-file , and then when actually
working on the extension create it new by uncommenting the above lines.

But I guess that's not really the way things should work...

Diez
 
D

David Cournapeau

Hi,


I'm trying to build a Cython-extension as Egg.

However, this doesn't work - I can either use distutils to build the
extension, creating a myextension.c-file on the way.

If that's there, I can use setuptools to build the egg.

But when I remove the .c-file, the .pyx-file isn't used to re-generate it.

This is my setup.py:

----
import os
import glob
from setuptools import setup, Extension
#from distutils.core import setup
#from distutils.extension import Extension

from Cython.Distutils import build_ext

What happens if you import setuptools *after* Cython.distutils ? My
guess - I could be wrong - is that both Cython.distutils and
setuptools monkey-patch distutils, and that setuptools does not "see"
Cython.Distutils. It could also be an incompatibility between
Cython.Distutils and setuptools (the design of distutils forces you to
take into account the details of things modified by every distutils
extension).

cheers,

David
 
D

Diez B. Roggisch

David said:
What happens if you import setuptools *after* Cython.distutils ? My
guess - I could be wrong - is that both Cython.distutils and
setuptools monkey-patch distutils, and that setuptools does not "see"
Cython.Distutils. It could also be an incompatibility between
Cython.Distutils and setuptools (the design of distutils forces you to
take into account the details of things modified by every distutils
extension).

Tried that, nothing changed :(

Diez
 
D

David Cournapeau

Tried that, nothing changed :(

Then you will have to modify Cython.Distutils to be aware of
setuptools, I think (and soon Distribute... ).

David
 
S

Stefan Behnel

Diez said:
I'm trying to build a Cython-extension as Egg.

However, this doesn't work - I can either use distutils to build the
extension, creating a myextension.c-file on the way.

If that's there, I can use setuptools to build the egg.

But when I remove the .c-file, the .pyx-file isn't used to re-generate it.

setuptools monkeypatch into distutils to support Pyrex if it's installed,
but most non-bleeding-edge versions do not know about Cython and thus break
the Cython distutils support when Pyrex isn't there as well.

What helps is to put a fake Pyrex installation into your sys.path, like

http://codespeak.net/svn/lxml/trunk/fake_pyrex/

as done at the top of

http://codespeak.net/svn/lxml/trunk/setup.py

I haven't tried if newer setuptools versions have been fixed yet.

Stefan
 
D

Diez B. Roggisch

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top