Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Robert Bradshaw <robertwb <at> math.washington.edu>
Subject: Re: possible to check python version on import
Newsgroups: gmane.comp.python.cython.user
Date: Wednesday 2nd February 2011 10:36:31 UTC (over 5 years ago)
On Mon, Jan 31, 2011 at 2:22 AM, Sebastian Haase 
wrote:
> Hi,
>
> I am trying to do my first steps with cython.
> By accident I compiled with python2.6 while I'm otherwise using Python
2.5.
> So the error I got was:
>
>>>> primes.primes(4)
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "primes.pyx", line 3, in primes.primes (primes.c:443)
>    def primes(int kmax):
> TypeError: __int__ returned non-int (type int)
>
>
> Is there any way to check python versions of a module - at least to
> give a warning... ?

That's a good idea, can anyone think of a reason this should not be done?

http://trac.cython.org/cython_trac/ticket/657

> [email protected]:~/qq/cython: cd Demos/
> [email protected]:~/qq/cython/Demos: python setup.py build_ext --inplace
> Compiling primes.pyx because it changed.
> Compiling spam.pyx because it changed.
> Compiling numpy_demo.pyx because it changed.
> running build_ext
> building 'primes' extension
> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
> -Wall -Wstrict-prototypes -fPIC
>
> creating build
> creating build/temp.linux-x86_64-2.6
> compile options: '-I/usr/include/python2.6 -c'
> gcc: primes.c
> gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
> build/temp.linux-x86_64-2.6/primes.o -o
> /net/storage/shaase/qq/cython/Demos/primes.so
> building 'spam' extension
> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
> -Wall -Wstrict-prototypes -fPIC
>
> compile options: '-I/usr/include/python2.6 -c'
> gcc: spam.c
> gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
> build/temp.linux-x86_64-2.6/spam.o -o
> /net/storage/shaase/qq/cython/Demos/spam.so
> building 'numpy_demo' extension
> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
> -Wall -Wstrict-prototypes -fPIC
>
> compile options: '-I/usr/lib/pymodules/python2.6/numpy/core/include
> -I/usr/include/python2.6 -c'
> gcc: numpy_demo.c
>
/usr/lib/pymodules/python2.6/numpy/core/include/numpy/__multiarray_api.h:1187:
> warning: '_import_array' defined but not used
> /usr/lib/pymodules/python2.6/numpy/core/include/numpy/__ufunc_api.h:196:
> warning: '_import_umath' defined but not used
> gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
> build/temp.linux-x86_64-2.6/numpy_demo.o -o
> /net/storage/shaase/qq/cython/Demos/numpy_demo.so
>
>
>
>
> [email protected]:~/qq/cython/Demos: python
> Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import primes
> starting
>>>> primes.primes(4)
> [2, 3, 5, 7]
>>>>
> [email protected]:~/qq/cython/Demos: python2.5
> python2.5         python2.5-config
> [email protected]:~/qq/cython/Demos: python2.5
> Python 2.5.5 (r255:77872, Nov 28 2010, 16:43:48)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import primes
> starting
>>>> primes.primes(4)
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "primes.pyx", line 3, in primes.primes (primes.c:443)
>    def primes(int kmax):
> TypeError: __int__ returned non-int (type int)
>
 
CD: 2ms