473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cython dynamic library problem

I am trying to learn how to use cython, and while I am following the
cython-dev
mailing list I didn't feel like this question was totally appropriate
for its audience
so I am trying here first.

I am on a max os x 10.5.4 running

drtgrav% python
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:40:23)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I have a pure python file that I am wanting to try to speed up some,
so I ran the file through cython, compiled it with gcc and tried to
call it from a python file
cython integrations.pyx
gcc -arch ppc -shared -c -fPIC -I/usr/include/python2.5
integration.c -o pyx_integration.so
python integration_test.py
Traceback (most recent call last):
File "integration_test.py", line 1, in <module>
from astroPyX import pyx_integration
ImportError: dlopen(/Users/drtgrav/Work/myCode/Python/astroPyX/
pyx_integration.so, 2): no suitable image found. Did find:
/Users/drtgrav/Work/myCode/Python/astroPyX/pyx_integration.so: can't
map

where integration_test.py is

from astroPyX import pyx_integration

pyx_integration.test(0)
pyx_integration.test(100)

Does anyone know what the ImportError means and how to correct it?

Cheers
Tommy
Sep 18 '08 #1
4 2807
Tommy Grav <tg***@mac.comwrites:
I am trying to learn how to use cython, and while I am following the
cython-dev
mailing list I didn't feel like this question was totally appropriate
for its audience
so I am trying here first.
[...]
Does anyone know what the ImportError means and how to correct it?
I would try to use `distutils` because this package is much wiser
than me and knows all necessary switches for gcc. ;)

# test_cython.pyx
def test(x):
return x * x

# test_cython.py
from pyx_test import test

print test(0)
print test(10)

# setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext as build_pyx

setup(name = 'pyx_test',
ext_modules=[Extension('pyx_test', ['test_cython.pyx'])],
cmdclass = { 'build_ext': build_pyx })
$ python2.5 setup.py build_ext -i
running build_ext
cythoning test_cython.pyx to test_cython.c
building 'pyx_test' extension
creating build/temp.linux-i686-2.5
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c test_cython.c -o build/temp.linux-i686-2.5/test_cython.o
test_cython.c:86: warning: function declaration isnft a prototype
test_cython.c:241: warning: function declaration isnft a prototype
test_cython.c:59: warning: e__pyx_skip_dispatchf defined but not used
gcc -pthread -shared -Wl,-O1 build/temp.linux-i686-2.5/test_cython.o -o pyx_test.so
$ python2.5 test_cython.py
0
100
HTH,
Rob
Sep 18 '08 #2
Rob Wolfe:
# setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext as build_pyx

setup(name = 'pyx_test',
ext_modules=[Extension('pyx_test', ['test_cython.pyx'])],
cmdclass = { 'build_ext': build_pyx })

$ python2.5 setup.py build_ext -i
running build_ext
cythoning test_cython.pyx to test_cython.c
building 'pyx_test' extension
creating build/temp.linux-i686-2.5
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c test_cython.c -o build/temp.linux-i686-2.5/test_cython.o
test_cython.c:86: warning: function declaration isnt a prototype
test_cython.c:241: warning: function declaration isnt a prototype
test_cython.c:59: warning: __pyx_skip_dispatch defined but not used
gcc -pthread -shared -Wl,-O1 build/temp.linux-i686-2.5/test_cython.o -o pyx_test.so
$ python2.5 test_cython.py
0
100
With some intelligence added to Cython, probably there are ways to
reduce all this, and most of the times avoid any setup.py module too.

Bye,
bearophile
Sep 18 '08 #3
On Sep 18, 2008, at 12:35 PM, Rob Wolfe wrote:
I would try to use `distutils` because this package is much wiser
than me and knows all necessary switches for gcc. ;)
That worked! Thanks

Cheers
Tommy
Sep 18 '08 #4

On Sep 18, 2008, at 12:35 PM, Rob Wolfe wrote:
>
I would try to use `distutils` because this package is much wiser
than me and knows all necessary switches for gcc. ;)
That worked! Thanks

Cheers
Tommy
Sep 18 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
3
by: K.S.Liang | last post by:
Hi all, 1> If there are more than one dynamic linking libraries in the file system, how do I know which one is loaded into system? Any C library or system call can tell me which *.so or *.sl is...
6
by: MikeY | last post by:
Hi Everyone, Does anyone know where I can get my hands on a sample with source code of a simple dynamic button control in C# Windows form. I am looking for a sample that uses a class library...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
5
by: David Lees | last post by:
August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py translator on the demo code. But when I try compiling, I get an error complaining that my...
0
by: Stefan Behnel | last post by:
Hi, just a quick announcement that I finished the port of the Cython compiler to the Py3 target platform. While you cannot currently run Cython itself in Py3, you can build the generated C...
1
by: martin.nordstrom87 | last post by:
Hi! I'm trying to wrap numpy with Cython and I've tried to use this guide to manage this: http://wiki.cython.org/WrappingNumpy However when I send an array to mysum() it gives me the right answer...
1
by: Srijit Kumar Bhadra | last post by:
Cython Installation on Windows documentation (http://wiki.cython.org/ InstallingOnWindows) needs a minor but important change. Under section "MinGW Compiler" compiler = mingw32 should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.