views:

39

answers:

1

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

+1  A: 

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.

Mattias Nilsson
Yes this partially works ... Thanks it points to the .egg directory and I only have to append the application name. But it works! Many Thanks!
koleto
Thanks again Mattias! Works perfect for me!
koleto