Reputation: 95
I would like to install my python application as a command line tool that should work entirelly inside the install directory (for example C:\Python26\Lib\site-packages\application) The problem is I would like to reffer in runtime to the submodules and resources from within the application directory three. If I install the app with [console_scripts] option the default path is the current directory. Is there a elegant way to keep the current execution path of the application to the site-packages directory?
Thanks
Upvotes: 1
Views: 317
Reputation: 3767
Not sure if this is what you're after but doing this might work.
import os
dir_of_current_module = os.path.dirname(__file__)
Once you know the dir, you can chdir() to it or do what you want. Remember: You might not always have permissions to do stuff there.
Upvotes: 1