This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Windows 'for current user' installation - 32/64-bit registrations overwrite each other
Type: Stage:
Components: Installation, Windows Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Jurko.Gospodnetić, loewis, paul.moore, steve.dower, tim.golden
Priority: normal Keywords: patch

Created on 2014-03-10 15:33 by Jurko.Gospodnetić, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
20883_1.patch steve.dower, 2014-03-11 22:17 review
Messages (11)
msg213045 - (view) Author: Jurko Gospodnetić (Jurko.Gospodnetić) * Date: 2014-03-10 15:33
When running the Python Windows installer 'for all users', the 32-bit installation and the 64-bit installation each gets a separate registration in the Windows registry. E.g. under:

  HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.4

and:

  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.4

However, when running the installer 'for the current user only', the 32-bit and the 64-bit installation both use the same Windows registry key:

  HKEY_CURRENT_USER\Software\Python\PythonCore\3.4

Note that a 64-bit installation does not automatically uninstall a previous 32-bit installation in either case, or vice versa.

As I understand it, whichever installation you use, you should be able to run a specific Python interpreter using the py.exe runner, as in:

  py.exe -3.4
  py.exe -3.4-32

As it stands now - both of those run the same interpreter when they have been installed 'for the current user only', although when running
'py.exe -3.4-32' the runner will make an extra check and reject running the Python executable if the 64-bit version was installed last.

So:
1. If you install the 64-bit version first and then the 32-bit version, both 'py.exe -3.4' & 'py.exe -3.4-32' run the 32-bit executable.
2. If you install the 32-bit version first and then the 64-bit version, 'py.exe -3.4' runs the 64-bit version, and 'py.exe -3.4-32' exits with an error.
msg213046 - (view) Author: Jurko Gospodnetić (Jurko.Gospodnetić) * Date: 2014-03-10 15:46
A possible solution would be to update installers and runners to use HKEY_CURRENT_USER\Software\Wow6432Node registry entries for 32-bit 'for current user only' installations on a 64-bit Windows OS.

To preserve backward compatibility, runners could fall back to reading the 64-bit HKEY_CURRENT_USER\Software registry entries if their 32-bit counterparts can not be found directly.

This way:
  - installations on 32-bit Windows are unaffected
  - new installations work with new runners correctly
  - old installations work with new runners as before
  - old installations work with old runners as before
  - new 64-bit installations work with old runners as before
  - new 32-bit installations do not work with old runners
msg213053 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-03-10 17:51
This is not a bug in Python, but either intentional, or a bug in Windows. Processing of Wow64Node is done by Windows, see 

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384253(v=vs.85).aspx

As you can see, the SOFTWARE key is redirected in HKEY_LOCAL_MACHINE, but shared in HKEY_CURRENT_USER.

If you think that absolutely something must be done, I would suggest to remove the "install for current user" feature altogether - it has too many flaws imposed by Windows.
msg213064 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-03-10 18:39
OK, fair enough (I agree that the Windows behaviour here is the root cause of the problem). However, it *would* have been possible for the registry keys to be HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.4-32 and HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.4-64 (with whatever Wow64 nonsense MS chose to add). If that had been in place, we would not have this bug.

The change is backward incompatible, though (in an annoyingly obscure way as well), and I'm comfortable with a resolution that this is not a sufficiently common scenario to warrant that sort of change.
msg213065 - (view) Author: Jurko Gospodnetić (Jurko.Gospodnetić) * Date: 2014-03-10 18:41
I'm against removing local user installation support because that is the only way Python can be installed without write access to shared system locations like the Windows system folder or the HKEY_LOCAL_MACHINE registry hive.
msg213066 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2014-03-10 18:53
Agreed, that is not necessary. Nor was Martin suggesting it as far as I can tell, he was simply saying that it would be less disruptive in the broader scheme of things than messing with the Python registry scheme to work around the limitation that 32 and 64 bit Pythons can't both be registered as per-user installations.
msg213068 - (view) Author: Jurko Gospodnetić (Jurko.Gospodnetić) * Date: 2014-03-10 18:57
And as for simultaneous 64/32-bit Python installations on a single 64-bit machine - as Paul said, whichever way Microsoft implemented its automatic registry key redirection, it is up to Python to decide how its installer should behave.

So the question is - should it be possible to run 32-bit & 64-bit Python installations on the same machine using the standard py.exe wrapper when those installations are done for the current user only?

