[Patches] getpath patch (repost)

M.-A. Lemburg mal@lemburg.com
Tue, 23 May 2000 11:37:02 +0200


This is a multi-part message in MIME format.
--------------E9B45DEB669408F0C7917EA3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The getpath patch hasn't been added to CVS and I haven't
heard any comments about the patch itself yet, which is why
I'm reposting it.

The patch makes Python on Unix put more trust into PYTHONHOME
than it did before. It also changes the landmark used by Python
to find the standard lib from string.py to os.py.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/
--------------E9B45DEB669408F0C7917EA3
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Return-Path: <patches-admin@python.org>
Received: from dinsdale.python.org (dinsdale.cnri.reston.va.us [132.151.1.21])
	by phys2.www.pin-net.de (8.9.3/8.9.3) with ESMTP id MAA21512
	for <mal@lemburg.com>; Sat, 13 May 2000 12:18:32 +0200
Received: from dinsdale.python.org (localhost [127.0.0.1])
	by dinsdale.python.org (Postfix) with ESMTP
	id 0566E1CDA6; Sat, 13 May 2000 06:18:28 -0400 (EDT)
Delivered-To: patches@python.org
Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82])
	by dinsdale.python.org (Postfix) with ESMTP id AF9451CDA1
	for <patches@python.org>; Sat, 13 May 2000 06:18:27 -0400 (EDT)
Received: from fmrl01.sul.t-online.de 
	by mailout05.sul.t-online.com with smtp 
	id 12qZ05-0004LM-00; Sat, 13 May 2000 12:18:25 +0200
Received: from lemburg.com (340012077301-0001@[62.158.238.216]) by fmrl01.sul.t-online.de
	with esmtp id 12qZ03-1gd6m0C; Sat, 13 May 2000 12:18:23 +0200
Message-ID: <391D2BC6.95E4FD3E@lemburg.com>
Date: Sat, 13 May 2000 12:17:42 +0200
From: "M.-A. Lemburg" <mal@lemburg.com>
Organization: eGenix.com Software GmbH -- http://www.egenix.com/
X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.10 i586)
X-Accept-Language: en
MIME-Version: 1.0
To: "Python Patches @ Python.org" <patches@python.org>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Sender: 340012077301-0001@t-dialin.net
Subject: [Patches] getpath patch
Sender: patches-admin@python.org
Errors-To: patches-admin@python.org
X-BeenThere: patches@python.org
X-Mailman-Version: 2.0beta3
Precedence: bulk
List-Id: Mailing list for submission of patches to Python <patches.python.org>
X-Mozilla-Status2: 00000000

Patch Set Contents:
-------------------

Modules/getpath.c:

Landmark changed to os.py.

Setting PYTHONHOME now unconditionally sets sys.prefix
(and sys.exec_prefix). No further checks are done whether the
standard lib can be found in that location or not. This is in
sync with the PC subdir getpath implementations.

PC/getpathp.c:

Landmark changed to os.py.

PC/os2vacpp/getpathp.c:

Landmark changed to os.py.

--

Note: Python will dump core if it cannot find the exceptions module. Perhaps we should add a builtin _exceptions module
(basically a frozen exceptions.py) which is then used as
fallback solution ?!

_____________________________________________________________________
License Transfer:

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under copyright,
patent or other rights or interests ("claims").  To the extent that I
have any such claims, I hereby grant to CNRI a nonexclusive,
irrevocable, royalty-free, worldwide license to reproduce, distribute,
perform and/or display publicly, prepare derivative versions, and
otherwise use this contribution as part of the Python software and its
related documentation, or any derivative versions thereof, at no cost
to CNRI or its licensed users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether or
not to incorporate this contribution in the Python software and its
related documentation.  I further grant CNRI permission to use my name
and other identifying information provided to CNRI by me for use in
connection with the Python software and its related documentation.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/


_______________________________________________
Patches mailing list
Patches@python.org
http://www.python.org/mailman/listinfo/patches

--------------E9B45DEB669408F0C7917EA3
Content-Type: text/plain; charset=us-ascii;
 name="getpath.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="getpath.patch"

diff -u -rbP -x *.o -x *.pyc -x Makefile -x *~ -x *.so -x add2lib -x pgen -x buildno -x config.* -x libpython* -x python -x Setup -x Setup.local -x Setup.thread -x hassignal -x Makefile.pre -x configure -x *.bak -x *.s -x DEADJOE -x *.rej -x *.orig -x Demo -x CVS -x Doc -x *.orig -x .#* -x distutils -x PCbuild -x *.py -x ACKS -x *.txt -x README CVS-Python/Modules/getpath.c Python+Unicode/Modules/getpath.c
--- CVS-Python/Modules/getpath.c	Mon May  8 15:13:50 2000
+++ Python+Unicode/Modules/getpath.c	Sat May 13 11:20:32 2000
@@ -87,7 +87,7 @@
  * Modules/Setup.  If the landmark is found, we're done.
  *
  * For the remaining steps, the prefix landmark will always be
- * lib/python$VERSION/string.py and the exec_prefix will always be
+ * lib/python$VERSION/os.py and the exec_prefix will always be
  * lib/python$VERSION/lib-dynload, where $VERSION is Python's version
  * number as supplied by the Makefile.  Note that this means that no more
  * build directory checking is performed; if the first step did not find
@@ -150,7 +150,7 @@
 #endif
 
 #ifndef LANDMARK
