Double symlinking breaks module import
tphhec01 at degas.ceu.hu
Sun Aug 24 11:16:27 CEST 2003
In article <ItW1b.912$Jh2.38 at newsread4.news.pas.earthlink.net>, Andrew Dalke wrote:
> Csaba Henk:
>> if I create another symlink myprog3.py -> myprog2.py, and then I invoke
>> myprog3.py, I get compliances that mymod is not found.
>> Is it a bug or policy?
> Python uses the normal file open functions, which automatically
> follow links. It doesn't build in the link following code itself.
> I suspect your symlink points to the wrong place. Can you
> cat the file?
The symlink can't be wrong because the python program itself (to which the
symlinks refer) starts up; it just doesn't find the module. This question is
related to importing modules, and the list of dirs in which the module
seeked is a Python internal, so it does not depend only on file functions.
How symlinking affect the module search path? As I now, modules seeked in
the current dir and standard places. If I invoke the prog via a symlink, the
current dir is not the same as for the program (where the module resides
also), still the module is found somehow. But not if two symlinks used.
Btw, the program with which I have this program, is sketch. Sketch has
sketch.py and the module Sketch in <prefix>/lib/sketch-0.6.15/. It's usually
invoked via the symlink
<prefix>/bin/sketch -> ../lib/sketch-0.6.15/sketch.py. My problem occured
when I wanted to started sketch via another symlink pointing to
<prefix>/bin/sketch. You can test my report by installing sketch.
sketch.py is the following code:
if sys.version < '1.5.1':
sys.stderr.write("Sorry, Sketch requires at least Python 1.5.1\n")
Sketch.config.sketch_command = sys.argv
Set theory is the LSD of mathematics
More information about the Python-list