[pywin32-checkins] pywin32 setup.py,1.57,1.58
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2007-05-24 06:01:35
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23340 Modified Files: setup.py Log Message: Another pass at getting things working on x64. This change incorporates most of Sidnei's work on the AMD64 branch, and updates most of the other win32 and win32com modules that haven't already had 64bit love from Roger (thanks guys!). Note this is not complete - among the outstanding issues are fixing 's#' format strings (but most of the tests *do* pass on x64, and the ones which don't fail for 'vista environment' reasons rather than x64 reasons) Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** setup.py 25 Apr 2007 03:24:23 -0000 1.57 --- setup.py 24 May 2007 06:01:04 -0000 1.58 *************** *** 46,49 **** --- 46,54 ---- or to build and install a debug version: python setup.py -q build --debug install + + To build 64bit versions of this, you must manually setup your compiler and SDK environment + variables, then set the environment variables 'DISTUTILS_USE_SDK' and 'MSSdk' to any value + before running setup. This will prevent distutils trying to sniff out the correct directories, which + it generally fails to do these days... """ # Originally by Thomas Heller, started in 2000 or so. *************** *** 59,62 **** --- 64,76 ---- from distutils.filelist import FileList from distutils.errors import DistutilsExecError + try: + from distutils.msvccompiler import get_build_architecture + except ImportError: + def get_build_architecture(): + return "Intel" + + ARCHITECTURES_64 = ("Itanium", "AMD64") + is_64bit = get_build_architecture() in ARCHITECTURES_64 + is_32bit = not is_64bit import types, glob *************** *** 160,164 **** except EnvironmentError: pass ! # 4. Failing this just try a few well-known default install locations. progfiles = os.environ.get("ProgramFiles", r"C:\Program Files") defaultlocs = [ --- 174,192 ---- except EnvironmentError: pass ! # 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 ! ! # 5. Failing this just try a few well-known default install locations. progfiles = os.environ.get("ProgramFiles", r"C:\Program Files") defaultlocs = [ *************** *** 215,219 **** sources.extend(self.get_source_files(dsp_file)) extra_link_args = extra_link_args or [] ! extra_link_args.append("/MACHINE:ix86") # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. --- 243,250 ---- sources.extend(self.get_source_files(dsp_file)) extra_link_args = extra_link_args or [] ! if is_64bit: ! extra_link_args.append("/MACHINE:%s" % get_build_architecture()) ! else: ! extra_link_args.append("/MACHINE:ix86") # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. *************** *** 388,391 **** --- 419,426 ---- self.include_dirs.insert(0, extra) extra = os.path.join(sdk_dir, 'lib') + assert os.path.isdir(extra) + if is_64bit: + extra = os.path.join(extra, 'x64') + assert os.path.isdir(extra), extra if extra not in self.library_dirs and os.path.isdir(extra): self.library_dirs.insert(0, extra) *************** *** 424,428 **** break 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 " \ --- 459,468 ---- break else: ! if is_64bit: ! # *sob* ! print "x64 build - assuming winver == 0x600" ! self.windows_h_version = 0x600 ! 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 " \ *************** *** 435,439 **** # module method in early Python versions get_msvc_paths = msvccompiler.get_msvc_paths ! look_dirs = self.include_dirs + get_msvc_paths("include") for h in ext.optional_headers: for d in look_dirs: --- 475,481 ---- # module method in early Python versions get_msvc_paths = msvccompiler.get_msvc_paths ! look_dirs = self.include_dirs ! if is_32bit: # don't sniff MSVC paths on x64 ! get_msvc_paths("include") for h in ext.optional_headers: for d in look_dirs: *************** *** 465,502 **** return None # no reason - it can be built! ! def build_extensions(self): ! # Is there a better way than this? ! # Just one GUIDS.CPP and it gives trouble on mainwin too ! # Maybe I should just rename the file, but a case-only rename is likely to be ! # worse! ! if ".CPP" not in self.compiler.src_extensions: ! self.compiler._cpp_extensions.append(".CPP") ! self.compiler.src_extensions.append(".CPP") ! ! # First, sanity-check the 'extensions' list ! self.check_extensions_list(self.extensions) ! ! self.found_libraries = {} ! ! # Here we hack a "pywin32" directory (one of 'win32', 'win32com', ! # 'pythonwin' etc), as distutils doesn't seem to like the concept ! # of multiple top-level directories. ! assert self.package is None ! for ext in self.extensions: ! try: ! self.package = ext.get_pywin32_dir() ! except AttributeError: ! raise RuntimeError, "Not a win32 package!" ! self.build_extension(ext) ! ! for ext in W32_exe_files: ! try: ! self.package = ext.get_pywin32_dir() ! except AttributeError: ! raise RuntimeError, "Not a win32 package!" ! self.build_exefile(ext) ! ! # Not sure how to make this completely generic, and there is no ! # need at this stage. path = 'pythonwin\\Scintilla' makefile = 'makefile_pythonwin' --- 507,511 ---- return None # no reason - it can be built! ! def _build_scintilla(self): path = 'pythonwin\\Scintilla' makefile = 'makefile_pythonwin' *************** *** 540,543 **** --- 549,588 ---- os.path.join(self.build_lib, "pythonwin")) + def build_extensions(self): + # Is there a better way than this? + # Just one GUIDS.CPP and it gives trouble on mainwin too + # Maybe I should just rename the file, but a case-only rename is likely to be + # worse! + if ".CPP" not in self.compiler.src_extensions: + self.compiler._cpp_extensions.append(".CPP") + self.compiler.src_extensions.append(".CPP") + + # First, sanity-check the 'extensions' list + self.check_extensions_list(self.extensions) + + self.found_libraries = {} + + # Here we hack a "pywin32" directory (one of 'win32', 'win32com', + # 'pythonwin' etc), as distutils doesn't seem to like the concept + # of multiple top-level directories. + assert self.package is None + for ext in self.extensions: + try: + self.package = ext.get_pywin32_dir() + except AttributeError: + raise RuntimeError, "Not a win32 package!" + self.build_extension(ext) + + for ext in W32_exe_files: + try: + self.package = ext.get_pywin32_dir() + except AttributeError: + raise RuntimeError, "Not a win32 package!" + self.build_exefile(ext) + + # Not sure how to make this completely generic, and there is no + # need at this stage. + if is_32bit: + self._build_scintilla() # Copy cpp lib files needed to create Python COM extensions clib_files = (['win32', 'pywintypes%s.lib'], *************** *** 679,682 **** --- 724,729 ---- if why is not None: self.excluded_extensions.append((ext, why)) + assert why, "please give a reason, or None" + print "Skipping", ext.name, why return self.current_extension = ext *************** *** 684,688 **** if not self.mingw32 and ext.pch_header: ext.extra_compile_args = ext.extra_compile_args or [] ! ext.extra_compile_args.append("/YX"+ext.pch_header) pch_name = os.path.join(self.build_temp, ext.name) + ".pch" ext.extra_compile_args.append("/Fp"+pch_name) --- 731,736 ---- if not self.mingw32 and ext.pch_header: ext.extra_compile_args = ext.extra_compile_args or [] ! if is_32bit: ! ext.extra_compile_args.append("/YX"+ext.pch_header) pch_name = os.path.join(self.build_temp, ext.name) + ".pch" ext.extra_compile_args.append("/Fp"+pch_name) *************** *** 1113,1116 **** --- 1161,1166 ---- extra_compile_args = ['-DUNICODE', '-D_UNICODE', '-DWINNT'], ), + ] + win32_extensions += [ WinExt_win32('servicemanager', extra_compile_args = ['-DUNICODE', '-D_UNICODE', *************** *** 1279,1289 **** ] ! pythonwin_extensions = [ ! WinExt_pythonwin("win32ui", extra_compile_args = ['-DBUILD_PYW'], ! pch_header="stdafx.h", base_address=dll_base_address), ! WinExt_pythonwin("win32uiole", pch_header="stdafxole.h", ! windows_h_version = 0x500), ! WinExt_pythonwin("dde", pch_header="stdafxdde.h"), ! ] # win32ui is large, so we reserve more bytes than normal dll_base_address += 0x100000 --- 1329,1341 ---- ] ! pythonwin_extensions = [] ! if is_32bit: ! pythonwin_extensions += [ ! WinExt_pythonwin("win32ui", extra_compile_args = ['-DBUILD_PYW'], ! pch_header="stdafx.h", base_address=dll_base_address), ! WinExt_pythonwin("win32uiole", pch_header="stdafxole.h", ! windows_h_version = 0x500), ! WinExt_pythonwin("dde", pch_header="stdafxdde.h"), ! ] # win32ui is large, so we reserve more bytes than normal dll_base_address += 0x100000 *************** *** 1319,1323 **** extra_link_args=["/SUBSYSTEM:CONSOLE"], libraries = "user32 advapi32 ole32 shell32"), ! WinExt_pythonwin("Pythonwin", extra_link_args=["/SUBSYSTEM:WINDOWS"]), ] --- 1371,1378 ---- extra_link_args=["/SUBSYSTEM:CONSOLE"], libraries = "user32 advapi32 ole32 shell32"), ! ] ! if is_32bit: ! W32_exe_files += [ ! WinExt_pythonwin("Pythonwin", extra_link_args=["/SUBSYSTEM:WINDOWS"]), ] |