views:

64

answers:

2

We see that programs like apt-get store information in several places:

/var/cache/apt      <- cache
/var/lib/apt        <- keyrings, package db, states, locks, mirrors
/etc/apt            <- configuration file
~/.aptitude/config  <- user configuration file

So we see four kinds of paths here:

  1. Cache path
  2. Data path
  3. System-wide configuration
  4. User configuration

Perhaps (1) can be made part of (2) for simplicity sake. Can anyone think of ways to get such appropriate paths in platform-independent way? Is there a library that does this, or does one have to invent this wheel?

A: 

Do you mean something like virtualenv?

lazy1
No. Where does `virtualenv` come into the picture here?
Sridhar Ratnakumar
It stores the installed files in the environment directory which IIRC is platform independent.Or maybe I don't understand the question ...
lazy1
+1  A: 

For Linux, check out the Filesystem Hierarchy Standard (but be aware that these standards are for software being part of distribution, software installed locally should not interfere with distribution's package management and stay in /usr/local/ and /var/local/).

If you want to be truly cross-platform, IMO best way would be to leave this things configurable for packager, defaulting to run in current directory (so that users without administrative privileges can simply unpack and run program). This way, people packaging for particular OS/distribution will set sensible values for system-wide installation, and users will be able to use it locally without administrative rights for the machine.

Maciej Pasternacki
I recommend the XDG basedir spec, http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html, which is more detailed than FHS about global and user-local locations for configuration, cache, and data.
ephemient