In your myproj root directory for this project, you want to move module1.py and module2.py into a directory named myproj under that, and if you wish to maintain Python < 3.3 compatibility, add a __init__.py into there.

You may also consider using setuptools instead of just distutils. setuptools provide a lot more helper methods and additional attributes that make setting up this file a lot easier. This is the bare minimum setup.py I would construct for the above project:

This signifies that the setup script has picked up the required source files. Run the python interpreter (preferably outside this project directory) to ensure that those modules can be imported (not due to relative import).

On the other hand, if you wish to provide those modules at the root level, you definitely need to declare py_modules explicitly.

Finally, the Python Packaging User Guide is a good resource for more specific questions anyone may have about building distributable python packages.

Email codedump link for How do I distribute all contents of root directory to a directory with that name