17

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'.

1 Answer 1

13

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 ...).

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.