What option do I need in setup.py to create the package in the right directory?

25,507

The description to how to do this an be found in the distribute documentation... Within a directory containing all of the project (TowelStuff/ in the given example) you specify the name of the actual module (towelstuff/). To include this as your module you need to add the following line in setup.py:

'packages': ['towelstuff']

After having created the sdist (from within TowelStuff/), the installation of this package will install it under site-packages/towelstuff, which can be imported as usual (from towelstuff import ...).

Share:
25,507

Related videos on Youtube

Alex
Author by

Alex

Updated on September 27, 2020

Comments

  • Alex
    Alex over 3 years

    I am using setup.py to create a python package, which I want to install via pip. To correctly install the files under

    lib/python2.7/site-packages/<package-name>
    

    I used the following option in setup.py:

    'package_dir': {'':'lib'}
    

    as described here but get an error

    error: package directory 'lib' does not exist
    

    Well, there is no such directory as I want the current directory to be installed as package lib or whatever. I also tried to use

    'package_dir': {'mycode':''}
    

    which installes the code directly in

    lib/python2.7/site-packages/
    

    and not under

    lib/python2.7/site-packages/<package-name>
    

    What am I doing wrong, and where is this documented? I might overlooked the documentation of this basic feature as the documentation for setup.py is 'suboptimal'.