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: bdist_wininst install_script not run on uninstall
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: mhammond Nosy List: eric.araujo, loewis, mhammond, tarek, vstinner
Priority: normal Keywords: patch

Created on 2011-05-28 02:08 by mhammond, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
setup.py mhammond, 2011-05-28 02:08 Sample setup script
hello.py mhammond, 2011-05-28 02:09 A stub for the script being installed
hello-install.py mhammond, 2011-05-28 02:09 the install script
issue12200.patch mhammond, 2011-05-31 01:43 Proposed fix for 3.2 review
Messages (6)
msg137105 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2011-05-28 02:08
Probably in all versions, but certainly in 2.7.

If you create an installer with bdist_wininst and specify an install_script, that script is not run on uninstallation.

See attached test case: setup.py specifies an install_script which just appends argv to %TEMP%/uninstall-test.txt.

* Create the installer with "python setup.py bdist_wininst"
* Execute the installer (ie, "dist\hello-0.1.win32.exe")
* Check %TEMP%/uninstall-test.txt - it should have 1 line:
['o:\\src\\python-2.6\\Scripts\\hello-install.py', '-install']
* Uninstall the package.
* Check %TEMP%/uninstall-test.txt - it *should* have a new line reflecting the uninstall.  Instead it is unchanged.

To get more info:
* Reinstall the package.
* Manually uninstall using the cmdline (with adjusted paths)
C:\> "c:\python26\Removehello.exe" -u "c:\python26\hello-wininst.log" > %TEMP%\delme.out 2>&1

Check the contents of %TEMP%\delme.out - you will see:
*** Could not load Python ****** Could not run installation script ***

Digging into the source code of install.c - the problem is that although the Python DLL name is parsed from the log file, this isn't reflected in the global variables python_dir or pythondll - so they remain empty strings and attempting to load the empty string as Python causes the error messages.
msg137448 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-01 17:38
I cannot review the patch (I don’t know C), but I will trust you.  Could you add a test to prevent regressions?
msg137463 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2011-06-01 23:07
Adding tests would be fairly painful - there is no test infrastructure in place for generating and running installers at all, and worse, the changes are likely to not work correctly when run from a Python "build" tree when the built DLL is not installed into System32 (the patch basically assumes an "installed" dir structure rather than a "built" one.)
msg137467 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2011-06-01 23:51
(OTOH though, I could tweak the patch to work in a built tree - it would mean appending "PCBuild" to the dir and retrying the DLL load if the other options fail...)
msg137535 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-03 15:49
If it’s not too much hassle for you and if it doesn’t improve maintenance costs, we’d feel safer with a test.

Martin, could you review this patch?
msg384830 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-01-11 12:52
The distutils bdist_wininst command has been removed in Python 3.10: see bpo-42802.
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56409
2021-01-11 12:52:38vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg384830

resolution: wont fix
stage: patch review -> resolved
2011-06-03 15:49:51eric.araujosetnosy: + loewis
messages: + msg137535
2011-06-01 23:51:33mhammondsetmessages: + msg137467
2011-06-01 23:07:32mhammondsetmessages: + msg137463
2011-06-01 17:38:55eric.araujosetmessages: + msg137448
versions: - Python 3.4
2011-05-31 01:43:23mhammondsetfiles: + issue12200.patch
assignee: tarek -> mhammond
stage: patch review
keywords: + patch
versions: + Python 2.7, Python 3.2, Python 3.3, Python 3.4
2011-05-28 02:09:36mhammondsetfiles: + hello-install.py
2011-05-28 02:09:18mhammondsetfiles: + hello.py
2011-05-28 02:08:46mhammondcreate