Windows registry path not ignored with Py_IgnoreEnvironmentFlag set

Hello, I noticed that if Py_IgnoreEnvironmentFlag is enabled, the Windows registry is still used to initialize sys.path during startup. Is this an oversight or intentional? I assumed one of the intentions of this flag is to prevent embedded Python interpreters from being affected by other Python installations. Ignoring the Window registry as well as environment variables seems to make sense in this situation. If this is an oversight, would it be too late to have this fixed in Python 2.7? Cheers, Farshid

On 2/06/2010 11:32 AM, Farshid Lashkari wrote:
Hello,
I noticed that if Py_IgnoreEnvironmentFlag is enabled, the Windows registry is still used to initialize sys.path during startup. Is this an oversight or intentional?
I guess it falls somewhere in the middle - the flag refers to the 'environment' so I believe it hasn't really been considered as applying to the registry - IOW, the reference to 'environment' probably refers to the specific 'environment variables' rather than the more general 'execution environment'.
I assumed one of the intentions of this flag is to prevent embedded Python interpreters from being affected by other Python installations. Ignoring the Window registry as well as environment variables seems to make sense in this situation.
I agree.
If this is an oversight, would it be too late to have this fixed in Python 2.7?
Others will have opinions which carry more weight than mine, but I see no reason it should not be fixed for *some* Python version. Assuming no objections from anyone else, I suggest the best way to get this to happen in the short to medium term would be to open a bug with a patch. A bug without a patch would also be worthwhile but would almost certainly cause it to be pushed back to a future 3.x version... Cheers, Mark

On Fri, Jun 4, 2010 at 4:47 PM, Mark Hammond <skippy.hammond@gmail.com> wrote:
On 2/06/2010 11:32 AM, Farshid Lashkari wrote:
Hello,
I noticed that if Py_IgnoreEnvironmentFlag is enabled, the Windows registry is still used to initialize sys.path during startup. Is this an oversight or intentional?
I guess it falls somewhere in the middle - the flag refers to the 'environment' so I believe it hasn't really been considered as applying to the registry - IOW, the reference to 'environment' probably refers to the specific 'environment variables' rather than the more general 'execution environment'.
I assumed one of the intentions of this flag is to prevent embedded Python interpreters from being affected by other Python installations. Ignoring the Window registry as well as environment variables seems to make sense in this situation.
I agree.
If this is an oversight, would it be too late to have this fixed in Python 2.7?
Others will have opinions which carry more weight than mine, but I see no reason it should not be fixed for *some* Python version. Assuming no objections from anyone else, I suggest the best way to get this to happen in the short to medium term would be to open a bug with a patch. A bug without a patch would also be worthwhile but would almost certainly cause it to be pushed back to a future 3.x version...
I don't object (this had never occurred to me), but is Python on Windows fully functioning when the registry is entirely ignored? -- --Guido van Rossum (python.org/~guido)

On Sat, Jun 5, 2010 at 7:55 AM, Guido van Rossum <guido@python.org> wrote:
I don't object (this had never occurred to me), but is Python on Windows fully functioning when the registry is entirely ignored?
I believe so. The path of executable and Python DLL are used to initialize sys.path, which should be enough to find the necessary files.

On 05/06/2010 19:03, Farshid Lashkari wrote:
On Sat, Jun 5, 2010 at 7:55 AM, Guido van Rossum <guido@python.org <mailto:guido@python.org>> wrote:
I don't object (this had never occurred to me), but is Python on Windows fully functioning when the registry is entirely ignored?
Yes, it works fine. This is one of the things py2exe does to create 'standalone' Python programs for Windows. Michael
I believe so. The path of executable and Python DLL are used to initialize sys.path, which should be enough to find the necessary files.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.u...
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies ("BOGUS AGREEMENTS") that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

Tangengially relevant is the following: When embedding python, it is currently impossible (well, in 2.x anyway) to completely override pythons magic path-guessing algorithm. This is annoying. Last pycon, the talk on embedding python, showed how applications that do that often get started through bootstrapping batch scripts that set up the environment for python, to guide the path-setting algorithm along. At CCP, we have patched python so that we can specify an initial sys.path, and completely disable the path guessing algorithm. This is necessary because python is _embedded_ and it is the embedding application that knows where it is allowed to look for libraries. This is in addition to telling it to ignore the environment. In fact, it is my opinion that the path init stuff, as well as command line parsing and so on, really belongs in python.exe and not in python25.lib, although one can argue for the convenience of keeping it in the .lib. But IMHO, it should not be part of Py_Initialize. Perhaps I'll submit this particular patch to the tracker one day. K
-----Original Message----- From: python-dev-bounces+kristjan=ccpgames.com@python.org [mailto:python-dev-bounces+kristjan=ccpgames.com@python.org] On Behalf Of Guido van Rossum Sent: 5. júní 2010 14:55 To: Mark Hammond Cc: Python-Dev Subject: Re: [Python-Dev] Windows registry path not ignored with Py_IgnoreEnvironmentFlag set
I don't object (this had never occurred to me), but is Python on Windows fully functioning when the registry is entirely ignored?
-- --Guido van Rossum (python.org/~guido)

On 6/5/2010 10:55 AM, Guido van Rossum wrote:
I don't object (this had never occurred to me), but is Python on Windows fully functioning when the registry is entirely ignored?
There have been a couple of portable CPython-on-a-CD or memory stick that supposedly run on any machine without 'installation' (writing to the registry), so they must run without reading anything Python specific.
participants (6)
-
Farshid Lashkari
-
Guido van Rossum
-
Kristján Valur Jónsson
-
Mark Hammond
-
Michael Foord
-
Terry Reedy