On Tue, Sep 9, 2008 at 11:16 PM, Ian Bicking <[EMAIL PROTECTED]> wrote: > Lukasz Szybalski wrote: >> >> On Sun, Sep 7, 2008 at 11:37 AM, Ian Bicking <[EMAIL PROTECTED]> wrote: >>> >>> Lukasz Szybalski wrote: >>>>>> >>>>>> Should I maybe create folder inside of virtualenv called "etc" right >>>>>> next to "bin" or? >>>>>> What would be an easy way to reference it? "from >>>>>> some_pythonpath....import __file__" then connect the folders >>>>>> __file__+"etc"+config.xml? >>>>>> >>>>>> What would be a recommended way to do it? How would you do it? >>>>> >>>>> Is your configuration deployment-specific, or some kind of internal >>>>> configuration? If it's associated with the deployment, I would put it >>>>> in >>>>> ENV/etc/myapp.xml, or ENV/etc/myapp/config.xml, i.e., not connected to >>>>> your >>>>> myapp source code. >>>> >>>> Its a deployment specific. It holds some defaults that user can change. >>>> How would I access ENV ?? from xyz import __file__ ? >>> >>> Generally you'd pass in the location of the configuration file from some >>> command-line that starts the script. You could try >>> os.path.join(print os.path.dirname(__main__.__file__) >> >> , 'etc', 'myapp', >>> >>> 'config.xml') as well, if you want a default. __main__.__file__ should >>> be >>> the location of the script. >> >> Above will work nice when I have the file in >> /somepath/ENV/etc/myapp/config.xml and I load the configuration. >> >> How do I put the file there when I install it do? How from setup.py >> can I know where is my ENV (virtual environment?) is > > You can look at sys.prefix. However, generally setup.py install doesn't > install config files like this. But you could make it do it if you wanted. > >> If I do python setup.py develop the following code will show current >> directory "print os.path.dirname(__main__.__file__)" . >> >> I guess what I want is the code that works in the same manner as >> setup() function and/or include_package_data = True which knows where >> site-package folder is. I want to know where my bin folder is? How can >> I find that out?
I'll play around with the sys.prefix but as a side note, I couldn't find the recommend way to create the config.xml. I want to do something similar as debian where in global installation my config goes to /etc/myapp/config.xml(thats easy everybody does this), but if installed with prefix or virtual env then where should it really go? ~/myapp/config.xml ~/.myapp/config.xml? /home/lucas/ENV/etc/myapp/config.xml??? How would I know ? With sys.prefix I can say 1. if its "/usr" then I know I need to put it in /etc/myapp/config.xml 2. if /home/lucas/ENV/ then I can put it in /home/lucas/ENV/etc/myapp/config.xml 3. What other location could exist? Is there a standard location? Would anybody recommend a better way? Thanks, Lucas _______________________________________________ Paste-users mailing list [email protected] http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users
