[PATCH STABLE] setup/hg: handle hg being a symlink when appending relative libdir to sys.path

Dan Villiom Podlaski Christiansen danchr at gmail.com
Thu Oct 21 17:22:00 CDT 2010


On 22 Oct 2010, at 00:03, Matt Mackall wrote:

> On Thu, 2010-10-21 at 22:52 +0200, Thomas Arendsen Hein wrote:
>> * L. David Baron <dbaron at dbaron.org> [20101021 22:45]:
>>> On Thursday 2010-10-21 21:12 +0200, Thomas Arendsen Hein wrote:
>>>> * L. David Baron <dbaron at dbaron.org> [20101021 19:23]:
>>>>> # HG changeset patch
>>>>> # User L. David Baron <dbaron at dbaron.org>
>>>>> # Date 1287680302 25200
>>>>> # Node ID 172c5e2d8baff6b65d09c779d64ae199b23eb886
>>>>> # Parent  6bf8d48bec8e1ab2e0462ce14a914d06e64f7117
>>>>> setup/hg: handle hg being a symlink when appending relative  
>>>>> libdir to sys.path
>>>>>
>>>>> Resolve symbolic links in the path to hg so that an hg that  
>>>>> works when
>>>>> invoked directly will also work when invoked via a symlink to it.
>>>>
>>>> I can't reproduce the problem, I often install hg in this way and
>>>> don't have problems with it:
>>>> /usr/local/bin/hg is a symlink to ../mercurial-tah/hg
>>>> and it just works, tested with version 1.6.4+185-c82cd7b08158 (and
>>>> many versions before that)
>>>
>>> Do you also set PYTHONPATH or something similar to add
>>> /usr/local/mercurial-tah/lib/python2.6/site-packages to the path?
>>> (Or did you actually mean ../mercurial-tah/hg rather than
>>> ../mercurial-tah/bin/hg ?)
>>
>> I don't have PYTHONPATH modified, but yes, I really meant hg instead
>> of bin/hg (just a checkout of the repository followed by 'make
>> local', not something created by 'make install' with some PREFIX).
>>
>> While this generally sounds like a good idea, I'm reluctant to push
>> it to stable, because it does not fix a bug, but introduces a new
>> feature, especially right now during the freeze.
>>
>> Maybe mpm or someone else from crew can decide this?
>
> I haven't seen a clear explanation of what the issue is supposed to  
> be.

At the sprint, we discussed a patch of mine that made Mercurial force  
loading of the packages it was installed with. However, I overlooked  
the point that the invoked ‘hg’ script might be a symlink. If it is,  
the path-setting logic doesn't work.

To reproduce do:

>   $ ln -s ~/kaflaflibob/bin/hg ~/kaflaflibob-hg
>   $ python setup.py install --prefix=~/kaflaflibob 2>&1 > /dev/null

Without the patch:

>   $ PYTHONPATH='' ~/kaflaflibob-hg
>   Traceback (most recent call last):
[snip]
>     File "/Users/danchr/src/opensrc/vcs/mercurial/mercurial/ 
> demandimport.py", line 52, in _load
>       mod = _origimport(head, globals, locals)
>   ImportError: No module named osutil

With the patch it succeeds.

--

Dan Villiom Podlaski Christiansen
danchr at gmail.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1943 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20101022/23c36985/attachment.bin>


More information about the Mercurial-devel mailing list