I need to write a package into a repository, but it is a small quick package, so I don't see the need to put files into a subdirectory. I simply want:
import mypkg.module1 with directory structure
root_folder/ - setup.py - __init__.py # the init for package "mypkg" (empty) - module1.py And I don't want to be constrained to increase the folder hierarchy like here:
root_folder/ - setup.py - mypkg/ # WHY would I do that for 1 module?? - __init__.py - module1.py # Content of setup.py from setuptools import setup setup(name='MyPkg', packages=['mypkg'] package_dir={'mypkg': '.'}) but as a result, import mypkg fails, and import module1 works, instead of the desired import mypkg.module1.
I found this question, but the answer of "just move setup.py one folder up" does not suit me.
After finding setup argument documentation here, I tried to define a namespace package:
# Content of setup.py with a namespace package from setuptools import setup setup(name='MyPkg', packages=['thisdir'] package_dir={'thisdir': '.'}, namespace_packages=['mypkg'])
py_modulesthough.