I have made a package and install it with pip (have created a sdist package). However when I execute the script that was at the same time install too /usr/local/bin/
it errors because the modules it is trying to import are installed too /usr/local/lib/python2.7/site-packages/MyApplication/Modules/
is there a way to make pip install the execution path to the correct location so when i execute the script from the terminal (any dir) it runs from the correct place?
I have answered this myself and for brevity am putting the answer up incase someone else comes across the same problem.
Before my module imports happen I do a check of the install location for my modules directory. I am then adding this to the sys.path
. This has worked perfectly.
sites = site.getsitepackages()
for item in sites:
if os.path.exists(item + "/PackageName/modules/__init__.py"):
path = item
sys.path.append(path + '/PackageName/')