[Python-Dev] Re: Possible solution for PEP250 and bdist_wininst
M.-A. Lemburg
mal@lemburg.com
Fri, 13 Jul 2001 19:20:54 +0200
Thomas Heller wrote:
>
> I have a possible solution for this problem.
>
> (I'll use the name INSTALLPATH for installation directory stored
> in the registry under the key
> HKEY_LOCAL_MACHINE\Software\Python\PythonCore\<version>\InstallPath).
>
> The bdist_wininst installer at _install_ time sets the PYTHONHOME
> environment variable to INSTALLPATH, then loads the python dll
> and retrieves the 'extinstallpath' attribute from the sys module:
>
> wwsprintf(buffer, "PYTHONHOME=%s", INSTALLPATH);
> _putenv(buffer);
> Py_SetProgramName(modulename);
> Py_Initialize();
> pextinstallpath = PySys_GetObject("extinstallpath");
> Py_Finalize();
>
> If this is successful, the (string contents of) pextinstallpath
> is appended to INSTALLPATH, and that will be the directory where
> the package will be installed. If unsuccessful, INSTALLPATH will
> be used as before.
Sounds OK.
> I'm unsure about the change to site.py, but this should work:
>
> diff -c -r1.26 site.py
> *** site.py 2001/03/23 17:53:49 1.26
> --- site.py 2001/07/13 15:32:27
> ***************
> *** 140,153 ****
> "python" + sys.version[:3],
> "site-packages"),
> makepath(prefix, "lib", "site-python")]
> - elif os.sep == ':':
> - sitedirs = [makepath(prefix, "lib", "site-packages")]
> else:
> ! sitedirs = [prefix]
> for sitedir in sitedirs:
> if os.path.isdir(sitedir):
> addsitedir(sitedir)
>
> # Define new built-ins 'quit' and 'exit'.
> # These are simply strings that display a hint on how to exit.
> if os.sep == ':':
> --- 140,154 ----
> "python" + sys.version[:3],
> "site-packages"),
> makepath(prefix, "lib", "site-python")]
> else:
> ! sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")]
> for sitedir in sitedirs:
> if os.path.isdir(sitedir):
> addsitedir(sitedir)
>
> + if os.sep == '\\':
> + sys.extinstallpath = os.path.join(sys.prefix, "lib", "site-packages")
> +
Why not do this for all platforms (which support site-packages) ?
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company: http://www.egenix.com/
Python Software: http://www.lemburg.com/python/