How can I get my setup.py to use a relative path to my files?

Posted by Chris B. on Stack Overflow See other posts from Stack Overflow or by Chris B.
Published on 2009-05-01T17:00:33Z Indexed on 2010/06/15 4:22 UTC
Read the original article Hit count: 230

Filed under:
|

I'm trying to build a Python distribution with distutils. Unfortunately, my directory structure looks like this:

/code
    /mypackage
        __init__.py
        file1.py
        file2.py
        /subpackage
            __init__.py
    /build
        setup.py

Here's my setup.py file:

from distutils.core import setup

setup(
    name = 'MyPackage',
    description = 'This is my package',
    packages = ['mypackage', 'mypackage.subpackage'], 
    package_dir = { 'mypackage' : '../mypackage' }, 
    version = '1',
    url = 'http://www.mypackage.org/',
    author = 'Me',
    author_email = '[email protected]',
)

When I run python setup.py sdist it correctly generates the manifest file, but doesn't include my source files in the distribution. Apparently, it creates a directory to contain the source files (i.e. mypackage1) then copies each of the source files to mypackage1/../mypackage which puts them outside of the distribution.

How can I correct this, without forcing my directory structure to conform to what distutils expects?

© Stack Overflow or respective owner

Related posts about python

Related posts about distutils