472,337 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 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 1671

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 -...
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,...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL...
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...
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...
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...
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...
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...
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???? ...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

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.