problem writing setup script

Christian Meesters meesters at uni-mainz.de
Mon Sep 24 10:36:40 EDT 2007


Hi

I have the following file structure

MANIFEST
README
INSTALL -- all text
setup.py
src/
    __init__.py
    foo.py
    for_ext.pyx 

and this setup-script:

import sys
from distutils.core import setup
from distutils.extension import Extension
try:
    from Pyrex.Distutils import build_ext
except ImportError:
    __info__ = """
    Please install Pyrex
    (http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/)
    before running this setup script.
    """
    sys.exit(__info__)

setup(
    name = "foo",
    # snip
    packages = ['foo'],
    package_dir={'foo': 'src/'},
    package_data = {'foo': ['README', 'INSTALL']},
    ext_package='foo_ext',
    ext_modules = [
        Extension("foo_ext", ["src/foo_ext.pyx"])
        ],
    cmdclass = {'build_ext' : build_ext}
)

Typing 
sudo python setup.py
runs without warning, however, this results in a file
/usr/lib/python2.5/site-packages/foo/foo.py , which I only can import like
import foo.foo
and not
import foo
in order to access foo's namespace.
Furhtermore a file foo_ext.so will be created
in /usr/lib/python2.5/site-packages, but I would like to see it
in /usr/lib/python2.5/site-packages/foo, since importing foo_ext.so only
makes sense for foo.

Does anybody know how I should change my file structure or the setup-script
to achieve those two goals?

TIA
Christian




More information about the Python-list mailing list