-#define LANDMARK "string.py"
+#define LANDMARK "os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];
@@ -265,6 +265,18 @@
 	int n;
 	char *vpath;
 
+	/* If PYTHONHOME is set, we believe it unconditionally */
+	if (home) {
+		char *delim;
+		strcpy(prefix, home);
+		delim = strchr(prefix, DELIM);
+		if (delim)
+			*delim = '\0';
+		joinpath(prefix, lib_python);
+		joinpath(prefix, LANDMARK);
+		return 1;
+	}
+
 	/* Check to see if argv[0] is in the build directory */
 	strcpy(prefix, argv0_path);
 	joinpath(prefix, "Modules/Setup");
@@ -290,19 +302,6 @@
 			return -1;
 	}
 
-	if (home) {
-		/* Check $PYTHONHOME */
-		char *delim;
-		strcpy(prefix, home);
-		delim = strchr(prefix, DELIM);
-		if (delim)
-			*delim = '\0';
-		joinpath(prefix, lib_python);
-		joinpath(prefix, LANDMARK);
-		if (ismodule(prefix))
-			return 1;
-	}
-
 	/* Search from argv0_path, until root is found */
 	strcpy(prefix, argv0_path);
 	do {
@@ -334,16 +333,8 @@
 {
 	int n;
 
-	/* Check to see if argv[0] is in the build directory */
-	strcpy(exec_prefix, argv0_path);
-	joinpath(exec_prefix, "Modules/Setup");
-	if (isfile(exec_prefix)) {
-		reduce(exec_prefix);
-		return -1;
-	}
-
+	/* If PYTHONHOME is set, we believe it unconditionally */
 	if (home) {
-		/* Check $PYTHONHOME */
 		char *delim;
 		delim = strchr(home, DELIM);
 		if (delim)
@@ -352,8 +343,15 @@
 			strcpy(exec_prefix, home);
 		joinpath(exec_prefix, lib_python);
 		joinpath(exec_prefix, "lib-dynload");
-		if (isdir(exec_prefix))
 			return 1;
+	}
+
+	/* Check to see if argv[0] is in the build directory */
+	strcpy(exec_prefix, argv0_path);
+	joinpath(exec_prefix, "Modules/Setup");
+	if (isfile(exec_prefix)) {
+		reduce(exec_prefix);
+		return -1;
 	}
 
 	/* Search from argv0_path, until root is found */
diff -u -rbP -x *.o -x *.pyc -x Makefile -x *~ -x *.so -x add2lib -x pgen -x buildno -x config.* -x libpython* -x python -x Setup -x Setup.local -x Setup.thread -x hassignal -x Makefile.pre -x configure -x *.bak -x *.s -x DEADJOE -x *.rej -x *.orig -x Demo -x CVS -x Doc -x *.orig -x .#* -x distutils -x PCbuild -x *.py -x ACKS -x *.txt -x README CVS-Python/PC/getpathp.c Python+Unicode/PC/getpathp.c
--- CVS-Python/PC/getpathp.c	Thu Mar 30 21:45:39 2000
+++ Python+Unicode/PC/getpathp.c	Sat May 13 11:07:50 2000
@@ -53,7 +53,7 @@
 
    * We attempt to locate the "Python Home" - if the PYTHONHOME env var
      is set, we believe it.  Otherwise, we use the path of our host .EXE's
-     to try and locate our "landmark" (lib\\string.py) and deduce our home.
+     to try and locate our "landmark" (lib\\os.py) and deduce our home.
      - If we DO have a Python Home: The relevant sub-directories (Lib, 
        plat-win, lib-tk, etc) are based on the Python Home
      - If we DO NOT have a Python Home, the core Python Path is
@@ -110,7 +110,7 @@
  */
 
 #ifndef LANDMARK
-#define LANDMARK "lib\\string.py"
+#define LANDMARK "lib\\os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];
diff -u -rbP -x *.o -x *.pyc -x Makefile -x *~ -x *.so -x add2lib -x pgen -x buildno -x config.* -x libpython* -x python -x Setup -x Setup.local -x Setup.thread -x hassignal -x Makefile.pre -x configure -x *.bak -x *.s -x DEADJOE -x *.rej -x *.orig -x Demo -x CVS -x Doc -x *.orig -x .#* -x distutils -x PCbuild -x *.py -x ACKS -x *.txt -x README CVS-Python/PC/os2vacpp/getpathp.c Python+Unicode/PC/os2vacpp/getpathp.c
--- CVS-Python/PC/os2vacpp/getpathp.c	Mon Jul 27 15:49:04 1998
+++ Python+Unicode/PC/os2vacpp/getpathp.c	Sat May 13 11:08:02 2000
@@ -68,14 +68,14 @@
  *
  * Otherwise, if there is a PYTHONPATH environment variable, we return that.
  *
- * Otherwise we try to find $progpath/lib/string.py, and if found, then
+ * Otherwise we try to find $progpath/lib/os.py, and if found, then
  * root is $progpath/lib, and we return Python path as compiled PYTHONPATH
  * with all "./lib" replaced by $root (as above).
  *
  */
 
 #ifndef LANDMARK
-#define LANDMARK "lib\\string.py"
+#define LANDMARK "lib\\os.py"
 #endif
 
 static char prefix[MAXPATHLEN+1];
Binary files CVS-Python/core and Python+Unicode/core differ
Binary files CVS-Python/core and Python+Unicode/core differ

--------------E9B45DEB669408F0C7917EA3--