Let\'s say you have a project called proj
and in this project you have the following structure:
proj/
dists/
doc/
src/
__init__.py
You can try adding the src
folder to the PYTHONPATH
before you call the setup
function:
import sys, os
src_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'src')
sys.path.append(src_path)
And also, just to be on the safe side, you then change the working directory:
os.chdir(src_path)
After that, it should all be OK.
Some other tools for packaging your app support that from within. I thought it was setuptools, turns out it's PyInstaller. But basically, that's what should be done, just enough for your packages to be imported directly.
Turns out distutils has the package_dir
directive. That is what you should use, but it might work by only adding your package to the PYTHONPATH
.