Cython.distutils.Extension does not play nicely with setupegg.py

323 views
Skip to first unread message

Thomas Wiecki

unread,
Feb 3, 2012, 1:59:24 PM2/3/12
to cython...@googlegroups.com
Hi,

I switched to using the Cython.distutils.Extension but when trying to
use it through the setupegg.py wrapper (i.e. setuptools for
development install), I get:

>sudo python setupegg_switch.py develop
Traceback (most recent call last):
File "setupegg_switch.py", line 7, in <module>
execfile('setup_switch.py')
File "setup_switch.py", line 30, in <module>
ext_modules = [Extension("wfpt", ["src/wfpt.pyx"]),
#extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp']),
File "/home/wiecki/tools/cython/Cython/Distutils/extension.py", line
108, in __init__
**kw)
TypeError: unbound method __init__() must be called with Extension
instance as first argument (got Extension instance instead)

Any fix?

Thomas

Adam Klein

unread,
Feb 5, 2012, 5:17:23 PM2/5/12
to cython...@googlegroups.com
Hi all,

I am trying to write a Cython extension type, Timestamp, that mimics datetime but enriches it with metadata. This is for the timeseries functionality we're trying to build up in pandas.

It seems like I cannot derive from datetime directly.  I tried this, and it worked syntactically, but there seems to be no way to intercept the constructor call and construct the super class appropriately.

So I went with composition, where datetime is a member variable.  However, I cannot get this sort of thing to work:

datetime <comparison> Timestamp

while this is just fine:

Timestamp <comparison> datetime

How would you all approach this situation?

Thanks in advance,
 Adam

Stefan Behnel

unread,
Feb 6, 2012, 2:14:53 AM2/6/12
to cython...@googlegroups.com
Adam Klein, 05.02.2012 23:17:

> Hi all,
>
> I am trying to write a Cython extension type, Timestamp, that mimics
> datetime but enriches it with metadata.

Hi,

please do not hijack threads. Start a new one instead.

Stefan

Didrik Pinte

unread,
Feb 6, 2012, 6:00:49 AM2/6/12
to cython...@googlegroups.com

The workaround is to make sure you import setuptools before distutils
and it will work fine.

The following just work fine for me :

---------------------------------------------------
from setuptools import setup
from distutils.extension import Extension

from Cython.Distutils import build_ext
from Cython.Build import cythonize


setup (...)
---------------------------------------------------

-- Didrik

Thomas Wiecki

unread,
Feb 6, 2012, 10:40:09 AM2/6/12
to cython...@googlegroups.com
Thanks, can you retry your example with using:

from Cython.Distutils import Extension

instead of

from distutils.extension import Extension

and see whether that still works?

Thomas

mark florisson

unread,
Feb 6, 2012, 11:19:33 AM2/6/12
to cython...@googlegroups.com
If you have setuptools installed, why not try it out yourself? (And
please don't suddenly start top-posting)

Thomas Wiecki

unread,
Feb 6, 2012, 12:49:36 PM2/6/12
to cython...@googlegroups.com
On Mon, Feb 6, 2012 at 11:19 AM, mark florisson
<markflo...@gmail.com> wrote:
> If you have setuptools installed, why not try it out yourself? (And
> please don't suddenly start top-posting)

Sorry. I did try it, but it didn't work so I wanted to make sure it
wasn't an issue with my installation.

Thomas Wiecki

unread,
Feb 6, 2012, 5:18:04 PM2/6/12
to cython...@googlegroups.com
Here is example code that triggers this behavior:

from setuptools import setup
from Cython.Distutils import Extension
Extension('foo', ['*.pxd'])

On Mon, Feb 6, 2012 at 12:49 PM, Thomas Wiecki

Leon Baum

unread,
Feb 23, 2012, 1:28:54 PM2/23/12
to cython-users
Hi,

Have you found a solution or workaround? I am running into this
problem with Cython 0.15.1 as well trying to build pandas from
https://github.com/pydata/pandas/tree/datetime64

I can also reproduce your example.

-Leon

Thomas Wiecki

unread,
Feb 24, 2012, 9:05:42 AM2/24/12
to cython...@googlegroups.com
My (ugly) work-around is to copy the contents of the setup.py file to
the setupegg.py file and remove the cython files. The c files then get
generated by calling setup.py and you can develop install via the
separate setupegg.py.
Reply all
Reply to author
Forward
0 new messages