mirror of
https://github.com/python/cpython.git
synced 2025-09-23 00:43:12 +00:00
Getting rid of this ancient stuff.
This commit is contained in:
parent
41b4f3875b
commit
bc160b50c5
5 changed files with 0 additions and 534 deletions
|
@ -1,173 +0,0 @@
|
||||||
(I had no time to update and test this directory. It is provided
|
|
||||||
for your information only.)
|
|
||||||
|
|
||||||
Python 1.4beta3 for Windows NT 3.5 and Windows 95
|
|
||||||
=================================================
|
|
||||||
|
|
||||||
The zip file pyth14b3.zip contains a preliminary binary release of
|
|
||||||
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 on a file system with enough space. It will create
|
|
||||||
a directory Python1.4b3 containing subdirectories Bin and 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.
|
|
||||||
|
|
||||||
Tcl/Tk support requires additional installation steps, see below.
|
|
||||||
|
|
||||||
|
|
||||||
To use
|
|
||||||
------
|
|
||||||
|
|
||||||
Python runs in a console (DOS) window. From the File Manager, run the
|
|
||||||
file python.exe found in the Bin subdirectory. You can also drag it
|
|
||||||
to a program group of your choice for easier access. Opening any file
|
|
||||||
ending in .py from the file manager should run it.
|
|
||||||
|
|
||||||
|
|
||||||
To use with Tkinter
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
Get the file win41p1.exe from /pub/python/nt/ on ftp.python.org or
|
|
||||||
from ftp site ftp.sunlabs.com, directory /pub/tcl/. This is a
|
|
||||||
self-extracting archive containing the Tcl/Tk distribution for Windows
|
|
||||||
NT. Don't use an older version.
|
|
||||||
|
|
||||||
Using the control panel, set the TCL_LIBRARY and TK_LIBRARY
|
|
||||||
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". Also
|
|
||||||
add the directory "C:\TCL\bin" (or whereever the Tcl bin directory
|
|
||||||
ended up) to the PATH environment variable.
|
|
||||||
|
|
||||||
On Windows '95, you need to edit AUTOEXEC.BAT for this, e.g. by adding
|
|
||||||
the lines
|
|
||||||
|
|
||||||
SET TCL_LIBRARY=C:\Program Files\TCL\lib\tcl7.5
|
|
||||||
SET TK_LIBRARY=C:\Program Files\TCL\lib\tk4.1
|
|
||||||
SET PATH="%PATH%";"C:\Program Files\TCL\bin"
|
|
||||||
|
|
||||||
(substituting the actual location of the TCL installation directory).
|
|
||||||
|
|
||||||
Once Tcl/Tk is installed, you should be able to type the following
|
|
||||||
commands in Python:
|
|
||||||
|
|
||||||
>>> import Tkinter
|
|
||||||
>>> Tkinter._test()
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
Troubleshooting
|
|
||||||
---------------
|
|
||||||
|
|
||||||
The following procedure will test successive components required for
|
|
||||||
successful use of Python and Tkinter. The steps before "import
|
|
||||||
_tkinter" can be used to verify the proper installation of the Python
|
|
||||||
core.
|
|
||||||
|
|
||||||
- First, run the Python interpreter (python.exe). This should give
|
|
||||||
you a ">>>" prompt in a "MS-DOS console" window. This may fail with a
|
|
||||||
complaint about being unable to find the file MSVC40RT.DLL. This file
|
|
||||||
(along with several other files) is included in the MSOFTDLL.EXE
|
|
||||||
self-extracting archive available in the /pub/python/wpy directory on
|
|
||||||
ftp.python.org. After extraction, move MSVCRT40.NT to
|
|
||||||
\Windows\System\MSVCRT40.DLL (note the change of extension).
|
|
||||||
|
|
||||||
- If you can't get a ">>>" prompt, your core Python installation may
|
|
||||||
be botched. Reinstall from the ZIP file (see above) and run
|
|
||||||
SETUP.BAT.
|
|
||||||
|
|
||||||
- At the ">>>" prompt, type a few commands. Each command should
|
|
||||||
succeed without complaints. Remember that Python is a case sensitive
|
|
||||||
language, so type the commands exactly as shown ("tkinter" and
|
|
||||||
"Tkinter" are two very different things).
|
|
||||||
|
|
||||||
>>> import sys
|
|
||||||
|
|
||||||
If this fails, you can't type :-) (Explanation: this is a
|
|
||||||
built-in module that is pre-initialized before the first ">>>"
|
|
||||||
prompt is printed. There is no way that this import can fail
|
|
||||||
except by a typo.)
|
|
||||||
|
|
||||||
>>> import string
|
|
||||||
|
|
||||||
If this fails, the Python library cannot be found. Reinstall
|
|
||||||
Python. (Explanation: the registry entry for PythonPath is
|
|
||||||
botched. Inspect sys.path to see what it is. If it is
|
|
||||||
something like ['.', '.\\lib', '.\\lib\\win'], the setup.py
|
|
||||||
script has not run successfully and you may get away with
|
|
||||||
rerunning the SETUP.BAT file.)
|
|
||||||
|
|
||||||
>>> import _tkinter
|
|
||||||
|
|
||||||
This can fail in a number of ways:
|
|
||||||
|
|
||||||
ImportError: No module named _tkinter
|
|
||||||
The Python module file _tkinter.dll can't be found.
|
|
||||||
Since it is installed by default, the installation is
|
|
||||||
probably botched. Reinstall Python.
|
|
||||||
|
|
||||||
ImportError: DLL load failed: The specified module could not
|
|
||||||
be found. (Possibly with a dialog box explaining that
|
|
||||||
TCL75.DLL or TK41.DLL could not be found.)
|
|
||||||
Probably a Tcl/Tk installation error. Reinstall Tcl/Tk.
|
|
||||||
Note that on Windows '95, you may need to add the Tcl
|
|
||||||
bin directory to the PATH environment variable.
|
|
||||||
|
|
||||||
Other failures:
|
|
||||||
It may be possible that you have an early prerelease
|
|
||||||
TCL75.DLL or TK41.DLL, which is incompatible with the
|
|
||||||
_tkinter module in the Python distribution. This will
|
|
||||||
most likely result in error messages that don't make a
|
|
||||||
lot of sense. Try installing Tcl/Tk from the
|
|
||||||
win41p1.exe self-extracting archive found in
|
|
||||||
/pub/python/nt on ftp.python.org.
|
|
||||||
|
|
||||||
>>> import Tkinter
|
|
||||||
|
|
||||||
If this fails, your Python library or sys.path is botched.
|
|
||||||
Your best bet, again, is to reinstall Python.
|
|
||||||
|
|
||||||
>>> Tkinter._test()
|
|
||||||
|
|
||||||
This should pop up a window with a label ("Proof-of-existence
|
|
||||||
test for TK") and two buttons ("Click me!" and "QUIT").
|
|
||||||
If you get nothing at all (not even a ">>>" prompt), the
|
|
||||||
window is probably hiding behind the Python console window.
|
|
||||||
Move the console window around to reveal the test window.
|
|
||||||
|
|
||||||
If you get an exception instead, it is most likely a verbose
|
|
||||||
complaint from Tcl/Tk about improper installation. This is
|
|
||||||
usually caused by bad or missing values for the environment
|
|
||||||
variables TK_LIBRARY or TCL_LIBRARY. See the installation
|
|
||||||
instructions above.
|
|
||||||
|
|
||||||
|
|
||||||
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 +0,0 @@
|
||||||
bin\python.exe -i .\setup.py
|
|
|
@ -1,271 +0,0 @@
|
||||||
"""Setup script for Windows NT 3.5 and Windows 95.
|
|
||||||
|
|
||||||
Run this with the current directory set to the Python ``root''.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import strop
|
|
||||||
|
|
||||||
del sys.path[1:]
|
|
||||||
|
|
||||||
try:
|
|
||||||
import nt
|
|
||||||
except ImportError:
|
|
||||||
print "This script should only be run on a Windows (NT or '95) system."
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
sys.winver
|
|
||||||
print "This Python version appears to be", sys.winver
|
|
||||||
except NameError:
|
|
||||||
print "Huh? sys.winver is not defined!"
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# Try to import a common module that *should* work.
|
|
||||||
print "Looking for Python root directory..."
|
|
||||||
while 1:
|
|
||||||
pwd = nt.getcwd()
|
|
||||||
##print "Could it be", `pwd`, "?"
|
|
||||||
try:
|
|
||||||
open("Lib\\os.py").close()
|
|
||||||
##print "It appears so."
|
|
||||||
break
|
|
||||||
except IOError:
|
|
||||||
##print "Hm, it doesn't appear to be. Try the parent directory."
|
|
||||||
try:
|
|
||||||
opwd = pwd
|
|
||||||
nt.chdir("..")
|
|
||||||
pwd = nt.getcwd()
|
|
||||||
if opwd == pwd:
|
|
||||||
##print "Seems like we're in the root already."
|
|
||||||
raise nt.error
|
|
||||||
except nt.error:
|
|
||||||
##print "Can't chdir to the parent -- we're stuck."
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
##print "Try again one level higher."
|
|
||||||
continue
|
|
||||||
print "Hey, would you like to help?"
|
|
||||||
print "Please enter the pathname of the Python root."
|
|
||||||
while 1:
|
|
||||||
try:
|
|
||||||
dirname = raw_input("Python root: ")
|
|
||||||
except EOFError:
|
|
||||||
print "OK, I give up."
|
|
||||||
sys.exit(1)
|
|
||||||
if not dirname:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
nt.chdir(dirname)
|
|
||||||
except nt.error:
|
|
||||||
print "That directory doesn't seem to exist."
|
|
||||||
print "Please try again."
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
pwd = nt.getcwd()
|
|
||||||
print "Python root directory is", pwd
|
|
||||||
sys.path[1:] = [".\\Lib", ".\\Lib\win", ".\\Bin", ".\\vc40"]
|
|
||||||
|
|
||||||
# Now we should be in a position to import win32api and win32con
|
|
||||||
|
|
||||||
try:
|
|
||||||
import win32api
|
|
||||||
except ImportError:
|
|
||||||
print "Blech. We *still* can't import win32api."
|
|
||||||
print "Giving up."
|
|
||||||
sys.exit(1)
|
|
||||||
try:
|
|
||||||
import win32con
|
|
||||||
except ImportError:
|
|
||||||
print "Beh. We have win32api but not win32con."
|
|
||||||
print "Making do with a dummy."
|
|
||||||
class win32con:
|
|
||||||
REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002L
|
|
||||||
REG_NOTIFY_CHANGE_SECURITY = 0x00000008L
|
|
||||||
REG_RESOURCE_REQUIREMENTS_LIST = 10
|
|
||||||
REG_NONE = 0
|
|
||||||
REG_SZ = 1
|
|
||||||
REG_EXPAND_SZ = 2
|
|
||||||
REG_BINARY = 3
|
|
||||||
REG_DWORD = 4
|
|
||||||
REG_DWORD_LITTLE_ENDIAN = 4
|
|
||||||
REG_DWORD_BIG_ENDIAN = 5
|
|
||||||
REG_LINK = 6
|
|
||||||
REG_MULTI_SZ = 7
|
|
||||||
REG_RESOURCE_LIST = 8
|
|
||||||
REG_FULL_RESOURCE_DESCRIPTOR = 9
|
|
||||||
HKEY_CLASSES_ROOT = 0x80000000
|
|
||||||
HKEY_CURRENT_USER = 0x80000001
|
|
||||||
HKEY_LOCAL_MACHINE = 0x80000002
|
|
||||||
HKEY_USERS = 0x80000003
|
|
||||||
HKEY_PERFORMANCE_DATA = 0x80000004
|
|
||||||
HKEY_PERFORMANCE_TEXT = 0x80000050
|
|
||||||
HKEY_PERFORMANCE_NLSTEXT = 0x80000060
|
|
||||||
|
|
||||||
|
|
||||||
def listtree(handle, level=0):
|
|
||||||
i = 0
|
|
||||||
while 1:
|
|
||||||
try:
|
|
||||||
key = win32api.RegEnumKey(handle, i)
|
|
||||||
except win32api.error:
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
value = win32api.RegQueryValue(handle, key)
|
|
||||||
except win32api.error, msg:
|
|
||||||
try:
|
|
||||||
msg = msg[2]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
value = "*** Error: %s" % str(msg)
|
|
||||||
print " "*level + "%s: %s" % (key, value)
|
|
||||||
subhandle = win32api.RegOpenKey(handle, key)
|
|
||||||
listtree(subhandle, level+1)
|
|
||||||
win32api.RegCloseKey(subhandle)
|
|
||||||
i = i+1
|
|
||||||
|
|
||||||
roothandle = win32con.HKEY_LOCAL_MACHINE
|
|
||||||
pythonkey = "Software\\Python"
|
|
||||||
try:
|
|
||||||
pythonhandle = win32api.RegOpenKey(roothandle, pythonkey)
|
|
||||||
except win32api.error:
|
|
||||||
pythonhandle = win32api.RegCreateKey(roothandle, pythonkey)
|
|
||||||
|
|
||||||
## listtree(pythonhandle)
|
|
||||||
## try:
|
|
||||||
## handle = win32api.RegOpenKey(pythonhandle, "JustTesting")
|
|
||||||
## except win32api.error, msg:
|
|
||||||
## try: msg = msg[2]
|
|
||||||
## except: pass
|
|
||||||
## ##print "Error opening, try creating instead:", msg
|
|
||||||
## handle = win32api.RegCreateKey(pythonhandle, "JustTesting")
|
|
||||||
## win32api.RegSetValue(handle, "test1", win32con.REG_SZ, "NO!")
|
|
||||||
## win32api.RegSetValue(handle, "test2", win32con.REG_SZ, "YES!")
|
|
||||||
## win32api.RegDeleteKey(handle, "test1")
|
|
||||||
## win32api.RegDeleteKey(handle, "test2")
|
|
||||||
## win32api.RegCloseKey(handle)
|
|
||||||
## win32api.RegDeleteKey(pythonhandle, "JustTesting")
|
|
||||||
## listtree(pythonhandle)
|
|
||||||
|
|
||||||
print "Setting PythonPath..."
|
|
||||||
corekey = "PythonCore\\%s" % sys.winver
|
|
||||||
try:
|
|
||||||
corehandle = win32api.RegOpenKey(pythonhandle, corekey)
|
|
||||||
except win32api.error, msg:
|
|
||||||
corehandle = win32api.RegCreateKey(pythonhandle, corekey)
|
|
||||||
path = []
|
|
||||||
pwd = nt.getcwd()
|
|
||||||
for i in ["Bin",
|
|
||||||
"Lib",
|
|
||||||
"Lib\\win",
|
|
||||||
"Lib\\tkinter",
|
|
||||||
"Lib\\test",
|
|
||||||
"Lib\\dos_8x3"]:
|
|
||||||
i = pwd + "\\" + i
|
|
||||||
path.append(i)
|
|
||||||
sys.path[1:] = path
|
|
||||||
pathvalue = strop.join(path, ";")
|
|
||||||
#print "Setting PythonPath to", pathvalue
|
|
||||||
win32api.RegSetValue(corehandle, "PythonPath", win32con.REG_SZ, pathvalue)
|
|
||||||
win32api.RegCloseKey(corehandle)
|
|
||||||
#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 = '"%s\\Bin\\python.exe" -i "%%1"' % pwd
|
|
||||||
print "Interpreter command is", interpreter
|
|
||||||
root = win32con.HKEY_CLASSES_ROOT
|
|
||||||
sz = win32con.REG_SZ
|
|
||||||
win32api.RegSetValue(root, ".py", sz, "Python.Script")
|
|
||||||
win32api.RegSetValue(root , "Python.Script", sz, "Python Script")
|
|
||||||
win32api.RegSetValue(root , "Python.Script\\Shell\\Open\\Command", sz,
|
|
||||||
interpreter)
|
|
||||||
|
|
||||||
import compileall
|
|
||||||
print "Compiling all library modules..."
|
|
||||||
compileall.main()
|
|
||||||
|
|
||||||
print "Installation complete."
|
|
||||||
|
|
||||||
envkeys = map(strop.upper, nt.environ.keys())
|
|
||||||
if 'PYTHONPATH' in envkeys:
|
|
||||||
print """
|
|
||||||
**********************************************************************
|
|
||||||
WARNING!
|
|
||||||
You have set the environment variable PYTHONPATH.
|
|
||||||
This will override the default Python module search path
|
|
||||||
and probably cause you to use an old or broken Python installation.
|
|
||||||
Go into your control panel *now* and delete PYTHONPATH!
|
|
||||||
**********************************************************************
|
|
||||||
"""
|
|
||||||
|
|
||||||
raw_input("Press Enter to exit: ")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
registry_doc = """Summary of the Win32 API Registry interfaces.
|
|
||||||
|
|
||||||
Concepts:
|
|
||||||
A _directory_ is a collection of key/value pairs.
|
|
||||||
You need a _handle_ for a directory to do anything with it.
|
|
||||||
There are some predefined keys, e.g. HKEY_LOCAL_MACHINE.
|
|
||||||
A _key_ is an ASCII string; NT file system conventions apply.
|
|
||||||
A _value_ has a type and some data; there are predefined types
|
|
||||||
(e.g. REG_SZ is a string, REG_DWORD is a 4-byte integer).
|
|
||||||
There's some fishiness in that in fact multiple, named values
|
|
||||||
can appear under each key, but this seems little used (in this
|
|
||||||
case, the value is best seen as a structured value).
|
|
||||||
A key can also refer to a _subdirectory_. In this case the
|
|
||||||
associated value is typically empty. To get a handle for a
|
|
||||||
subdirectory, use RegOpenKey(handle, key). The key can also
|
|
||||||
be a backslash-separated path, so you can go directly from one of
|
|
||||||
the predefined keys to the directory you are interested in.
|
|
||||||
|
|
||||||
Most common functions:
|
|
||||||
RegOpenKey(handle, keypath) -> handle
|
|
||||||
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
|
|
||||||
Get the (unnamed) value stored as key in handle
|
|
||||||
RegSetValue(handle, subkey, type, value)
|
|
||||||
Set the (unnamed) value stored as key in handle, with given
|
|
||||||
type; type should be REG_SZ
|
|
||||||
RegSetValueEx(handle, name, reserved, type, value)
|
|
||||||
Set the value with given name to the given type and value;
|
|
||||||
currently reserved is ignored and type should be REG_SZ
|
|
||||||
|
|
||||||
Functions to list directory contents (start counting at 0, fail if done):
|
|
||||||
RegEnumKey(handle, i)
|
|
||||||
Return the i'th subkey
|
|
||||||
RegEnumValue(handle, i)
|
|
||||||
Return the i'th name and value
|
|
||||||
|
|
||||||
Lesser used functions:
|
|
||||||
RegFlushKey(handle)
|
|
||||||
Flush the changes to the handle to disk (like Unix sync())
|
|
||||||
RegSaveKey(handle, filename, reserved)
|
|
||||||
Save the contents to a disk file (broken?!)
|
|
||||||
RegLoadKey(handle, keypath, filename)
|
|
||||||
Load the contents from a disk file (lots of restrictions!)
|
|
||||||
"""
|
|
|
@ -1,11 +0,0 @@
|
||||||
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.*
|
|
|
@ -1,78 +0,0 @@
|
||||||
"""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…
Add table
Add a link
Reference in a new issue