I know I found that useful in a scenario (done using installations 'for all users' though) where I had some scripts using 64-bit Python and needed to run several scripts automating a 32-bit Python extension module. I believe the problem was in the pstools module that at the time was not available as a 64-bit build (don't know if that situation has been resolved since).

Personally, I just noticed the undocumented inconsistency and decided to report it. I don't really care all that much about whether it is resolved cleanly, as in my development setup I have other problems preventing me from using the py.exe wrapper all together - I need multiple parallel patch releases in the same system and the best way I found to achieve that is to:
  - do a 'local user installation' - version A,
  - rename the target folder for version A
  - do a 'local user installation' - version B,
  - ...
and have my own version specific startup scripts like py243.cmd, py244.cmd, py276_x86.cmd, py276.cmd, py340.cmd, ...

I really don't like it that different Python X.Y patch releases overwrite each other's installation registrations or uninstall each other automatically. :-( Or that you can not specify more detailed Python interpreter version information like 2.4.3 to the py.exe wrapper. :-(
msg213070 - (view) Author: Jurko Gospodnetić (Jurko.Gospodnetić) * Date: 2014-03-10 19:02
> Nor was Martin suggesting it as far as I can tell

I'm sorry if I came across too strongly. I can assure you I meant no disrespect nor have I at any point felt affronted by anything anyone else said in this thread/issue. :-)
msg213077 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-03-10 20:13
I would be in favour of having separate keys for 32-bit and 64-bit installs (in addition to the current one, if dropping it completely is not an option). We use the registry keys in PTVS (http://pytools.codeplex.com/) to detect installed interpreters, so the collision here means we can only detect one per-user interpreter per-version.

We haven't received many complaints about this, so we assume that not many people install both the 32-bit and 64-bit versions of Python. However, we do it all the time, so we'd be happy with a fix just for us :)

As far as the redirection goes, that is largely a compatibility 'feature' for running 32-bit programs on 64-bit Windows. HKEY_CURRENT_USER\Software\Wow6432Node is not official (even though there's some buggy software that thinks it is...) and doesn't mean anything (while the one in HKEY_LOCAL_MACHINE does).

The intent is that software uses differently named keys when storing different settings. Having "Python\PythonCore\3.4", "3.4-32" and/or "3.4-64" seems appropriate to me (where the "3.4" value keeps the current last-one-wins behaviour).

Out of interest, what other issues exist for the per-user installation? I normally prefer it because I like keeping the DLLs out of System32, and I practically never hit any issues (Python 2.5 has one with virtualenv, but that's about it).
msg213174 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2014-03-11 20:40
I haven't tested the per-user installations in the last five years, so I don't actually know what the problems are these days. One key issue is the elevated privileges topic (UAC). Correct me if I'm wrong: installing per-user still requires to run the installer with administrator privileges (i.e. you get the UAC prompt), right?

The other (solved) oddity is that the installer needs to include two copies of msvcrt, as the merge module only supports installation into the SxS folder.

As for this issue: if somebody provides a complete patch, I'm willing to consider it. Make sure to discuss backwards compatibility.

Simultaneous installation of multiple patch levels is out of scope of this issue. Note that you can get the installer to support it by editing the UpgradeCode in the MSI file with orca.
msg213180 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2014-03-11 22:17
UAC is still required for the installer - unfortunately MSI just doesn't support having a single package that can do both elevated and unelevated installs. Still, you can install once per-user and then copy the PythonXY folder onto another machine, which does not work as easily with the all-users install. I actually have a collection of zipped Python installs and an automated test that extracts each one in turn.

I'm not sure what constitutes a "complete" patch, but I've attached a patch for msi.py (though I have no idea how it works and can't test it locally) and launcher.c to look at the new keys. If there are tests for these I don't see where they are, but I'm happy to extend them.

I don't think backwards compatibility is a concern here. Older versions of Python will continue to incorrectly handle side-by-side per-user installations with the py.exe launcher and any other tools that use the registry to find installations. Existing tools that are not modified will find Python 3.5 installations with identical mechanics to previously, while those that also look for the InstallPath32 and *64 keys will find both installations if they are there. Even if the changes are backported as a bugfix, nothing changes for tools that are not aware of the new keys.
History
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 65082
2014-03-11 22:17:18steve.dowersetfiles: + 20883_1.patch
keywords: + patch
messages: + msg213180
2014-03-11 20:40:47loewissetmessages: + msg213174
2014-03-10 20:13:53steve.dowersetnosy: + steve.dower
messages: + msg213077
2014-03-10 19:02:38Jurko.Gospodnetićsetmessages: + msg213070
2014-03-10 18:57:22Jurko.Gospodnetićsetmessages: + msg213068
2014-03-10 18:53:16paul.mooresetmessages: + msg213066
2014-03-10 18:41:04Jurko.Gospodnetićsetmessages: + msg213065
2014-03-10 18:39:58paul.mooresetnosy: + paul.moore
messages: + msg213064
2014-03-10 17:51:48loewissetstatus: open -> closed
resolution: not a bug
messages: + msg213053
2014-03-10 15:57:45vstinnersetnosy: + loewis, tim.golden
2014-03-10 15:46:44Jurko.Gospodnetićsetmessages: + msg213046
2014-03-10 15:33:40Jurko.Gospodnetićcreate