mirror of https://github.com/python/cpython.git
Added uninstall option
This commit is contained in:
parent
604cefa8df
commit
03dea6d026
|
@ -2,17 +2,19 @@ Python 1.4beta3 for Windows NT 3.5
|
|||
==================================
|
||||
|
||||
The zip file pyth14b3.zip contains a preliminary binary release of
|
||||
Python 1.4beta3 for Windows NT 3.5, with Tcl/Tk support. The
|
||||
installation has not been tested on Windows '95 or Windows 3.1 with
|
||||
Win32s. For general information on Python, see http://www.python.org/.
|
||||
Python 1.4beta3 for Windows NT 3.5 and Windows '95, with Tcl/Tk
|
||||
support. The installation has not been tested on Windows 3.1 with
|
||||
Win32s. For general information on Python, see
|
||||
http://www.python.org/.
|
||||
|
||||
To install:
|
||||
|
||||
Unzip the archive in the root of a file system with enough space. It
|
||||
will create a directory \Python1.4b3 containing subdirectories Bin and
|
||||
Lib and files setup.bat and setup.py. (If you don't have a zip
|
||||
program that supports long filenames, get the file winzip95.exe and
|
||||
install it -- this is WinZip 6.1 for 32-bit Windows systems.)
|
||||
Lib and some files, including setup.bat, setup.py, uninstall.bat, and
|
||||
uninstall.py. (If you don't have a zip program that supports long
|
||||
filenames, get the file winzip95.exe and install it -- this is WinZip
|
||||
6.1 for 32-bit Windows systems.)
|
||||
|
||||
Run the SETUP.BAT file found in directory just created. When it is
|
||||
done, press Enter.
|
||||
|
@ -35,6 +37,10 @@ environment variables. E.g. if you installed Tcl/Tk in C:\TCL (the
|
|||
default suggested by the installer), set TCL_LIBRARY to
|
||||
"C:\TCL\lib\tcl7.5" and set TK_LIBRARY to "C:\TCL\lib\tk4.1".
|
||||
|
||||
On Windows '95, you also need to add the directory "C:\TCL\bin" (or
|
||||
whereever the Tcl bin directory ended up) to the PATH environment
|
||||
variable. (Sorry, I don't know how to do this myself :-( )
|
||||
|
||||
Once Tcl/Tk is installed, you should be able to type the following
|
||||
commands in Python:
|
||||
|
||||
|
@ -44,6 +50,16 @@ commands in Python:
|
|||
This creates a simple test dialog box (you may have to move the Python
|
||||
window a bit to see it). Click on OK to get the Python prompt back.
|
||||
|
||||
August 30, 1996
|
||||
To uninstall:
|
||||
|
||||
Run the batch file UNINSTALL.BAT. This will run the Python script
|
||||
uninstall.py, which undoes the registry additions and removes most
|
||||
installed files. The batch file then proceed to remove some files
|
||||
that the Python script can't remove (because it's using them). The
|
||||
batch file ends with an error because it deletes itself. Hints on how
|
||||
to avoid this (and also on how to remove the installation directory
|
||||
itself) are gracefully accepted.
|
||||
|
||||
September 3, 1996
|
||||
|
||||
--Guido van Rossum (home page: http://www.python.org/~guido/)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"""Setup script for Windows NT 3.5 until we have a proper installer.
|
||||
"""Setup script for Windows NT 3.5 and Windows 95.
|
||||
|
||||
Run this with the current directory set to the Python ``root''.
|
||||
"""
|
||||
|
@ -171,9 +171,24 @@ def listtree(handle, level=0):
|
|||
#listtree(pythonhandle)
|
||||
win32api.RegCloseKey(pythonhandle)
|
||||
|
||||
print "Registering uninstaller..."
|
||||
pwd = nt.getcwd()
|
||||
uninstaller = '"%s\\uninstall.bat" "%s"' % (pwd, pwd)
|
||||
uninstallkey = \
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Python"+sys.winver
|
||||
try:
|
||||
uihandle = win32api.RegOpenKey(roothandle, uninstallkey)
|
||||
except win32api.error, msg:
|
||||
uihandle = win32api.RegCreateKey(roothandle, uninstallkey)
|
||||
win32api.RegSetValueEx(uihandle, "DisplayName", None, win32con.REG_SZ,
|
||||
"Python "+sys.winver)
|
||||
win32api.RegSetValueEx(uihandle, "UninstallString", None, win32con.REG_SZ,
|
||||
uninstaller)
|
||||
win32api.RegCloseKey(uihandle)
|
||||
|
||||
print "Registering Python Interpreter as shell for *.py files..."
|
||||
pwd = nt.getcwd()
|
||||
interpreter = '"' + pwd + '\\Bin\\python.exe" -i %1'
|
||||
interpreter = '"%s\\Bin\\python.exe" -i "%%1"' % pwd
|
||||
print "Interpreter command is", interpreter
|
||||
root = win32con.HKEY_CLASSES_ROOT
|
||||
sz = win32con.REG_SZ
|
||||
|
@ -227,6 +242,8 @@ def listtree(handle, level=0):
|
|||
Get a handle for an existing subdirectory
|
||||
RegCreateKey(handle, keypath) -> handle
|
||||
Get a handle for a new subdirectory
|
||||
RegDeleteKey(handle, key)
|
||||
Delete the given subdirectory -- must be empty
|
||||
RegCloseKey(handle)
|
||||
Close a handle
|
||||
RegGetValue(handle, subkey) -> string
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
cd "%1"
|
||||
bin\python.exe uninstall.py
|
||||
del lib\win\*.pyc
|
||||
del lib\win\*.pyd
|
||||
del lib\win\*.py
|
||||
rd lib\win
|
||||
rd lib
|
||||
del bin\*.exe
|
||||
del bin\*.dll
|
||||
rd bin
|
||||
del uninstall.*
|
|
@ -0,0 +1,78 @@
|
|||
"""Uninstaller for Windows NT 3.5 and Windows 95.
|
||||
|
||||
Actions:
|
||||
|
||||
1. Remove our entries from the Registry:
|
||||
- Software\Python\PythonCore\<winver>
|
||||
- Software\Microsoft\Windows\CurrentVersion\Uninstall\Python<winver>
|
||||
(Should we also remove the entry for .py and Python.Script?)
|
||||
|
||||
2. Remove the installation tree -- this is assumed to be the directory
|
||||
whose path is both os.path.dirname(sys.argv[0]) and sys.path[0]
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import nt
|
||||
import os
|
||||
import win32api
|
||||
import win32con
|
||||
|
||||
def rmkey(parent, key, level=0):
|
||||
sep = " "*level
|
||||
try:
|
||||
handle = win32api.RegOpenKey(parent, key)
|
||||
except win32api.error, msg:
|
||||
print sep + "No key", `key`
|
||||
return
|
||||
print sep + "Removing key", key
|
||||
while 1:
|
||||
try:
|
||||
subkey = win32api.RegEnumKey(handle, 0)
|
||||
except win32api.error, msg:
|
||||
break
|
||||
rmkey(handle, subkey, level+1)
|
||||
win32api.RegCloseKey(handle)
|
||||
win32api.RegDeleteKey(parent, key)
|
||||
print sep + "Done with", key
|
||||
|
||||
roothandle = win32con.HKEY_LOCAL_MACHINE
|
||||
pythonkey = "Software\\Python\\PythonCore\\" + sys.winver
|
||||
rmkey(roothandle, pythonkey)
|
||||
uninstallkey = \
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Python"+sys.winver
|
||||
rmkey(roothandle, uninstallkey)
|
||||
|
||||
def rmtree(dir, level=0):
|
||||
sep = " "*level
|
||||
print sep+"rmtree", dir
|
||||
for name in os.listdir(dir):
|
||||
if level == 0 and \
|
||||
os.path.normcase(name) == os.path.normcase("uninstall.bat"):
|
||||
continue
|
||||
fn = os.path.join(dir, name)
|
||||
if os.path.isdir(fn):
|
||||
rmtree(fn, level+1)
|
||||
else:
|
||||
try:
|
||||
os.remove(fn)
|
||||
except os.error, msg:
|
||||
print sep+" can't remove", `fn`, msg
|
||||
else:
|
||||
print sep+" removed", `fn`
|
||||
try:
|
||||
os.rmdir(dir)
|
||||
except os.error, msg:
|
||||
print sep+"can't remove directory", `dir`, msg
|
||||
else:
|
||||
print sep+"removed directory", `dir`
|
||||
|
||||
pwd = os.getcwd()
|
||||
scriptdir = os.path.normpath(os.path.join(pwd, os.path.dirname(sys.argv[0])))
|
||||
pathdir = os.path.normpath(os.path.join(pwd, sys.path[0]))
|
||||
if scriptdir == pathdir:
|
||||
rmtree(pathdir)
|
||||
else:
|
||||
print "inconsistend script directory, not removing any files."
|
||||
print "script directory =", `scriptdir`
|
||||
print "path directory =", `pathdir`
|
Loading…
Reference in New Issue