473,405 Members | 2,160 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,405 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 2810
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.