Issue 983775: Allow bdist_wininst to install for non-admin users (original) (raw)
Attached is a patch which allows a distutils binary installation to work when Python is installed by a non-admin, and the extension is also to be installed by a non-admin user.
It makes the following changes:
- When enumerating the Python versions found, also remember the HKEY they were found under.
- When installing, if Python was installed under HKCU, we will too. If Python was installed under HKLM, we check the permissions of the current user, and install where we can.
- The "root" key we use is a global variable - all registry setting and delete functions use this global rather than a hardcoded HKLM.
- A new entry is written to the install log, indicating the key we used. Uninstallation is based on this key.
Another change in this patch is that 'tempnam()' is used rather than 'tmpnam()' - 'tmpnam' creates a temp file on the root of the current drive, and if this is readonly would explain the 'freopen' errors occasionally reported. 'tempnam' creates the temp file in the %TEMP% directory.
I've tested this when Python is installed by an admin, but the person installing the extension does not have admin permissions. Assuming the user has write permissions into the Python directory, this works correctly.
As usual, assigning to Thomas for comment/review.