Re: Advice on distutils and distribution policies



Mardy wrote:
Hi,
  I've built a small project (http://eligante.sf.net) which I'm actually
trying to package using distutils.
....
However, I don't know if this directory layout is suitable for
site-packages, since at a first glance it looks to me that datafiles might
not be welcome under it. Is it so?

In general, it's a good idea to keep code and data separated:

 - Different people might need to access code and data. People who
   add content to a web site shouldn't be able to make a mess of the
   software that controls that web site (or vice versa).
 - Lifecycles are different, so different backup strategies might apply.
 - Directory structures such as /usr under unix are typically fairly
   static on production systems, and there might be assumptions that
   required space doesn't grow over time, whereas data, kept under
   /var is expected to change more over time. Also, if e.g. web content
   is kept in a separate disk partition, filling that partition won't
   mess up other parts of the computer system.
 - It should be easy to upgrade the software without messing up data.
   It's practical if it's safe to e.g. do
   "rm -rf /usr/lib/python2.3/site-packages/eligante" followed by
   a new "python setup.py install" in case a sys admin thinks that
   his old install was broken.

For a CGI-based app on e.g. a linux box with Apache, I think it would
be typical to partition things like this:

In an apache cgi-bin directory: The main Python CGI script(s) that
are called by the web server. These might be scripts that are modified
as a part of the installation process to e.g. point out data files.
These should be short files. Import a module, set up configuration
and run something in the imported module.

Under /usr/lib/python2.x/site-packages/ you keep the bulk of your
software (as described above).

HTML and CSS files that are to be handled directly by the web browser
is placed under Apache's DOCUMENT_ROOT etc. E.g.
$DOCUMENT_ROOT/eligante.

Data files that are read and processed by you own programs (i.e. not
directly by the web server) van be anywhere under /var, e.g.
/var/eligante.


In that case, where should I move the .html files, and how should I access
them from inside python?

Asolute path defined by an environment variable?

I think Apache defines a DOCUMENT_ROOT variable. You
could decide that your HTML files etc should reside in
some particular place relative to DOCUMENT_ROOT, and
use something like...

import os
SUB_FOLDER = 'my_folder'
dir = os.path.join(os.environ['DOCUMENT_ROOT'],SUB_FOLDER)

....to locate your files.

As I wrote above, hardcoding in a main CGI-script is also
common practice.
.



Relevant Pages

  • Re: XP and drivers- what should stay on the C drive?
    ... recovery disks appear to install some of the drivers and XP Home ... I keep my data files (documents, drawings, photos, spreadsheets, programs I ... The remainder of my HD has a large logical drive that I store my Drive Image ... partition would also be backed up so you don't lose them as well. ...
    (microsoft.public.windowsxp.newusers)
  • Re: School computer virus update
    ... There is another solution for recovering your data files if you don't have ... install Windows XP in that partition (being careful to write down the ...
    (microsoft.public.security.virus)
  • Re: bypass migration in startup outlook 2003
    ... did a fresh install and I was able to reconnect to my personal folders. ... Sue Mosher, Outlook MVP ... profile name exists but does not show any access to any data files. ...
    (microsoft.public.outlook.installation)
  • Re: Thank you all...
    ... system in either Normal Mode or Safe Mode. ... Install" of Windows XP, which retains your data files and software. ...
    (microsoft.public.windowsxp.general)
  • Re: reload winxp
    ... If you do a new install over your previous xp os you will have to reinstall ... all your programs and you will lose your data files. ... all your data files then do a "repair" install. ... >>MS-MVP Windows - Shell/User ...
    (microsoft.public.windowsxp.general)