[pywin32-checkins] pywin32 setup3.py, NONE, 1.1.2.1 setup.py, 1.81.2.2, 1.81.2.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-10-01 13:08:27
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29050 Modified Files: Tag: py3k setup.py Added Files: Tag: py3k setup3.py Log Message: revert setup.py to a 2.x compatible syntax, add setup3.py and support for automatically doing 2to3 conversion on the fly for py3k. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.81.2.2 retrieving revision 1.81.2.3 diff -C2 -d -r1.81.2.2 -r1.81.2.3 *** setup.py 17 Sep 2008 03:47:32 -0000 1.81.2.2 --- setup.py 1 Oct 2008 13:08:17 -0000 1.81.2.3 *************** *** 71,75 **** import types, glob import re ! import winreg --- 71,75 ---- import types, glob import re ! import _winreg *************** *** 81,84 **** --- 81,87 ---- from distutils.command.build import build from distutils.command.install_data import install_data + from distutils.command.build_py import build_py + from distutils.command.build_scripts import build_scripts + try: from distutils.command.bdist_msi import bdist_msi *************** *** 98,104 **** class Log: def debug(self, msg, *args): ! print (msg % args) def info(self, msg, *args): ! print (msg % args) log = Log() --- 101,107 ---- class Log: def debug(self, msg, *args): ! print msg % args def info(self, msg, *args): ! print msg % args log = Log() *************** *** 116,120 **** pywin32_version="%d.%d.%s" % (sys.version_info[0], sys.version_info[1], build_id_patch) ! print ("Building pywin32", pywin32_version) try: --- 119,123 ---- pywin32_version="%d.%d.%s" % (sys.version_info[0], sys.version_info[1], build_id_patch) ! print "Building pywin32", pywin32_version try: *************** *** 139,142 **** --- 142,146 ---- # landmark. DEBUG = False # can't use log.debug - not setup yet + HKLM = _winreg.HKEY_LOCAL_MACHINE # ack - 2to3 error - see http://bugs.python.org/issue3994 landmark = "include\\windows.h" # 1. The use might have their current environment setup for the *************** *** 145,149 **** if sdkdir: if DEBUG: ! print ("PSDK: try %MSSdk%: '%s'" % sdkdir) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir --- 149,153 ---- if sdkdir: if DEBUG: ! print "PSDK: try %MSSdk%: '%s'" % sdkdir if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir *************** *** 153,165 **** # the "Platform SDK for Windows Server 2003 SP1" this is dead end. try: ! key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\MicrosoftSDK\Directories") ! sdkdir, ignore = winreg.QueryValueEx(key, "Install Dir") except EnvironmentError: pass else: if DEBUG: ! print (r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\ ! "\Directories\Install Dir': '%s'" % sdkdir) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir --- 157,169 ---- # the "Platform SDK for Windows Server 2003 SP1" this is dead end. try: ! key = _winreg.OpenKey(HKLM, r"Software\Microsoft\MicrosoftSDK\Directories") ! sdkdir, ignore = _winreg.QueryValueEx(key, "Install Dir") except EnvironmentError: pass else: if DEBUG: ! print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\ ! "\Directories\Install Dir': '%s'" % sdkdir if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir *************** *** 169,187 **** # only one with an "Install Dir" sub-value. try: ! key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\MicrosoftSDK\InstalledSDKs") i = 0 while True: ! guid = winreg.EnumKey(key, i) ! guidkey = winreg.OpenKey(key, guid) try: ! sdkdir, ignore = winreg.QueryValueEx(guidkey, "Install Dir") except EnvironmentError: pass else: if DEBUG: ! print (r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\ "\InstallSDKs\%s\Install Dir': '%s'"\ ! % (guid, sdkdir)) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir --- 173,191 ---- # only one with an "Install Dir" sub-value. try: ! key = _winreg.OpenKey(HKLM, r"Software\Microsoft\MicrosoftSDK\InstalledSDKs") i = 0 while True: ! guid = _winreg.EnumKey(key, i) ! guidkey = _winreg.OpenKey(key, guid) try: ! sdkdir, ignore = _winreg.QueryValueEx(guidkey, "Install Dir") except EnvironmentError: pass else: if DEBUG: ! print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\ "\InstallSDKs\%s\Install Dir': '%s'"\ ! % (guid, sdkdir) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir *************** *** 191,203 **** # 4. Vista's SDK try: ! key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\Microsoft SDKs\Windows") ! sdkdir, ignore = winreg.QueryValueEx(key, "CurrentInstallFolder") except EnvironmentError: pass else: if DEBUG: ! print (r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDKs"\ ! "\Windows\CurrentInstallFolder': '%s'" % sdkdir) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir --- 195,207 ---- # 4. Vista's SDK try: ! key = _winreg.OpenKey(HKLM, r"Software\Microsoft\Microsoft SDKs\Windows") ! sdkdir, ignore = _winreg.QueryValueEx(key, "CurrentInstallFolder") except EnvironmentError: pass else: if DEBUG: ! print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDKs"\ ! "\Windows\CurrentInstallFolder': '%s'" % sdkdir if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir *************** *** 211,215 **** for sdkdir in defaultlocs: if DEBUG: ! print ("PSDK: try default location: '%s'" % sdkdir) if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir --- 215,219 ---- for sdkdir in defaultlocs: if DEBUG: ! print "PSDK: try default location: '%s'" % sdkdir if os.path.isfile(os.path.join(sdkdir, landmark)): return sdkdir *************** *** 245,248 **** --- 249,253 ---- depends=None, platforms=None, # none means 'all platforms' + unicode_mode=None, # 'none'==default or specifically true/false. ): assert dsp_file or sources, "Either dsp_file or sources must be specified" *************** *** 282,285 **** --- 287,291 ---- export_symbols) self.depends = depends or [] # stash it here, as py22 doesn't have it. + self.unicode_mode = unicode_mode def parse_def_file(self, path): *************** *** 381,384 **** --- 387,399 ---- if found_mfc: break + # Handle Unicode - if unicode_mode is None, then it means True + # for py3k, false for py2 + unicode_mode = self.unicode_mode + if unicode_mode is None: + unicode_mode = sys.version_info > (3,) + if unicode_mode: + self.extra_compile_args.append("/DUNICODE") + self.extra_compile_args.append("/D_UNICODE") + self.extra_compile_args.append("/DWINNT") class WinExt_pythonwin(WinExt): *************** *** 386,389 **** --- 401,406 ---- if "dsp_file" not in kw and not kw.get("sources"): kw["dsp_file"] = "pythonwin/" + name + ".dsp" + if 'unicode_mode' not in kw: + kw['unicode_mode']=False kw.setdefault("extra_compile_args", []).extend( ['-D_AFXDLL', '-D_AFXEXT','-D_MBCS']) *************** *** 431,439 **** libs = kw.get("libraries", "") keyname = "SOFTWARE\Microsoft\Exchange\SDK" ! for root in winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER: try: ! keyob = winreg.OpenKey(root, keyname) ! value, type_id = winreg.QueryValueEx(keyob, "INSTALLDIR") ! if type_id == winreg.REG_SZ: sdk_install_dir = value break --- 448,456 ---- libs = kw.get("libraries", "") keyname = "SOFTWARE\Microsoft\Exchange\SDK" ! for root in _winreg.HKEY_LOCAL_MACHINE, _winreg.HKEY_CURRENT_USER: try: ! keyob = _winreg.OpenKey(root, keyname) ! value, type_id = _winreg.QueryValueEx(keyob, "INSTALLDIR") ! if type_id == _winreg.REG_SZ: sdk_install_dir = value break *************** *** 464,467 **** --- 481,554 ---- ################################################################ + # Extensions to the distutils commands. + + # Start with 2to3 related stuff for py3k. + is_py3k = sys.version_info > (3,) + if is_py3k: + def refactor_filenames(filenames): + from lib2to3.refactor import RefactoringTool, get_fixers_from_package + fixers = get_fixers_from_package('lib2to3.fixes') + options = dict(doctests_only=False, fix=[], list_fixes=[], + print_function=False, verbose=False, + write=True) + r = RefactoringTool(fixers, options) + for updated_file in filenames: + if os.path.splitext(updated_file)[1] not in ['.py', '.pys']: + continue + log.info("Refactoring %s" % updated_file) + try: + r.refactor_file(updated_file, write=True, doctests_only=False) + if os.path.exists(updated_file + ".bak"): + os.unlink(updated_file + ".bak") + except Exception: + log.warn("WARNING: Failed to 2to3 %s: %s" % (updated_file, sys.exc_info()[1])) + else: + # py2k - nothing to do. + def refactor_filenames(filenames): + pass + + # 'build_py' command + if is_py3k: + # Force 2to3 to be run for py3k versions. + class my_build_py(build_py): + def run(self): + self.updated_files = [] + + # Base class code + if self.py_modules: + self.build_modules() + if self.packages: + self.build_packages() + self.build_package_data() + + # 2to3 + refactor_filenames(self.updated_files) + + # Remaining base class code + self.byte_compile(self.get_outputs(include_bytecode=0)) + + def build_module(self, module, module_file, package): + res = build_py.build_module(self, module, module_file, package) + if res[1]: + # file was copied + self.updated_files.append(res[0]) + return res + else: + my_build_py = build_py # default version. + + # 'build_scripts' command + if is_py3k: + class my_build_scripts(build_scripts): + def copy_file(self, src, dest): + dest, copied = build_scripts.copy_file(self, src, dest) + # 2to3 + if not self.dry_run and copied: + refactor_filenames([dest]) + return dest, copied + + else: + my_build_scripts = build_scripts + + # 'build' command class my_build(build): def run(self): *************** *** 473,478 **** f.write("%s\n" % build_id) f.close() ! except EnvironmentError as why: ! print ("Failed to open '%s': %s" % (ver_fname, why)) class my_build_ext(build_ext): --- 560,565 ---- f.write("%s\n" % build_id) f.close() ! except EnvironmentError, why: ! print "Failed to open '%s': %s" % (ver_fname, why) class my_build_ext(build_ext): *************** *** 627,631 **** else: raise RuntimeError("Can't find a version in Windows.h") ! if ext.windows_h_version > self.windows_h_version: return "WINDOWS.H with version 0x%x is required, but only " \ "version 0x%x is installed." \ --- 714,719 ---- else: raise RuntimeError("Can't find a version in Windows.h") ! if ext.windows_h_version is not None and \ ! ext.windows_h_version > self.windows_h_version: return "WINDOWS.H with version 0x%x is required, but only " \ "version 0x%x is installed." \ *************** *** 645,649 **** patched_libs = [] for lib in ext.libraries: ! if self.found_libraries.has_key(lib.lower()): found = self.found_libraries[lib.lower()] else: --- 733,737 ---- patched_libs = [] for lib in ext.libraries: ! if lib.lower() in self.found_libraries: found = self.found_libraries[lib.lower()] else: *************** *** 745,749 **** self.excluded_extensions.append((ext, why)) assert why, "please give a reason, or None" ! print ("Skipping %s: %s" % (ext.name, why)) continue --- 833,837 ---- self.excluded_extensions.append((ext, why)) assert why, "please give a reason, or None" ! print "Skipping %s: %s" % (ext.name, why) continue *************** *** 787,791 **** # On a 64bit host, the value we are looking for is actually in # SysWow64Node - but that is only available on xp and later. ! access = winreg.KEY_READ if sys.getwindowsversion()[0] >= 5: access = access | 512 # KEY_WOW64_32KEY --- 875,879 ---- # On a 64bit host, the value we are looking for is actually in # SysWow64Node - but that is only available on xp and later. ! access = _winreg.KEY_READ if sys.getwindowsversion()[0] >= 5: access = access | 512 # KEY_WOW64_32KEY *************** *** 795,802 **** plat_dir = "x86" # Find the redist directory. ! vckey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC", ! access) ! val, val_typ = winreg.QueryValueEx(vckey, "ProductDir") mfc_dir = os.path.join(val, "redist", plat_dir, "Microsoft.VC90.MFC") if not os.path.isdir(mfc_dir): --- 883,891 ---- plat_dir = "x86" # Find the redist directory. ! HKLM = _winreg.HKEY_LOCAL_MACHINE ! vckey = _winreg.OpenKey(HKLM, r"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC", ! 0, access) ! val, val_typ = _winreg.QueryValueEx(vckey, "ProductDir") mfc_dir = os.path.join(val, "redist", plat_dir, "Microsoft.VC90.MFC") if not os.path.isdir(mfc_dir): *************** *** 806,817 **** self.copy_file( os.path.join(mfc_dir, f), target_dir) ! except (EnvironmentError, RuntimeError) as exc: ! print ("Can't find an installed VC for the MFC DLLs:", exc) def build_exefile(self, ext): - from types import ListType, TupleType sources = ext.sources ! if sources is None or type(sources) not in (ListType, TupleType): raise DistutilsSetupError( ("in 'ext_modules' option (extension '%s'), " + --- 895,905 ---- self.copy_file( os.path.join(mfc_dir, f), target_dir) ! except (EnvironmentError, RuntimeError), exc: ! print "Can't find an installed VC for the MFC DLLs:", exc def build_exefile(self, ext): sources = ext.sources ! if sources is None or type(sources) not in (list, tuple): raise DistutilsSetupError( ("in 'ext_modules' option (extension '%s'), " + *************** *** 934,938 **** self.excluded_extensions.append((ext, why)) assert why, "please give a reason, or None" ! print ("Skipping %s: %s" % (ext.name, why)) return self.current_extension = ext --- 1022,1026 ---- self.excluded_extensions.append((ext, why)) assert why, "please give a reason, or None" ! print "Skipping %s: %s" % (ext.name, why) return self.current_extension = ext *************** *** 1003,1009 **** def find_swig (self): ! # We know where swig is ! os.environ["SWIG_LIB"] = os.path.abspath(r"swig\swig_lib") ! return os.path.abspath(r"swig\swig.exe") def swig_sources (self, sources, ext=None): --- 1091,1102 ---- def find_swig (self): ! if "SWIG" in os.environ: ! swig = os.environ["SWIG"] ! else: ! # We know where our swig is ! swig = os.path.abspath(r"swig\swig.exe") ! lib = os.path.join(os.path.dirname(swig), "swig_lib") ! os.environ["SWIG_LIB"] = lib ! return swig def swig_sources (self, sources, ext=None): *************** *** 1112,1120 **** # installer if not self.dry_run and not self.skip_build and not self.root: ! # What executable to use? This one I guess. ! filename = os.path.join(os.path.dirname(this_file), "pywin32_postinstall.py") if not os.path.isfile(filename): raise RuntimeError("Can't find '%s'" % (filename,)) ! print ("Executing post install script...") os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, filename, --- 1205,1215 ---- # installer if not self.dry_run and not self.skip_build and not self.root: ! # We must run the script we just installed into Scripts, as it ! # may have had 2to3 run over it. ! filename = os.path.join(sys.prefix, "Scripts", "pywin32_postinstall.py") if not os.path.isfile(filename): raise RuntimeError("Can't find '%s'" % (filename,)) ! print "Executing post install script..." ! # What executable to use? This one I guess. os.spawnl(os.P_NOWAIT, sys.executable, sys.executable, filename, *************** *** 1213,1217 **** try: self.spawn(args) ! except DistutilsExecError as msg: log.info("VersionStamp failed: %s", msg) ok = False --- 1308,1312 ---- try: self.spawn(args) ! except DistutilsExecError, msg: log.info("VersionStamp failed: %s", msg) ok = False *************** *** 1253,1259 **** installobj = self.distribution.get_command_obj('install') self.install_dir = installobj.install_lib ! print ('Installing data files to %s' % self.install_dir) install_data.finalize_options(self) ################################################################ --- 1348,1361 ---- installobj = self.distribution.get_command_obj('install') self.install_dir = installobj.install_lib ! print 'Installing data files to %s' % self.install_dir install_data.finalize_options(self) + def copy_file(self, src, dest): + dest, copied = build_scripts.copy_file(self, src, dest) + # 2to3 + if not self.dry_run and copied: + refactor_filenames([dest]) + return dest, copied + ################################################################ *************** *** 1270,1274 **** WinExt_win32("perfmondata", libraries="advapi32", ! extra_compile_args=["-DUNICODE", "-D_UNICODE", "-DWINNT"], export_symbol_file = "win32/src/PerfMon/perfmondata.def", is_regular_dll = 1, --- 1372,1376 ---- WinExt_win32("perfmondata", libraries="advapi32", ! unicode_mode=True, export_symbol_file = "win32/src/PerfMon/perfmondata.def", is_regular_dll = 1, *************** *** 1277,1295 **** for info in ( ! ("mmapfile", "", True), ! ("odbc", "odbc32 odbccp32", True), ("perfmon", "", True), ! ("timer", "user32", True), ! ("win2kras", "rasapi32", True, 0x0500), ! ("win32api", "user32 advapi32 shell32 version", True, 0x0500, 'win32/src/win32apimodule.cpp win32/src/win32api_display.cpp'), ("win32cred", "AdvAPI32 credui", True, 0x0501, 'win32/src/win32credmodule.cpp'), ! ("win32crypt", "Crypt32", True, 0x0500, 'win32/src/win32crypt.i win32/src/win32cryptmodule.cpp'), ! ("win32file", "oleaut32", True, 0x0500), ! ("win32event", "user32", True), ! ("win32clipboard", "gdi32 user32 shell32", True), ! ("win32evtlog", "advapi32 oleaut32", True), # win32gui handled below ! ("win32job", "user32", True, 0x0500, 'win32/src/win32job.i win32/src/win32jobmodule.cpp'), ! ("win32lz", "lz32", True), ("win32net", "netapi32 advapi32", True, None, """ win32/src/win32net/win32netfile.cpp win32/src/win32net/win32netgroup.cpp --- 1379,1397 ---- for info in ( ! ("mmapfile", "", None), ! ("odbc", "odbc32 odbccp32", None), ("perfmon", "", True), ! ("timer", "user32", None), ! ("win2kras", "rasapi32", None, 0x0500), ! ("win32api", "user32 advapi32 shell32 version", None, 0x0500, 'win32/src/win32apimodule.cpp win32/src/win32api_display.cpp'), ("win32cred", "AdvAPI32 credui", True, 0x0501, 'win32/src/win32credmodule.cpp'), ! ("win32crypt", "Crypt32", None, 0x0500, 'win32/src/win32crypt.i win32/src/win32cryptmodule.cpp'), ! ("win32file", "oleaut32", None, 0x0500), ! ("win32event", "user32", None), ! ("win32clipboard", "gdi32 user32 shell32", None), ! ("win32evtlog", "advapi32 oleaut32", None), # win32gui handled below ! ("win32job", "user32", None, 0x0500, 'win32/src/win32job.i win32/src/win32jobmodule.cpp'), ! ("win32lz", "lz32", None), ("win32net", "netapi32 advapi32", True, None, """ win32/src/win32net/win32netfile.cpp win32/src/win32net/win32netgroup.cpp *************** *** 1298,1307 **** win32/src/win32net/win32netuser.cpp """), ! ("win32pdh", "", True), ! ("win32pipe", "", True), ! ("win32print", "winspool user32 gdi32", True, 0x0500), ! ("win32process", "advapi32 user32", True, 0x0500), ("win32profile", "Userenv", True, None, 'win32/src/win32profilemodule.cpp'), ! ("win32ras", "rasapi32 user32", True), ("win32security", "advapi32 user32 netapi32", True, 0x0500, """ win32/src/win32security.i win32/src/win32securitymodule.cpp --- 1400,1409 ---- win32/src/win32net/win32netuser.cpp """), ! ("win32pdh", "", None), ! ("win32pipe", "", None), ! ("win32print", "winspool user32 gdi32", None, 0x0500), ! ("win32process", "advapi32 user32", None, 0x0500), ("win32profile", "Userenv", True, None, 'win32/src/win32profilemodule.cpp'), ! ("win32ras", "rasapi32 user32", None), ("win32security", "advapi32 user32 netapi32", True, 0x0500, """ win32/src/win32security.i win32/src/win32securitymodule.cpp *************** *** 1309,1315 **** """), ("win32service", "advapi32 oleaut32 user32", True, 0x0501), ! ("win32trace", "advapi32", True), ! ("win32wnet", "netapi32 mpr", True), ! ("win32inet", "wininet", True, 0x500, """ win32/src/win32inet.i win32/src/win32inetmodule.cpp win32/src/win32inet_winhttp.cpp""" --- 1411,1417 ---- """), ("win32service", "advapi32 oleaut32 user32", True, 0x0501), ! ("win32trace", "advapi32", None), ! ("win32wnet", "netapi32 mpr", None), ! ("win32inet", "wininet", None, 0x500, """ win32/src/win32inet.i win32/src/win32inetmodule.cpp win32/src/win32inet_winhttp.cpp""" *************** *** 1317,1326 **** ("win32console", "kernel32", True, 0x0501, "win32/src/win32consolemodule.cpp"), ("win32ts", "WtsApi32", True, 0x0501, "win32/src/win32tsmodule.cpp"), ! ("_win32sysloader", "", True, 0x0501, "win32/src/_win32sysloader.cpp"), ("win32transaction", "kernel32", True, 0x0501, "win32/src/win32transactionmodule.cpp"), ): ! name, lib_names, is_unicode = info[:3] windows_h_ver = sources = None if len(info)>3: --- 1419,1430 ---- ("win32console", "kernel32", True, 0x0501, "win32/src/win32consolemodule.cpp"), ("win32ts", "WtsApi32", True, 0x0501, "win32/src/win32tsmodule.cpp"), ! ("_win32sysloader", "", None, 0x0501, "win32/src/_win32sysloader.cpp"), ("win32transaction", "kernel32", True, 0x0501, "win32/src/win32transactionmodule.cpp"), ): ! name, lib_names, unicode_mode = info[:3] ! # unicode_mode == None means "not on py2.6, yes on py3", True means everywhere ! # False means nowhere. windows_h_ver = sources = None if len(info)>3: *************** *** 1329,1339 **** sources = info[4].split() extra_compile_args = [] - if is_unicode: - extra_compile_args = ['-DUNICODE', '-D_UNICODE', '-DWINNT'] ext = WinExt_win32(name, libraries=lib_names, extra_compile_args = extra_compile_args, windows_h_version = windows_h_ver, ! sources = sources) win32_extensions.append(ext) --- 1433,1442 ---- sources = info[4].split() extra_compile_args = [] ext = WinExt_win32(name, libraries=lib_names, extra_compile_args = extra_compile_args, windows_h_version = windows_h_ver, ! sources = sources, ! unicode_mode = unicode_mode) win32_extensions.append(ext) *************** *** 1348,1352 **** libraries="gdi32 user32 comdlg32 comctl32 shell32", define_macros = [("WIN32GUI", None)], - extra_compile_args = ['-DUNICODE', '-D_UNICODE'] ), # winxpgui is built from win32gui.i, but sets up different #defines before --- 1451,1454 ---- *************** *** 1361,1365 **** define_macros = [("WIN32GUI",None), ("WINXPGUI",None)], extra_swig_commands=["-DWINXPGUI"], - extra_compile_args = ['-DUNICODE', '-D_UNICODE'] ), # winxptheme --- 1463,1466 ---- *************** *** 1368,1381 **** libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", windows_h_version=0x0500, - extra_compile_args = ['-DUNICODE', '-D_UNICODE', '-DWINNT'], ), ] win32_extensions += [ WinExt_win32('servicemanager', ! extra_compile_args = ['-DUNICODE', '-D_UNICODE', ! '-DWINNT', '-DPYSERVICE_BUILD_DLL'], libraries = "user32 ole32 advapi32 shell32", dsp_file = r"win32\Pythonservice servicemanager.dsp", ! windows_h_version = 0x500), ] --- 1469,1481 ---- libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", windows_h_version=0x0500, ), ] win32_extensions += [ WinExt_win32('servicemanager', ! extra_compile_args = ['-DPYSERVICE_BUILD_DLL'], libraries = "user32 ole32 advapi32 shell32", dsp_file = r"win32\Pythonservice servicemanager.dsp", ! windows_h_version = 0x500, ! unicode_mode=True,), ] *************** *** 1623,1627 **** WinExt_win32("pythonservice", dsp_file = "win32/PythonService EXE.dsp", ! extra_compile_args = ['-DUNICODE', '-D_UNICODE', '-DWINNT'], extra_link_args=["/SUBSYSTEM:CONSOLE"], libraries = "user32 advapi32 ole32 shell32"), --- 1723,1727 ---- WinExt_win32("pythonservice", dsp_file = "win32/PythonService EXE.dsp", ! unicode_mode = True, extra_link_args=["/SUBSYSTEM:CONSOLE"], libraries = "user32 advapi32 ole32 shell32"), *************** *** 1719,1723 **** try: temp = convert_data_files([file]) ! except RuntimeError as details: if not str(details.args[0]).startswith("No file"): raise --- 1819,1823 ---- try: temp = convert_data_files([file]) ! except RuntimeError, details: if not str(details.args[0]).startswith("No file"): raise *************** *** 1730,1735 **** if len(sys.argv)==1: # distutils will print usage - print our docstring first. ! print (__doc__) ! print ("Standard usage information follows:") packages=['win32com', --- 1830,1835 ---- if len(sys.argv)==1: # distutils will print usage - print our docstring first. ! print __doc__ ! print "Standard usage information follows:" packages=['win32com', *************** *** 1786,1789 **** --- 1886,1896 ---- other_extensions + if sys.version_info > (3,): + py3k_skip_modules = \ + """odbc win32evtlog win32print win32security win32inet adsi internet + mapi shell bits ifilter isapi PyISAPI_loader + """.split() + ext_modules = [e for e in ext_modules if e.name not in py3k_skip_modules] + # Build a map of DLL base addresses. According to Python's PC\dllbase_nt.txt, # we start at 0x1e200000 and go up in 0x00020000 increments. A couple of *************** *** 1799,1808 **** dll_base_address += 0x30000 cmdclass = { 'install': my_install, 'build': my_build, 'build_ext': my_build_ext, 'install_data': my_install_data, } ! dist = setup(name="pywin32", version=str(build_id), --- 1906,1918 ---- dll_base_address += 0x30000 + cmdclass = { 'install': my_install, 'build': my_build, 'build_ext': my_build_ext, 'install_data': my_install_data, + 'build_py' : my_build_py, + 'build_scripts' : my_build_scripts, } ! dist = setup(name="pywin32", version=str(build_id), *************** *** 1896,1912 **** # If we did any extension building, and report if we skipped any. ! if dist.command_obj.has_key('build_ext'): what_string = "built" ! if dist.command_obj.has_key('install'): # just to be purdy what_string += "/installed" # Print the list of extension modules we skipped building. ! if dist.command_obj.has_key('build_ext'): excluded_extensions = dist.command_obj['build_ext'].excluded_extensions if excluded_extensions: ! print ("*** NOTE: The following extensions were NOT %s:" % what_string) for ext, why in excluded_extensions: ! print (" %s: %s" % (ext.name, why)) ! print ("For more details on installing the correct libraries and headers,") ! print ("please execute this script with no arguments (or see the docstring)") else: ! print ("All extension modules %s OK" % (what_string,)) --- 2006,2022 ---- # If we did any extension building, and report if we skipped any. ! if 'build_ext' in dist.command_obj: what_string = "built" ! if 'install' in dist.command_obj: # just to be purdy what_string += "/installed" # Print the list of extension modules we skipped building. ! if 'build_ext' in dist.command_obj: excluded_extensions = dist.command_obj['build_ext'].excluded_extensions if excluded_extensions: ! print "*** NOTE: The following extensions were NOT %s:" % what_string for ext, why in excluded_extensions: ! print " %s: %s" % (ext.name, why) ! print "For more details on installing the correct libraries and headers," ! print "please execute this script with no arguments (or see the docstring)" else: ! print "All extension modules %s OK" % (what_string,) --- NEW FILE: setup3.py --- # This is a Python 3.x script to build pywin32. It converts then executes # the regular setup.py script. import os from lib2to3.refactor import RefactoringTool, get_fixers_from_package fixers = get_fixers_from_package('lib2to3.fixes') options = dict(doctests_only=False, fix=[], list_fixes=[], print_function=False, verbose=False, write=True) r = RefactoringTool(fixers, options) script = os.path.join(os.path.dirname(__file__), "setup.py") data = open(script).read() print("Converting...") got = r.refactor_string(data, "setup.py") print("Executing...") exec(str(got)) |