Title: distutils build_ext path comparison only based on strings
Type: behavior Stage: test needed
Components: Distutils Versions: Python 3.4, Python 3.5, Python 2.7
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: dstufft, eric.araujo, jougs, sleipnir, tarek, vstinner
Priority: normal Keywords: patch

Created on 2009-05-26 10:55 by sleipnir, last changed 2019-07-29 11:30 by vstinner.

File name Uploaded Description Edit
python-2.5.2-build_ext-pathcompare.patch sleipnir, 2009-05-26 10:55 Fix path comparison in distutils build_ext
Messages (7)
msg88351 - (view) Author: Sven Rebhan (sleipnir) Date: 2009-05-26 10:55
If python is installed into a symlink'ed directory, the variables
"sys.exec_prefix" and "sys.executable" can contain different paths.
Therefore, the respective test in fails (line 202)
and a wrong library search directory (-L.) is set.

The attached patch fixes this issue, by using os.path.samefile() instead
of the string comparison to see whether two files are identical
irrespective of their paths.
msg115844 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-08 02:49
Thanks for the report and patch.

I just tested that When the executable itself is symlinked (not installed, just linked from an existing installation), sys.exec_prefix and sys.executable are different. This means that a unit test (to prevent regressions) will be easy to write with the helpers in test.test_support (2.7)/ (3.x)/

os.path.samefile is not supported on Windows before 3.2; I guess we’ll have to live with that bug and just document it :(

Do you want to add tests for this? I’ll do it if you don’t.

(Out of curiosity, why are there three signed-off-by lines? Is there a secret community of distutils bug fixers using git?)
msg115845 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-08 02:53
symlinks are not supported at all on Windows before 3.2, so we’re good, except for cygwin.
msg115853 - (view) Author: Sven Rebhan (sleipnir) Date: 2010-09-08 07:36
Of course there is a secret distutils comunity using git! ;-) The three ppl mentioned there found and fixed the problem, that's why.

But back to the issue: Can we use a switch or wrapper function to change the test method for this path dependent on the OS? I'm asking because in windows there might be no symlink either and everything just works(tm).
msg116110 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-11 17:39
> The three ppl mentioned there found and fixed the problem, that's why.
The real question behind the joke was: Are you part of the same community? Where does this fix come from?

> But back to the issue: Can we use a switch or wrapper function to
> change the test method for this path dependent on the OS?
Symlink support detection is not trivial, it depends on platform, version and user rights (the docs say Windows Vista has a notion of “right to create a symlink”). See Lib/test/ for some scary code.  For our bug, I have hope that a simple “hasattr(os.path, 'samefile'” will be enough to decide whether to use this function or string comparison.

Do you want to add tests for this bug?
msg159661 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-04-29 23:48
Two people started working on this during the first Montreal sprint.
msg348614 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-07-29 11:30
This issue is 10 years old has a patch: it's far from being "newcomer friendly", I remove the "Easy" label.
Date User Action Args
2019-07-29 11:30:04vstinnersetkeywords: - easy
nosy: + vstinner
messages: + msg348614

2014-07-06 17:39:43BreamoreBoysetnosy: + dstufft

components: - Distutils2
versions: + Python 3.4, Python 3.5, - 3rd party, Python 3.2, Python 3.3
2012-04-29 23:48:49eric.araujosetmessages: + msg159661
versions: + Python 3.3, - Python 3.1
2010-09-29 23:43:18eric.araujosetversions: + 3rd party
2010-09-11 17:39:39eric.araujosetmessages: + msg116110
2010-09-08 07:36:36sleipnirsetmessages: + msg115853
2010-09-08 02:53:32eric.araujosetmessages: + msg115845
2010-09-08 02:49:23eric.araujosetassignee: tarek -> eric.araujo
components: + Distutils2

keywords: + easy
nosy: + eric.araujo
messages: + msg115844
stage: test needed
2010-07-11 09:33:30BreamoreBoysetversions: - Python 2.6
2009-09-07 08:11:24tareksetpriority: normal
resolution: accepted
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.5
2009-05-26 10:59:37jougssetnosy: + jougs
2009-05-26 10:55:57sleipnircreate