[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ideal directory structure?

On 30/01/10 09:04, Ben Finney wrote:
As for getting access to ‘foolib’ for import: you need to make sure it's
on the import path somehow.

* For a library of general use, install it to the Python site packages.
   You can then write your application as just one of an arbitrary number
   of applications using that library from the Python public site

       import foolib.wibble
       import foolib.warble
Using distutils, I know how to install the packages into the appropriate directory, so there is no issue with import *installed* packages/modules. What I am talking about is the upstream tarball that, when extracted into a directory, can run without being installed using distutils. For example, I have a foo-1.2.3.tar.gz (created using "setup.py sdist") that I extract to get (taking Guy's suggestion about the package names)


Now in foo-1.2.3/bin/foo how do I import foolib.wibble so that an installed foo (i.e. /usr/bin/foo after a "setup.py install") can import from the installed module/package (somewhere inside /usr/lib/) while a foo extracted from a source tarball (foo-1.2.3/bin/foo) can import a module/package from the extracted package (foo-1.2.3/foolib/wibble.py).

Forgive me if I haven't understood what you said or if my initial question itself was unclear, I'm (clearly) not very experienced.

Also, say I take Guy's suggestion, then what is the advantage of keep my executable in a bin/ directory when there is no conflict of file and directory names?

Thank you,


Reply to: