<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi Steve,<br><br></div>I have looked into this PEP to see what we need to do on Enthought side of things. I have a few questions:<br><br></div>1. Is it recommended to follow this for any python version we may provide, or just new versions (3.6 and above). Most of our customers still heavily use 2.7, and I wonder whether it would cause more trouble than it is worth backporting this to 2.7.<br></div>2. The main issue for us in practice has been `PythonPath` entry as used to build `sys.path`. I understand this is not the point of the PEP, but would it make sense to give more precise recommendations for 3rd party providers there ?<br><br></div>IIUC, the PEP 514 would recommend for us to do the following:<br><br></div>1. Use HKLM for "system install" or HKCU for "user install" as the root key<br></div>2. Register under "<root>\Software\Python\Enthought"<br></div>3. We should patch our pythons to look in 2. and not in "<root>\Software\Python\PythonCore", especially for `sys.path` constructions.<br></div><div>4. When a python from enthought is installed, it should never register anything in the key defined in 2.<br><br></div><div>Is this correct ?<br></div><div><br></div>I am not clear about 3., especially on what should be changed. I know that for 2.7, we need to change PC\getpathp.c for sys.path, but are there any other places where the registry is used by python itself ?<br><br></div>Thanks for working on this,<br><br></div>David<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 6, 2016 at 9:01 PM, Steve Dower <span dir="ltr"><<a href="mailto:python@stevedower.id.au" target="_blank">python@stevedower.id.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've posted an updated version of this PEP that should soon be visible at <a href="https://www.python.org/dev/peps/pep-0514" rel="noreferrer" target="_blank">https://www.python.org/dev/peps/pep-0514</a>.<br>
<br>
Leaving aside the fact that the current implementation of Python relies on *other* information in the registry (that is not specified in this PEP), I'm still looking for feedback or concerns from developers who are likely to create or use the keys that are described here.<br>
<br>
----------------<br>
<br>
PEP: 514<br>
Title: Python registration in the Windows registry<br>
Version: $Revision$<br>
Last-Modified: $Date$<br>
Author: Steve Dower <<a href="mailto:steve.dower@python.org">steve.dower@python.org</a>><br>
Status: Draft<br>
Type: Informational<br>
Content-Type: text/x-rst<br>
Created: 02-Feb-2016<br>
Post-History: 02-Feb-2016<br>
<br>
Abstract<br>
========<br>
<br>
This PEP defines a schema for the Python registry key to allow third-party<br>
installers to register their installation, and to allow applications to detect<br>
and correctly display all Python environments on a user's machine. No<br>
implementation changes to Python are proposed with this PEP.<br>
<br>
Python environments are not required to be registered unless they want to be<br>
automatically discoverable by external tools.<br>
<br>
The schema matches the registry values that have been used by the official<br>
installer since at least Python 2.5, and the resolution behaviour matches the<br>
behaviour of the official Python releases.<br>
<br>
Motivation<br>
==========<br>
<br>
When installed on Windows, the official Python installer creates a registry key<br>
for discovery and detection by other applications. This allows tools such as<br>
installers or IDEs to automatically detect and display a user's Python<br>
installations.<br>
<br>
Third-party installers, such as those used by distributions, typically create<br>
identical keys for the same purpose. Most tools that use the registry to detect<br>
Python installations only inspect the keys used by the official installer. As a<br>
result, third-party installations that wish to be discoverable will overwrite<br>
these values, resulting in users "losing" their Python installation.<br>
<br>
By describing a layout for registry keys that allows third-party installations<br>
to register themselves uniquely, as well as providing tool developers guidance<br>
for discovering all available Python installations, these collisions should be<br>
prevented.<br>
<br>
Definitions<br>
===========<br>
<br>
A "registry key" is the equivalent of a file-system path into the registry. Each<br>
key may contain "subkeys" (keys nested within keys) and "values" (named and<br>
typed attributes attached to a key).<br>
<br>
``HKEY_CURRENT_USER`` is the root of settings for the currently logged-in user,<br>
and this user can generally read and write all settings under this root.<br>
<br>
``HKEY_LOCAL_MACHINE`` is the root of settings for all users. Generally, any<br>
user can read these settings but only administrators can modify them. It is<br>
typical for values under ``HKEY_CURRENT_USER`` to take precedence over those in<br>
``HKEY_LOCAL_MACHINE``.<br>
<br>
On 64-bit Windows, ``HKEY_LOCAL_MACHINE\Software\Wow6432Node`` is a special key<br>
that 32-bit processes transparently read and write to rather than accessing the<br>
``Software`` key directly.<br>
<br>
Structure<br>
=========<br>
<br>
We consider there to be a single collection of Python environments on a machine,<br>
where the collection may be different for each user of the machine. There are<br>
three potential registry locations where the collection may be stored based on<br>
the installation options of each environment::<br>
<br>
HKEY_CURRENT_USER\Software\Python\<Company>\<Tag><br>
HKEY_LOCAL_MACHINE\Software\Python\<Company>\<Tag><br>
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\<Company>\<Tag><br>
<br>
Environments are uniquely identified by their Company-Tag pair, with two options<br>
for conflict resolution: include everything, or give priority to user<br>
preferences.<br>
<br>
Tools that include every installed environment, even where the Company-Tag pairs<br>
match, should ensure users can easily identify whether the registration was<br>
per-user or per-machine.<br>
<br>
Tools that give priority to user preferences must ignore values from<br>
``HKEY_LOCAL_MACHINE`` when a matching Company-Tag pair exists is in<br>
``HKEY_CURRENT_USER``.<br>
<br>
Official Python releases use ``PythonCore`` for Company, and the value of<br>
``sys.winver`` for Tag. Other registered environments may use any values for<br>
Company and Tag. Recommendations are made in the following sections.<br>
<br>
Python environments are not required to register themselves unless they want to<br>
be automatically discoverable by external tools.<br>
<br>
Backwards Compatibility<br>
-----------------------<br>
<br>
Python 3.4 and earlier did not distinguish between 32-bit and 64-bit builds in<br>
``sys.winver``. As a result, it is possible to have valid side-by-side<br>
installations of both 32-bit and 64-bit interpreters.<br>
<br>
To ensure backwards compatibility, applications should treat environments listed<br>
under the following two registry keys as distinct, even when the Tag matches::<br>
<br>
HKEY_LOCAL_MACHINE\Software\Python\PythonCore\<Tag><br>
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\PythonCore\<Tag><br>
<br>
Environments listed under ``HKEY_CURRENT_USER`` may be treated as distinct from<br>
both of the above keys, potentially resulting in three environments discovered<br>
using the same Tag. Alternatively, a tool may determine whether the per-user<br>
environment is 64-bit or 32-bit and give it priority over the per-machine<br>
environment, resulting in a maximum of two discovered environments.<br>
<br>
It is not possible to detect side-by-side installations of both 64-bit and<br>
32-bit versions of Python prior to 3.5 when they have been installed for the<br>
current user. Python 3.5 and later always uses different Tags for 64-bit and<br>
32-bit versions.<br>
<br>
Environments registered under other Company names must use distinct Tags to<br>
support side-by-side installations. There is no backwards compatibility<br>
allowance.<br>
<br>
Company<br>
-------<br>
<br>
The Company part of the key is intended to group related environments and to<br>
ensure that Tags are namespaced appropriately. The key name should be<br>
alphanumeric without spaces and likely to be unique. For example, a trademarked<br>
name, a UUID, or a hostname would be appropriate::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp<br>
HKEY_CURRENT_USER\Software\Python\6C465E66-5A8C-4942-9E6A-D29159480C60<br>
HKEY_CURRENT_USER\Software\Python\<a href="http://www.example.com" rel="noreferrer" target="_blank">www.example.com</a><br>
<br>
The company name ``PyLauncher`` is reserved for the PEP 397 launcher<br>
(``py.exe``). It does not follow this convention and should be ignored by tools.<br>
<br>
If a string value named ``DisplayName`` exists, it should be used to identify<br>
the environment category to users. Otherwise, the name of the key should be<br>
used.<br>
<br>
If a string value named ``SupportUrl`` exists, it may be displayed or otherwise<br>
used to direct users to a web site related to the environment.<br>
<br>
A complete example may look like::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp<br>
(Default) = (value not set)<br>
DisplayName = "Example Corp"<br>
SupportUrl = "<a href="http://www.example.com" rel="noreferrer" target="_blank">http://www.example.com</a>"<br>
<br>
Tag<br>
---<br>
<br>
The Tag part of the key is intended to uniquely identify an environment within<br>
those provided by a single company. The key name should be alphanumeric without<br>
spaces and stable across installations. For example, the Python language<br>
version, a UUID or a partial/complete hash would be appropriate; an integer<br>
counter that increases for each new environment may not::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\3.6<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66<br>
<br>
If a string value named ``DisplayName`` exists, it should be used to identify<br>
the environment to users. Otherwise, the name of the key should be used.<br>
<br>
If a string value named ``SupportUrl`` exists, it may be displayed or otherwise<br>
used to direct users to a web site related to the environment.<br>
<br>
If a string value named ``Version`` exists, it should be used to identify the<br>
version of the environment. This is independent from the version of Python<br>
implemented by the environment.<br>
<br>
If a string value named ``SysVersion`` exists, it must be in ``x.y`` or<br>
``x.y.z`` format matching the version returned by ``sys.version_info`` in the<br>
interpreter. Otherwise, if the Tag matches this format it is used. If not, the<br>
Python version is unknown.<br>
<br>
Note that each of these values is recommended, but optional. A complete example<br>
may look like this::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66<br>
(Default) = (value not set)<br>
DisplayName = "Distro 3"<br>
SupportUrl = "<a href="http://www.example.com/distro-3" rel="noreferrer" target="_blank">http://www.example.com/distro-3</a>"<br>
Version = "3.0.12345.0"<br>
SysVersion = "3.6.0"<br>
<br>
InstallPath<br>
-----------<br>
<br>
Beneath the environment key, an ``InstallPath`` key must be created. This key is<br>
always named ``InstallPath``, and the default value must match ``sys.prefix``::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\3.6\InstallPath<br>
(Default) = "C:\ExampleCorpPy36"<br>
<br>
If a string value named ``ExecutablePath`` exists, it must be a path to the<br>
``python.exe`` (or equivalent) executable. Otherwise, the interpreter executable<br>
is assumed to be called ``python.exe`` and exist in the directory referenced by<br>
the default value.<br>
<br>
If a string value named ``WindowedExecutablePath`` exists, it must be a path to<br>
the ``pythonw.exe`` (or equivalent) executable. Otherwise, the windowed<br>
interpreter executable is assumed to be called ``pythonw.exe`` and exist in the<br>
directory referenced by the default value.<br>
<br>
A complete example may look like::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66\InstallPath<br>
(Default) = "C:\ExampleDistro30"<br>
ExecutablePath = "C:\ExampleDistro30\ex_python.exe"<br>
WindowedExecutablePath = "C:\ExampleDistro30\ex_pythonw.exe"<br>
<br>
Help<br>
----<br>
<br>
Beneath the environment key, a ``Help`` key may be created. This key is always<br>
named ``Help`` if present and has no default value.<br>
<br>
Each subkey of ``Help`` specifies a documentation file, tool, or URL associated<br>
with the environment. The subkey may have any name, and the default value is a<br>
string appropriate for passing to ``os.startfile`` or equivalent.<br>
<br>
If a string value named ``DisplayName`` exists, it should be used to identify<br>
the help file to users. Otherwise, the key name should be used.<br>
<br>
A complete example may look like::<br>
<br>
HKEY_CURRENT_USER\Software\Python\ExampleCorp\6C465E66\Help<br>
Python\<br>
(Default) = "C:\ExampleDistro30\python36.chm"<br>
DisplayName = "Python Documentation"<br>
Extras\<br>
(Default) = "<a href="http://www.example.com/tutorial" rel="noreferrer" target="_blank">http://www.example.com/tutorial</a>"<br>
DisplayName = "Example Distro Online Tutorial"<br>
<br>
Other Keys<br>
----------<br>
<br>
Some other registry keys are used for defining or inferring search paths under<br>
certain conditions. A third-party installation is permitted to define these keys<br>
under their Company-Tag key, however, the interpreter must be modified and<br>
rebuilt in order to read these values.<br>
<br>
Copyright<br>
=========<br>
<br>
This document has been placed in the public domain.<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/cournape%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/cournape%40gmail.com</a><br>
</blockquote></div><br></div>