confused with so many python package locations for imports
ben+python at benfinney.id.au
Sat Apr 25 10:31:02 CEST 2009
Krishnakant <hackingkk at gmail.com> writes:
> My Basic question is that, what package directory is Standard as far
> as all gnu/linux distros are concerned?
Python has a habit of generating, and expecting to find,
platform-specific files (‘foo.pyo’ extension modules), compiled bytecode
files (‘foo.pyc’), and module source files (‘foo.py’) necessarily in the
same directory for purpose of locating them at import time.
This goes very contrary to most standards of Unix and GNU filesystem
standards, including the FHS, which prefers to keep firm distinction
between files that are source, platform-independent binary, and
platform-dependent binary, and have them all in separate defined
locations by default.
So, it's not clear at all where Python's all-in-one conglomeration of
different filetypes in a single directory tree should be located on Unix
or GNU. Hence the differences over time and across different
distributions, as GNU distributors try different workarounds for
Python's current foibles in this area.
> In other words I would like to know if there is some package directory
> which is searched by default for installed packages?
Yes, there is. That location is as defined by the Python executable on
> I want my distutils setup.py to setup the package so that an import
> statement can import the package no matter what distro of gnu/linux we
> are running.
You are currently out of luck. The distutils design is currently
undergoing review and design evolution in order to make this easier, and
AFAICT there was a lot of enthusiasm and good work done at this year's
PyCon, but IMHO we're a long way from sorting out the mismatch between
Python and the FHS.
\ “I am amazed, O Wall, that you have not collapsed and fallen, |
`\ since you must bear the tedious stupidities of so many |
_o__) scrawlers.” —anonymous graffiti, Pompeii, 79 CE |
More information about the Python-list