473,397 Members | 1,950 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,397 software developers and data experts.

Problem with custom extension: help needed

Greetings,
I wrote a couple of custom dummy extensions in Python (one a pure Python
and the other a C) and i managed to compile and install them without a
problem:

[josevnz@linux0037 TestNative]$ make
python2 setup.py build
running build
running build_py
creating build
creating build/lib.linux-i686-2.2
creating build/lib.linux-i686-2.2/test
copying src/python/test/Dummy.py -> build/lib.linux-i686-2.2/test
copying src/python/test/__init__.py -> build/lib.linux-i686-2.2/test
running build_ext
building 'test.NativeDummy' extension
creating build/temp.linux-i686-2.2
gcc -DNDEBUG -O2 -g -pipe -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC
-fPIC -DMAJOR_VERSION=0 -DMINOR_VERSION=0 -I/include
-I/usr/include/python2.2 -c src/c/dummy.c -o
build/temp.linux-i686-2.2/dummy.o
gcc -shared build/temp.linux-i686-2.2/dummy.o -L/lib -lm -o
build/lib.linux-i686-2.2/test/NativeDummy.so

So far the RPM installation looks ok too and seems to be than the
installed files are on the proper location:

make rpm
.....
moving build/bdist.linux-i686/rpm/SRPMS/python-TestNative-0.0-1.src.rpm
-> dist
moving
build/bdist.linux-i686/rpm/RPMS/i386/python-TestNative-0.0-1.i386.rpm ->
dist

[root@linux0037 root]# rpm -ihv
/home/josevnz/python/TestNative/dist/python-TestNative-0.0-1.i386.rpm
Preparing... ###########################################
[100%]
1:python-TestNative ###########################################
[100%]

[root@linux0037 root]# rpm -ql python-TestNative
/usr/lib/python2.2/site-packages/test/Dummy.py
/usr/lib/python2.2/site-packages/test/Dummy.pyc
/usr/lib/python2.2/site-packages/test/NativeDummy.so
/usr/lib/python2.2/site-packages/test/__init__.py
/usr/lib/python2.2/site-packages/test/__init__.pyc
But when i run a custom script that uses both extensions i got the
following error:

[josevnz@linux0037 TestNative]$ ./scripts/Test.py
../scripts
/usr/lib/python2.2
/usr/lib/python2.2/plat-linux2
/usr/lib/python2.2/lib-tk
/usr/lib/python2.2/lib-dynload
/usr/lib/python2.2/site-packages
/usr/lib/python2.2/site-packages/gtk-2.0
/usr/lib/python2.2/site-packages/test
Traceback (most recent call last):
File "./scripts/Test.py", line 18, in ?
import test.Dummy
ImportError: No module named Dummy
[josevnz@linux0037 TestNative]$
The script code seems normal to me:

#!/usr/bin/env python2
#
# Hello world to test native interfaces in Python
#
# Fix the path
import os.path
import sys
new_path="/usr/lib/python2.2/site-packages/test"
new_path=os.path.abspath(new_path)
sys.path.append(new_path)
debug=1

if debug:
for path in sys.path:
print path

import test.Dummy
import test.NativeDummy

argument1 = "Test string argument"
argument2 = 600000
dumber = test.Dummy.Dummy("really dumb")
test.NativeDummy(argument1, argument2)
Here is my setup.py file:

#!/usr/bin/env python2
#
# Hello world to test native interfaces in Python
#
from distutils.core import setup, Extension

VERSION=0
RELEASE=0

extension1 = Extension('test.NativeDummy',
define_macros = [('MAJOR_VERSION', VERSION),
('MINOR_VERSION', RELEASE)],
include_dirs = ['/include'],
libraries = ['m'],
library_dirs = ['/lib'],
sources = ['src/c/dummy.c'])

setup (name = 'python-TestNative',
version = '0.0',
description = 'My practice native test with Python.',
author = 'Jose Vicente Nunez Zuleta',
author_email = 'ZZZZZ',
url = 'XXXX',
package_dir = {'' : 'src/python'},
packages = ['test'],
long_description = '''
My practice native test with Python.
Hope this works.
''',
ext_modules = [extension1])

I'm using Python 2.2 on RedHat7.2

What do i need to fix so Python can load my extensions?

Thanks in advance,
--
Jose Vicente Nunez Zuleta (josevnz at newbreak dot com)
Newbreak LLC System Administrator
http://www.newbreak.com
Jul 18 '05 #1
0 1732

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

Similar topics

2
by: John | last post by:
I tried to search for a solution to this, but I couldn't find one. Maybe I didn't look in the right place, but whatever.... Here is the problem - I have an extension "Myextension" created using...
68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
1
by: noone | last post by:
I upgraded VS 2003 and asked my ISP (MaximumASP) to upgrade the server to net 1.1. That was two weeks ago and I am having a problem that will not go away. When publishing the site from VS I get an...
5
by: bryan | last post by:
If I understand correctly, I can write a custom handler for a given extension (say .abcd files) by writing a class that implements the IHttpHandler interface and then registering it in my web...
0
by: CBVenkat | last post by:
Hi, I am trying to add a new extension to the WSDL definition to include the following tag: <foo:compress type="xxxxxx"> <foo:addon name="a1"> <foo:parameter name="thePart" value="xxxx">...
7
by: Flashster | last post by:
My program writes text to a file. Currently the files have a suffix of '.log' . I want to make sure that the user does not attempt to open a file that was not originally created by my program. ...
1
by: Michael Russell | last post by:
Hi all, Sorry for the repost, but I never received any response when I first asked this a few weeks ago. I would really appreciate some feedback on this, it's driving me nuts... I'm...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
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: 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?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.