views:

143

answers:

3

This should be a common scenario, but could not find any relevant post yet..

I plan to deploy a Python library (I guess the same applies to regular applications) which makes use of some images and other resource files. What is the standard location for such items? I imagine, for project Foo, the choices would be

  • Have resources directory in the source repository and then move files to /usr/share/foo/
  • Place resources directly inside the python package that goes under /usr/lib/python-<version>/foo/

Any suggestions?

Edit: As suggested, clarifying that the main platform this will be running on is Linux.

+2  A: 

This question is somewhat incomplete, because a proper answer would depend on the underlying operating system, as each has its own modus operandi. In linux (and most unix based OSs) for example /usr/share/foo or /usr/local/share/foo would be the standard. In OS X you can do the same, but I would think "/Library/Application Support/Foo" (although that's usually for storing settings and whatnot) would be the place to put such things, though if you're writing libraries following the "Framework" idea, all the resources would be included in the /Library/Frameworks/Foo.Framework" ... Apps on OS X on the other hand should keeps all there resources within the Resources directory inside Foo.app

Nico
A: 

The standard location is where your standard libs goes. But it doesn't sound to me from what you've written, that you'll want your python lib there. I think you should try out Virtualenv.

If you don't want to go through all the trouble (well, it really just amounts to sudo easy_install virtualenv for you), you could try to just dump your python lib in any dir in your ~/ and do something along the lines of

import sys
sys.path.append( '/full/path/to/your/lib/goes/here')

to any given application that uses your lib.

Please bear in mind, that the examples given are for test-purposes only. For anything live-ish, I would recommend that you use distutil. Examples of use are given here.

Steen
+2  A: 

We put non .py files in /opt/foo/foo-1.2/...

Except, of course, for static media that is served by Apache, that goes to /var/www/html/foo/foo-1.1/media/...

Except, of course, for customer-specific configuration files. They go to /var/opt/customer/foo/...

Those follow the Linux standards as I understand them.

We try to stay away from /usr/lib/ and /lib kinds of locations because those feel like they're part of the distribution. We lean toward /opt and /var because they're clearly separated from the linux distro directories.

S.Lott