What option do I need in setup.py to create the package in the right directory?
Question: 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](http://docs.python.org/2/distutils/setupscript.html) 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'.


Answer: The description to how to do this an be found in the [distribute
documentation](https://the-hitchhikers-guide-to-
packaging.readthedocs.io/en/latest/quickstart.html)... 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 ...`).

