Uploaded Test files
This commit is contained in:
parent
f584ad9d97
commit
2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions
BIN
venv/Scripts/__pycache__/pywin32_postinstall.cpython-36.pyc
Normal file
BIN
venv/Scripts/__pycache__/pywin32_postinstall.cpython-36.pyc
Normal file
Binary file not shown.
BIN
venv/Scripts/__pycache__/pywin32_testall.cpython-36.pyc
Normal file
BIN
venv/Scripts/__pycache__/pywin32_testall.cpython-36.pyc
Normal file
Binary file not shown.
BIN
venv/Scripts/cmake.exe
Normal file
BIN
venv/Scripts/cmake.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/cpack.exe
Normal file
BIN
venv/Scripts/cpack.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/ctest.exe
Normal file
BIN
venv/Scripts/ctest.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/iptest.exe
Normal file
BIN
venv/Scripts/iptest.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/iptest3.exe
Normal file
BIN
venv/Scripts/iptest3.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/ipython.exe
Normal file
BIN
venv/Scripts/ipython.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/ipython3.exe
Normal file
BIN
venv/Scripts/ipython3.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jsonschema.exe
Normal file
BIN
venv/Scripts/jsonschema.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-bundlerextension.exe
Normal file
BIN
venv/Scripts/jupyter-bundlerextension.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-console.exe
Normal file
BIN
venv/Scripts/jupyter-console.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-kernel.exe
Normal file
BIN
venv/Scripts/jupyter-kernel.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-kernelspec.exe
Normal file
BIN
venv/Scripts/jupyter-kernelspec.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-migrate.exe
Normal file
BIN
venv/Scripts/jupyter-migrate.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-nbconvert.exe
Normal file
BIN
venv/Scripts/jupyter-nbconvert.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-nbextension.exe
Normal file
BIN
venv/Scripts/jupyter-nbextension.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-notebook.exe
Normal file
BIN
venv/Scripts/jupyter-notebook.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-qtconsole.exe
Normal file
BIN
venv/Scripts/jupyter-qtconsole.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-run.exe
Normal file
BIN
venv/Scripts/jupyter-run.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-serverextension.exe
Normal file
BIN
venv/Scripts/jupyter-serverextension.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-troubleshoot.exe
Normal file
BIN
venv/Scripts/jupyter-troubleshoot.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter-trust.exe
Normal file
BIN
venv/Scripts/jupyter-trust.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/jupyter.exe
Normal file
BIN
venv/Scripts/jupyter.exe
Normal file
Binary file not shown.
BIN
venv/Scripts/pygmentize.exe
Normal file
BIN
venv/Scripts/pygmentize.exe
Normal file
Binary file not shown.
637
venv/Scripts/pywin32_postinstall.py
Normal file
637
venv/Scripts/pywin32_postinstall.py
Normal file
|
@ -0,0 +1,637 @@
|
|||
# postinstall script for pywin32
|
||||
#
|
||||
# copies PyWinTypesxx.dll and PythonCOMxx.dll into the system directory,
|
||||
# and creates a pth file
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import shutil
|
||||
import time
|
||||
import distutils.sysconfig
|
||||
try:
|
||||
import winreg as winreg
|
||||
except:
|
||||
import winreg
|
||||
|
||||
# Send output somewhere so it can be found if necessary...
|
||||
import tempfile
|
||||
tee_f = open(os.path.join(tempfile.gettempdir(), 'pywin32_postinstall.log'), "w")
|
||||
class Tee:
|
||||
def __init__(self, file):
|
||||
self.f = file
|
||||
def write(self, what):
|
||||
if self.f is not None:
|
||||
try:
|
||||
self.f.write(what.replace("\n", "\r\n"))
|
||||
except IOError:
|
||||
pass
|
||||
tee_f.write(what)
|
||||
def flush(self):
|
||||
if self.f is not None:
|
||||
try:
|
||||
self.f.flush()
|
||||
except IOError:
|
||||
pass
|
||||
tee_f.flush()
|
||||
|
||||
# For some unknown reason, when running under bdist_wininst we will start up
|
||||
# with sys.stdout as None but stderr is hooked up. This work-around allows
|
||||
# bdist_wininst to see the output we write and display it at the end of
|
||||
# the install.
|
||||
if sys.stdout is None:
|
||||
sys.stdout = sys.stderr
|
||||
|
||||
sys.stderr = Tee(sys.stderr)
|
||||
sys.stdout = Tee(sys.stdout)
|
||||
|
||||
com_modules = [
|
||||
# module_name, class_names
|
||||
("win32com.servers.interp", "Interpreter"),
|
||||
("win32com.servers.dictionary", "DictionaryPolicy"),
|
||||
("win32com.axscript.client.pyscript","PyScript"),
|
||||
]
|
||||
|
||||
# Is this a 'silent' install - ie, avoid all dialogs.
|
||||
# Different than 'verbose'
|
||||
silent = 0
|
||||
|
||||
# Verbosity of output messages.
|
||||
verbose = 1
|
||||
|
||||
ver_string = "%d.%d" % (sys.version_info[0], sys.version_info[1])
|
||||
root_key_name = "Software\\Python\\PythonCore\\" + ver_string
|
||||
|
||||
try:
|
||||
# When this script is run from inside the bdist_wininst installer,
|
||||
# file_created() and directory_created() are additional builtin
|
||||
# functions which write lines to Python23\pywin32-install.log. This is
|
||||
# a list of actions for the uninstaller, the format is inspired by what
|
||||
# the Wise installer also creates.
|
||||
file_created
|
||||
is_bdist_wininst = True
|
||||
except NameError:
|
||||
is_bdist_wininst = False # we know what it is not - but not what it is :)
|
||||
def file_created(file):
|
||||
pass
|
||||
def directory_created(directory):
|
||||
pass
|
||||
def get_root_hkey():
|
||||
try:
|
||||
winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
|
||||
root_key_name, 0, winreg.KEY_CREATE_SUB_KEY)
|
||||
return winreg.HKEY_LOCAL_MACHINE
|
||||
except OSError as details:
|
||||
# Either not exist, or no permissions to create subkey means
|
||||
# must be HKCU
|
||||
return winreg.HKEY_CURRENT_USER
|
||||
|
||||
try:
|
||||
create_shortcut
|
||||
except NameError:
|
||||
# Create a function with the same signature as create_shortcut provided
|
||||
# by bdist_wininst
|
||||
def create_shortcut(path, description, filename,
|
||||
arguments="", workdir="", iconpath="", iconindex=0):
|
||||
import pythoncom
|
||||
from win32com.shell import shell, shellcon
|
||||
|
||||
ilink = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None,
|
||||
pythoncom.CLSCTX_INPROC_SERVER,
|
||||
shell.IID_IShellLink)
|
||||
ilink.SetPath(path)
|
||||
ilink.SetDescription(description)
|
||||
if arguments:
|
||||
ilink.SetArguments(arguments)
|
||||
if workdir:
|
||||
ilink.SetWorkingDirectory(workdir)
|
||||
if iconpath or iconindex:
|
||||
ilink.SetIconLocation(iconpath, iconindex)
|
||||
# now save it.
|
||||
ipf = ilink.QueryInterface(pythoncom.IID_IPersistFile)
|
||||
ipf.Save(filename, 0)
|
||||
|
||||
# Support the same list of "path names" as bdist_wininst.
|
||||
def get_special_folder_path(path_name):
|
||||
import pythoncom
|
||||
from win32com.shell import shell, shellcon
|
||||
|
||||
for maybe in """
|
||||
CSIDL_COMMON_STARTMENU CSIDL_STARTMENU CSIDL_COMMON_APPDATA
|
||||
CSIDL_LOCAL_APPDATA CSIDL_APPDATA CSIDL_COMMON_DESKTOPDIRECTORY
|
||||
CSIDL_DESKTOPDIRECTORY CSIDL_COMMON_STARTUP CSIDL_STARTUP
|
||||
CSIDL_COMMON_PROGRAMS CSIDL_PROGRAMS CSIDL_PROGRAM_FILES_COMMON
|
||||
CSIDL_PROGRAM_FILES CSIDL_FONTS""".split():
|
||||
if maybe == path_name:
|
||||
csidl = getattr(shellcon, maybe)
|
||||
return shell.SHGetSpecialFolderPath(0, csidl, False)
|
||||
raise ValueError("%s is an unknown path ID" % (path_name,))
|
||||
|
||||
def CopyTo(desc, src, dest):
|
||||
import win32api, win32con
|
||||
while 1:
|
||||
try:
|
||||
win32api.CopyFile(src, dest, 0)
|
||||
return
|
||||
except win32api.error as details:
|
||||
if details.winerror==5: # access denied - user not admin.
|
||||
raise
|
||||
if silent:
|
||||
# Running silent mode - just re-raise the error.
|
||||
raise
|
||||
tb = None
|
||||
full_desc = "Error %s\n\n" \
|
||||
"If you have any Python applications running, " \
|
||||
"please close them now\nand select 'Retry'\n\n%s" \
|
||||
% (desc, details.strerror)
|
||||
rc = win32api.MessageBox(0,
|
||||
full_desc,
|
||||
"Installation Error",
|
||||
win32con.MB_ABORTRETRYIGNORE)
|
||||
if rc == win32con.IDABORT:
|
||||
raise
|
||||
elif rc == win32con.IDIGNORE:
|
||||
return
|
||||
# else retry - around we go again.
|
||||
|
||||
# We need to import win32api to determine the Windows system directory,
|
||||
# so we can copy our system files there - but importing win32api will
|
||||
# load the pywintypes.dll already in the system directory preventing us
|
||||
# from updating them!
|
||||
# So, we pull the same trick pywintypes.py does, but it loads from
|
||||
# our pywintypes_system32 directory.
|
||||
def LoadSystemModule(lib_dir, modname):
|
||||
# See if this is a debug build.
|
||||
import imp
|
||||
for suffix_item in imp.get_suffixes():
|
||||
if suffix_item[0]=='_d.pyd':
|
||||
suffix = '_d'
|
||||
break
|
||||
else:
|
||||
suffix = ""
|
||||
filename = "%s%d%d%s.dll" % \
|
||||
(modname, sys.version_info[0], sys.version_info[1], suffix)
|
||||
filename = os.path.join(lib_dir, "pywin32_system32", filename)
|
||||
mod = imp.load_dynamic(modname, filename)
|
||||
|
||||
|
||||
def SetPyKeyVal(key_name, value_name, value):
|
||||
root_hkey = get_root_hkey()
|
||||
root_key = winreg.OpenKey(root_hkey, root_key_name)
|
||||
try:
|
||||
my_key = winreg.CreateKey(root_key, key_name)
|
||||
try:
|
||||
winreg.SetValueEx(my_key, value_name, 0, winreg.REG_SZ, value)
|
||||
finally:
|
||||
my_key.Close()
|
||||
finally:
|
||||
root_key.Close()
|
||||
if verbose:
|
||||
print(("-> %s\\%s[%s]=%r" % (root_key_name, key_name, value_name, value)))
|
||||
|
||||
def RegisterCOMObjects(register = 1):
|
||||
import win32com.server.register
|
||||
if register:
|
||||
func = win32com.server.register.RegisterClasses
|
||||
else:
|
||||
func = win32com.server.register.UnregisterClasses
|
||||
flags = {}
|
||||
if not verbose:
|
||||
flags['quiet']=1
|
||||
for module, klass_name in com_modules:
|
||||
__import__(module)
|
||||
mod = sys.modules[module]
|
||||
flags["finalize_register"] = getattr(mod, "DllRegisterServer", None)
|
||||
flags["finalize_unregister"] = getattr(mod, "DllUnregisterServer", None)
|
||||
klass = getattr(mod, klass_name)
|
||||
func(klass, **flags)
|
||||
|
||||
def RegisterPythonwin(register=True):
|
||||
""" Add (or remove) Pythonwin to context menu for python scripts.
|
||||
??? Should probably also add Edit command for pys files also.
|
||||
Also need to remove these keys on uninstall, but there's no function
|
||||
like file_created to add registry entries to uninstall log ???
|
||||
"""
|
||||
import os
|
||||
|
||||
lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1)
|
||||
classes_root=get_root_hkey()
|
||||
## Installer executable doesn't seem to pass anything to postinstall script indicating if it's a debug build,
|
||||
pythonwin_exe = os.path.join(lib_dir, "Pythonwin", "Pythonwin.exe")
|
||||
pythonwin_edit_command=pythonwin_exe + ' /edit "%1"'
|
||||
|
||||
keys_vals = [
|
||||
('Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Pythonwin.exe', '', pythonwin_exe),
|
||||
('Software\\Classes\\Python.File\\shell\\Edit with Pythonwin', 'command', pythonwin_edit_command),
|
||||
('Software\\Classes\\Python.NoConFile\\shell\\Edit with Pythonwin', 'command', pythonwin_edit_command),
|
||||
]
|
||||
|
||||
try:
|
||||
if register:
|
||||
for key, sub_key, val in keys_vals:
|
||||
## Since winreg only uses the character Api functions, this can fail if Python
|
||||
## is installed to a path containing non-ascii characters
|
||||
hkey = winreg.CreateKey(classes_root, key)
|
||||
if sub_key:
|
||||
hkey = winreg.CreateKey(hkey, sub_key)
|
||||
winreg.SetValueEx(hkey, None, 0, winreg.REG_SZ, val)
|
||||
hkey.Close()
|
||||
else:
|
||||
for key, sub_key, val in keys_vals:
|
||||
try:
|
||||
winreg.DeleteKey(classes_root, key)
|
||||
except OSError as why:
|
||||
winerror = getattr(why, 'winerror', why.errno)
|
||||
if winerror != 2: # file not found
|
||||
raise
|
||||
finally:
|
||||
# tell windows about the change
|
||||
from win32com.shell import shell, shellcon
|
||||
shell.SHChangeNotify(shellcon.SHCNE_ASSOCCHANGED, shellcon.SHCNF_IDLIST, None, None)
|
||||
|
||||
def get_shortcuts_folder():
|
||||
if get_root_hkey()==winreg.HKEY_LOCAL_MACHINE:
|
||||
try:
|
||||
fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
|
||||
except OSError:
|
||||
# No CSIDL_COMMON_PROGRAMS on this platform
|
||||
fldr = get_special_folder_path("CSIDL_PROGRAMS")
|
||||
else:
|
||||
# non-admin install - always goes in this user's start menu.
|
||||
fldr = get_special_folder_path("CSIDL_PROGRAMS")
|
||||
|
||||
try:
|
||||
install_group = winreg.QueryValue(get_root_hkey(),
|
||||
root_key_name + "\\InstallPath\\InstallGroup")
|
||||
except OSError:
|
||||
vi = sys.version_info
|
||||
install_group = "Python %d.%d" % (vi[0], vi[1])
|
||||
return os.path.join(fldr, install_group)
|
||||
|
||||
# Get the system directory, which may be the Wow64 directory if we are a 32bit
|
||||
# python on a 64bit OS.
|
||||
def get_system_dir():
|
||||
import win32api # we assume this exists.
|
||||
try:
|
||||
import pythoncom
|
||||
import win32process
|
||||
from win32com.shell import shell, shellcon
|
||||
try:
|
||||
if win32process.IsWow64Process():
|
||||
return shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_SYSTEMX86)
|
||||
return shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_SYSTEM)
|
||||
except (pythoncom.com_error, win32process.error):
|
||||
return win32api.GetSystemDirectory()
|
||||
except ImportError:
|
||||
return win32api.GetSystemDirectory()
|
||||
|
||||
def fixup_dbi():
|
||||
# We used to have a dbi.pyd with our .pyd files, but now have a .py file.
|
||||
# If the user didn't uninstall, they will find the .pyd which will cause
|
||||
# problems - so handle that.
|
||||
import win32api, win32con
|
||||
pyd_name = os.path.join(os.path.dirname(win32api.__file__), "dbi.pyd")
|
||||
pyd_d_name = os.path.join(os.path.dirname(win32api.__file__), "dbi_d.pyd")
|
||||
py_name = os.path.join(os.path.dirname(win32con.__file__), "dbi.py")
|
||||
for this_pyd in (pyd_name, pyd_d_name):
|
||||
this_dest = this_pyd + ".old"
|
||||
if os.path.isfile(this_pyd) and os.path.isfile(py_name):
|
||||
try:
|
||||
if os.path.isfile(this_dest):
|
||||
print(("Old dbi '%s' already exists - deleting '%s'" % (this_dest, this_pyd)))
|
||||
os.remove(this_pyd)
|
||||
else:
|
||||
os.rename(this_pyd, this_dest)
|
||||
print(("renamed '%s'->'%s.old'" % (this_pyd, this_pyd)))
|
||||
file_created(this_pyd+".old")
|
||||
except os.error as exc:
|
||||
print(("FAILED to rename '%s': %s" % (this_pyd, exc)))
|
||||
|
||||
def install(lib_dir):
|
||||
import traceback
|
||||
# The .pth file is now installed as a regular file.
|
||||
# Create the .pth file in the site-packages dir, and use only relative paths
|
||||
# We used to write a .pth directly to sys.prefix - clobber it.
|
||||
if os.path.isfile(os.path.join(sys.prefix, "pywin32.pth")):
|
||||
os.unlink(os.path.join(sys.prefix, "pywin32.pth"))
|
||||
# The .pth may be new and therefore not loaded in this session.
|
||||
# Setup the paths just in case.
|
||||
for name in "win32 win32\\lib Pythonwin".split():
|
||||
sys.path.append(os.path.join(lib_dir, name))
|
||||
# It is possible people with old versions installed with still have
|
||||
# pywintypes and pythoncom registered. We no longer need this, and stale
|
||||
# entries hurt us.
|
||||
for name in "pythoncom pywintypes".split():
|
||||
keyname = "Software\\Python\\PythonCore\\" + sys.winver + "\\Modules\\" + name
|
||||
for root in winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER:
|
||||
try:
|
||||
winreg.DeleteKey(root, keyname + "\\Debug")
|
||||
except WindowsError:
|
||||
pass
|
||||
try:
|
||||
winreg.DeleteKey(root, keyname)
|
||||
except WindowsError:
|
||||
pass
|
||||
LoadSystemModule(lib_dir, "pywintypes")
|
||||
LoadSystemModule(lib_dir, "pythoncom")
|
||||
import win32api
|
||||
# and now we can get the system directory:
|
||||
files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
|
||||
if not files:
|
||||
raise RuntimeError("No system files to copy!!")
|
||||
# Try the system32 directory first - if that fails due to "access denied",
|
||||
# it implies a non-admin user, and we use sys.prefix
|
||||
for dest_dir in [get_system_dir(), sys.prefix]:
|
||||
# and copy some files over there
|
||||
worked = 0
|
||||
try:
|
||||
for fname in files:
|
||||
base = os.path.basename(fname)
|
||||
dst = os.path.join(dest_dir, base)
|
||||
CopyTo("installing %s" % base, fname, dst)
|
||||
if verbose:
|
||||
print(("Copied %s to %s" % (base, dst)))
|
||||
# Register the files with the uninstaller
|
||||
file_created(dst)
|
||||
worked = 1
|
||||
# If this isn't sys.prefix (ie, System32), then nuke
|
||||
# any versions that may exist in sys.prefix - having
|
||||
# duplicates causes major headaches.
|
||||
if dest_dir != sys.prefix:
|
||||
bad_fname = os.path.join(sys.prefix, base)
|
||||
if os.path.exists(bad_fname):
|
||||
# let exceptions go here - delete must succeed
|
||||
os.unlink(bad_fname)
|
||||
if worked:
|
||||
break
|
||||
except win32api.error as details:
|
||||
if details.winerror==5:
|
||||
# access denied - user not admin - try sys.prefix dir,
|
||||
# but first check that a version doesn't already exist
|
||||
# in that place - otherwise that one will still get used!
|
||||
if os.path.exists(dst):
|
||||
msg = "The file '%s' exists, but can not be replaced " \
|
||||
"due to insufficient permissions. You must " \
|
||||
"reinstall this software as an Administrator" \
|
||||
% dst
|
||||
print(msg)
|
||||
raise RuntimeError(msg)
|
||||
continue
|
||||
raise
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"You don't have enough permissions to install the system files")
|
||||
|
||||
# Pythonwin 'compiles' config files - record them for uninstall.
|
||||
pywin_dir = os.path.join(lib_dir, "Pythonwin", "pywin")
|
||||
for fname in glob.glob(os.path.join(pywin_dir, "*.cfg")):
|
||||
file_created(fname[:-1] + "c") # .cfg->.cfc
|
||||
|
||||
# Register our demo COM objects.
|
||||
try:
|
||||
try:
|
||||
RegisterCOMObjects()
|
||||
except win32api.error as details:
|
||||
if details.winerror!=5: # ERROR_ACCESS_DENIED
|
||||
raise
|
||||
print("You do not have the permissions to install COM objects.")
|
||||
print("The sample COM objects were not registered.")
|
||||
except:
|
||||
print("FAILED to register the Python COM objects")
|
||||
traceback.print_exc()
|
||||
|
||||
# There may be no main Python key in HKCU if, eg, an admin installed
|
||||
# python itself.
|
||||
winreg.CreateKey(get_root_hkey(), root_key_name)
|
||||
|
||||
# Register the .chm help file.
|
||||
chm_file = os.path.join(lib_dir, "PyWin32.chm")
|
||||
if os.path.isfile(chm_file):
|
||||
# This isn't recursive, so if 'Help' doesn't exist, we croak
|
||||
SetPyKeyVal("Help", None, None)
|
||||
SetPyKeyVal("Help\\Pythonwin Reference", None, chm_file)
|
||||
else:
|
||||
print("NOTE: PyWin32.chm can not be located, so has not " \
|
||||
"been registered")
|
||||
|
||||
# misc other fixups.
|
||||
fixup_dbi()
|
||||
|
||||
# Register Pythonwin in context menu
|
||||
try:
|
||||
RegisterPythonwin()
|
||||
except:
|
||||
print('Failed to register pythonwin as editor')
|
||||
traceback.print_exc()
|
||||
else:
|
||||
if verbose:
|
||||
print('Pythonwin has been registered in context menu')
|
||||
|
||||
# Create the win32com\gen_py directory.
|
||||
make_dir = os.path.join(lib_dir, "win32com", "gen_py")
|
||||
if not os.path.isdir(make_dir):
|
||||
if verbose:
|
||||
print(("Creating directory %s" % (make_dir,)))
|
||||
directory_created(make_dir)
|
||||
os.mkdir(make_dir)
|
||||
|
||||
try:
|
||||
# create shortcuts
|
||||
# CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
|
||||
# will fail there if the user has no admin rights.
|
||||
fldr = get_shortcuts_folder()
|
||||
# If the group doesn't exist, then we don't make shortcuts - its
|
||||
# possible that this isn't a "normal" install.
|
||||
if os.path.isdir(fldr):
|
||||
dst = os.path.join(fldr, "PythonWin.lnk")
|
||||
create_shortcut(os.path.join(lib_dir, "Pythonwin\\Pythonwin.exe"),
|
||||
"The Pythonwin IDE", dst, "", sys.prefix)
|
||||
file_created(dst)
|
||||
if verbose:
|
||||
print("Shortcut for Pythonwin created")
|
||||
# And the docs.
|
||||
dst = os.path.join(fldr, "Python for Windows Documentation.lnk")
|
||||
doc = "Documentation for the PyWin32 extensions"
|
||||
create_shortcut(chm_file, doc, dst)
|
||||
file_created(dst)
|
||||
if verbose:
|
||||
print("Shortcut to documentation created")
|
||||
else:
|
||||
if verbose:
|
||||
print(("Can't install shortcuts - %r is not a folder" % (fldr,)))
|
||||
except Exception as details:
|
||||
print(details)
|
||||
|
||||
# importing win32com.client ensures the gen_py dir created - not strictly
|
||||
# necessary to do now, but this makes the installation "complete"
|
||||
try:
|
||||
import win32com.client
|
||||
except ImportError:
|
||||
# Don't let this error sound fatal
|
||||
pass
|
||||
print("The pywin32 extensions were successfully installed.")
|
||||
|
||||
def uninstall(lib_dir):
|
||||
# First ensure our system modules are loaded from pywin32_system, so
|
||||
# we can remove the ones we copied...
|
||||
LoadSystemModule(lib_dir, "pywintypes")
|
||||
LoadSystemModule(lib_dir, "pythoncom")
|
||||
|
||||
try:
|
||||
RegisterCOMObjects(False)
|
||||
except Exception as why:
|
||||
print(("Failed to unregister COM objects: %s" % (why,)))
|
||||
|
||||
try:
|
||||
RegisterPythonwin(False)
|
||||
except Exception as why:
|
||||
print(("Failed to unregister Pythonwin: %s" % (why,)))
|
||||
else:
|
||||
if verbose:
|
||||
print('Unregistered Pythonwin')
|
||||
|
||||
try:
|
||||
# remove gen_py directory.
|
||||
gen_dir = os.path.join(lib_dir, "win32com", "gen_py")
|
||||
if os.path.isdir(gen_dir):
|
||||
shutil.rmtree(gen_dir)
|
||||
if verbose:
|
||||
print(("Removed directory %s" % (gen_dir,)))
|
||||
|
||||
# Remove pythonwin compiled "config" files.
|
||||
pywin_dir = os.path.join(lib_dir, "Pythonwin", "pywin")
|
||||
for fname in glob.glob(os.path.join(pywin_dir, "*.cfc")):
|
||||
os.remove(fname)
|
||||
|
||||
# The dbi.pyd.old files we may have created.
|
||||
try:
|
||||
os.remove(os.path.join(lib_dir, "win32", "dbi.pyd.old"))
|
||||
except os.error:
|
||||
pass
|
||||
try:
|
||||
os.remove(os.path.join(lib_dir, "win32", "dbi_d.pyd.old"))
|
||||
except os.error:
|
||||
pass
|
||||
|
||||
except Exception as why:
|
||||
print(("Failed to remove misc files: %s" % (why,)))
|
||||
|
||||
try:
|
||||
fldr = get_shortcuts_folder()
|
||||
for link in ("PythonWin.lnk", "Python for Windows Documentation.lnk"):
|
||||
fqlink = os.path.join(fldr, link)
|
||||
if os.path.isfile(fqlink):
|
||||
os.remove(fqlink)
|
||||
if verbose:
|
||||
print(("Removed %s" % (link,)))
|
||||
except Exception as why:
|
||||
print(("Failed to remove shortcuts: %s" % (why,)))
|
||||
# Now remove the system32 files.
|
||||
files = glob.glob(os.path.join(lib_dir, "pywin32_system32\\*.*"))
|
||||
# Try the system32 directory first - if that fails due to "access denied",
|
||||
# it implies a non-admin user, and we use sys.prefix
|
||||
try:
|
||||
for dest_dir in [get_system_dir(), sys.prefix]:
|
||||
# and copy some files over there
|
||||
worked = 0
|
||||
for fname in files:
|
||||
base = os.path.basename(fname)
|
||||
dst = os.path.join(dest_dir, base)
|
||||
if os.path.isfile(dst):
|
||||
try:
|
||||
os.remove(dst)
|
||||
worked = 1
|
||||
if verbose:
|
||||
print(("Removed file %s" % (dst)))
|
||||
except Exception:
|
||||
print(("FAILED to remove %s" % (dst,)))
|
||||
if worked:
|
||||
break
|
||||
except Exception as why:
|
||||
print(("FAILED to remove system files: %s" % (why,)))
|
||||
|
||||
# NOTE: If this script is run from inside the bdist_wininst created
|
||||
# binary installer or uninstaller, the command line args are either
|
||||
# '-install' or '-remove'.
|
||||
|
||||
# Important: From inside the binary installer this script MUST NOT
|
||||
# call sys.exit() or raise SystemExit, otherwise not only this script
|
||||
# but also the installer will terminate! (Is there a way to prevent
|
||||
# this from the bdist_wininst C code?)
|
||||
|
||||
|
||||
def verify_destination(location):
|
||||
if not os.path.isdir(location):
|
||||
raise argparse.ArgumentTypeError("Path \"{}\" does not exist!".format(location))
|
||||
return location
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
description="""A post-install script for the pywin32 extensions.
|
||||
|
||||
* Typical usage:
|
||||
|
||||
> python pywin32_postinstall.py -install
|
||||
|
||||
If you installed pywin32 via a .exe installer, this should be run
|
||||
automatically after installation, but if it fails you can run it again.
|
||||
|
||||
If you installed pywin32 via PIP, you almost certainly need to run this to
|
||||
setup the environment correctly.
|
||||
|
||||
Execute with script with a '-install' parameter, to ensure the environment
|
||||
is setup correctly.
|
||||
""")
|
||||
parser.add_argument("-install",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Configure the Python environment correctly for pywin32.")
|
||||
parser.add_argument("-remove",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Try and remove everything that was installed or copied.")
|
||||
parser.add_argument("-wait",
|
||||
type=int,
|
||||
help="Wait for the specified process to terminate before starting.")
|
||||
parser.add_argument("-silent",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Don't display the \"Abort/Retry/Ignore\" dialog for files in use.")
|
||||
parser.add_argument("-quiet",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Don't display progress messages.")
|
||||
parser.add_argument("-destination",
|
||||
default=distutils.sysconfig.get_python_lib(plat_specific=1),
|
||||
type=verify_destination,
|
||||
help="Location of the PyWin32 installation")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.quiet:
|
||||
print(("Parsed arguments are: {}".format(args)))
|
||||
|
||||
if not args.install ^ args.remove:
|
||||
parser.error("You need to either choose to -install or -remove!")
|
||||
|
||||
if args.wait is not None:
|
||||
try:
|
||||
os.waitpid(args.wait, 0)
|
||||
except AttributeError:
|
||||
# Python 2.2 - no waitpid - just sleep.
|
||||
time.sleep(3)
|
||||
except os.error:
|
||||
# child already dead
|
||||
pass
|
||||
|
||||
silent = args.silent
|
||||
verbose = not args.quiet
|
||||
|
||||
if args.install:
|
||||
install(args.destination)
|
||||
|
||||
if args.remove:
|
||||
if not is_bdist_wininst:
|
||||
uninstall(args.destination)
|
75
venv/Scripts/pywin32_testall.py
Normal file
75
venv/Scripts/pywin32_testall.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
"""A test runner for pywin32"""
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os
|
||||
import site
|
||||
import subprocess
|
||||
|
||||
# locate the dirs based on where this script is - it may be either in the
|
||||
# source tree, or in an installed Python 'Scripts' tree.
|
||||
this_dir = os.path.dirname(__file__)
|
||||
site_packages = [site.getusersitepackages(), ] + site.getsitepackages()
|
||||
|
||||
# Run a test using subprocess and wait for the result.
|
||||
# If we get an returncode != 0, we know that there was an error.
|
||||
def run_test(script, cmdline_rest=""):
|
||||
dirname, scriptname = os.path.split(script)
|
||||
# some tests prefer to be run from their directory.
|
||||
cmd = [sys.executable, "-u", scriptname] + cmdline_rest.split()
|
||||
print(script)
|
||||
popen = subprocess.Popen(cmd, shell=True, cwd=dirname,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
data = popen.communicate()[0]
|
||||
if sys.version_info > (3,):
|
||||
sys.stdout.write(data.decode('latin-1'))
|
||||
else:
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.flush()
|
||||
if popen.returncode:
|
||||
print("****** %s failed: %s" % (script, popen.returncode))
|
||||
sys.exit(popen.returncode)
|
||||
|
||||
|
||||
def find_and_run(possible_locations, script, cmdline_rest=""):
|
||||
for maybe in possible_locations:
|
||||
if os.path.isfile(os.path.join(maybe, script)):
|
||||
run_test(os.path.abspath(os.path.join(maybe, script)), cmdline_rest)
|
||||
break
|
||||
else:
|
||||
raise RuntimeError("Failed to locate the test script '%s' in one of %s"
|
||||
% (script, possible_locations))
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
||||
code_directories = [this_dir] + site_packages
|
||||
|
||||
parser = argparse.ArgumentParser(description="A script to trigger tests in all subprojects of PyWin32.")
|
||||
parser.add_argument("-no-user-interaction",
|
||||
default=False,
|
||||
action='store_true',
|
||||
help="Run all tests without user interaction")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# win32
|
||||
maybes = [os.path.join(directory, "win32", "test") for directory in code_directories]
|
||||
command = ('testall.py', )
|
||||
if args.no_user_interaction:
|
||||
command += ("-no-user-interaction", )
|
||||
find_and_run(maybes, *command)
|
||||
|
||||
# win32com
|
||||
maybes = [os.path.join(directory, "win32com", "test") for directory in [os.path.join(this_dir, "com"), ] + site_packages]
|
||||
find_and_run(maybes, 'testall.py', "2")
|
||||
|
||||
# adodbapi
|
||||
maybes = [os.path.join(directory, "adodbapi", "test") for directory in code_directories]
|
||||
find_and_run(maybes, 'adodbapitest.py')
|
||||
# This script has a hard-coded sql server name in it, (and markh typically
|
||||
# doesn't have a different server to test on) but there is now supposed to be a server out there on the Internet
|
||||
# just to run these tests, so try it...
|
||||
find_and_run(maybes, 'test_adodbapi_dbapi20.py')
|
||||
|
||||
if sys.version_info > (3,):
|
||||
print("** The tests have some issues on py3k - not all failures are a problem...")
|
Loading…
Add table
Add a link
Reference in a new issue