mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
Fix problem reported by Donn Cave: if VPATH is an absolute path, it
would always be a hit. Prevent this by only using VPATH if we know we are in the build directory.
This commit is contained in:
parent
4a807f5939
commit
573a24a4f7
1 changed files with 25 additions and 18 deletions
|
@ -209,25 +209,30 @@ search_for_prefix(argv0_path, home)
|
||||||
int i, n;
|
int i, n;
|
||||||
char *vpath;
|
char *vpath;
|
||||||
|
|
||||||
/* Check VPATH to see if argv0_path is in the build directory.
|
/* Check to see if argv[0] is in the build directory */
|
||||||
* Complication: the VPATH passed in is relative to the
|
|
||||||
* Modules build directory and points to the Modules source
|
|
||||||
* directory; we need it relative to the build tree and
|
|
||||||
* pointing to the source tree. Solution: chop off a leading
|
|
||||||
* ".." (but only if it's there -- it could be an absolute
|
|
||||||
* path) and chop off the final component (assuming it's
|
|
||||||
* "Modules").
|
|
||||||
*/
|
|
||||||
vpath = VPATH;
|
|
||||||
if (vpath[0] == '.' && vpath[1] == '.' && vpath[2] == '/')
|
|
||||||
vpath += 3;
|
|
||||||
strcpy(prefix, argv0_path);
|
strcpy(prefix, argv0_path);
|
||||||
join(prefix, vpath);
|
join(prefix, "Modules/Setup");
|
||||||
reduce(prefix);
|
if (exists(prefix)) {
|
||||||
join(prefix, "Lib");
|
/* Check VPATH to see if argv0_path is in the build directory.
|
||||||
join(prefix, LANDMARK);
|
* Complication: the VPATH passed in is relative to the
|
||||||
if (exists(prefix))
|
* Modules build directory and points to the Modules source
|
||||||
return -1;
|
* directory; we need it relative to the build tree and
|
||||||
|
* pointing to the source tree. Solution: chop off a leading
|
||||||
|
* ".." (but only if it's there -- it could be an absolute
|
||||||
|
* path) and chop off the final component (assuming it's
|
||||||
|
* "Modules").
|
||||||
|
*/
|
||||||
|
vpath = VPATH;
|
||||||
|
if (vpath[0] == '.' && vpath[1] == '.' && vpath[2] == '/')
|
||||||
|
vpath += 3;
|
||||||
|
strcpy(prefix, argv0_path);
|
||||||
|
join(prefix, vpath);
|
||||||
|
reduce(prefix);
|
||||||
|
join(prefix, "Lib");
|
||||||
|
join(prefix, LANDMARK);
|
||||||
|
if (exists(prefix))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (home) {
|
if (home) {
|
||||||
/* Check $PYTHONHOME */
|
/* Check $PYTHONHOME */
|
||||||
|
@ -474,6 +479,8 @@ calculate_path()
|
||||||
strcpy(buf, rtpypath);
|
strcpy(buf, rtpypath);
|
||||||
strcat(buf, delimiter);
|
strcat(buf, delimiter);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
buf[0] = '\0';
|
||||||
|
|
||||||
/* Next goes merge of compile-time $PYTHONPATH with
|
/* Next goes merge of compile-time $PYTHONPATH with
|
||||||
* dynamically located prefix.
|
* dynamically located prefix.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue