[pywin32-checkins] pywin32 setup_win32all_core.py,1.21,1.22
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-12-01 10:46:44
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1:/tmp/cvs-serv5225 Modified Files: setup_win32all_core.py Log Message: Add support for _d builds, and correct SWIG generation. Index: setup_win32all_core.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all_core.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** setup_win32all_core.py 29 Nov 2003 06:41:55 -0000 1.21 --- setup_win32all_core.py 1 Dec 2003 10:46:41 -0000 1.22 *************** *** 1,4 **** ! # distutils setup-script for win32all ! # # Thomas Heller, started in 2000 or so. # --- 1,29 ---- ! """distutils setup-script for win32all ! ! To build the win32all extensions, simply execute: ! python setup_win32all.py -q build ! ! These extensions require a number of libraries to build, some of which may ! require your to install special SDKs or toolkits. This script will attempt ! to build as many as it can, and at the end of the build, will report any ! extension modules that could not be built and why. Not being able to build ! the MAPI or ActiveScripting related projects is common. ! If you don't use these extensions, you can ignore these warnings; if you do ! use them, you must install the correct libraries. ! ! To install the win32all extensions, execute: ! python setup_win32all.py -q install ! ! This will install the built extensions into your site-packages directory, ! and create an appropriate .pth file, and should leave everything ready to use. ! There should be no need to modify the registry. ! ! To build or install debug (_d) versions of these extensions, pass the "--debug" ! flag to the build command - eg: ! python setup_win32all.py -q build --debug ! or to build and install a debug version: ! python setup_win32all.py -q build --debug install ! you must have built (or installed) a debug version of Python for this to work. ! """ # Thomas Heller, started in 2000 or so. # *************** *** 14,18 **** from distutils.dep_util import newer_group from distutils import log - from distutils import spawn from distutils import dir_util, file_util from distutils.sysconfig import get_python_lib --- 39,42 ---- *************** *** 154,166 **** common_dirs = self.compiler.library_dirs common_dirs += os.environ.get("LIB").split(os.pathsep) for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): ! continue ! for dir in common_dirs + ext.library_dirs: ! if os.path.isfile(os.path.join(dir, lib + ".lib")): ! self.found_libraries[lib.lower()] = True ! break else: ! return "No library '%s'" % lib def build_extensions(self): --- 178,196 ---- common_dirs = self.compiler.library_dirs common_dirs += os.environ.get("LIB").split(os.pathsep) + patched_libs = [] for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): ! found = self.found_libraries[lib.lower()] else: ! look_dirs = common_dirs + ext.library_dirs ! found = self.compiler.find_library_file(look_dirs, lib, self.debug) ! if not found: ! return "No library '%s'" % lib ! self.found_libraries[lib.lower()] = found ! patched_libs.append(os.path.splitext(os.path.basename(found))[0]) ! # We update the .libraries list with the resolved library name. ! # This is really only so "_d" works. ! ext.libraries = patched_libs ! return None # no reason - it can be built! def build_extensions(self): *************** *** 202,207 **** makefile = 'makefile_pythonwin' makeargs = ["QUIET=1"] ! if self.dry_run: ! makeargs.append("-n") # We build the DLL into our own temp directory, then copy it to the # real directory - this avoids the generated .lib/.exp --- 232,239 ---- makefile = 'makefile_pythonwin' makeargs = ["QUIET=1"] ! if self.debug: ! makeargs.append("DEBUG=1") ! if not self.verbose: ! makeargs.append("/C") # nmake: /C Suppress output messages # We build the DLL into our own temp directory, then copy it to the # real directory - this avoids the generated .lib/.exp *************** *** 215,226 **** try: cmd = ["nmake.exe", "/nologo", "/f", makefile] + makeargs ! # dry_run handled by 'make /n' ! spawn.spawn(cmd, verbose=self.verbose, dry_run=0) finally: os.chdir(cwd) # The DLL goes in the Pythonwin directory. file_util.copy_file( ! os.path.join(self.build_temp, "scintilla", "scintilla.dll"), os.path.join(self.build_lib, "Pythonwin"), verbose = self.verbose, dry_run = self.dry_run) --- 247,261 ---- try: cmd = ["nmake.exe", "/nologo", "/f", makefile] + makeargs ! self.spawn(cmd) finally: os.chdir(cwd) # The DLL goes in the Pythonwin directory. + if self.debug: + base_name = "scintilla_d.dll" + else: + base_name = "scintilla.dll" file_util.copy_file( ! os.path.join(self.build_temp, "scintilla", base_name), os.path.join(self.build_lib, "Pythonwin"), verbose = self.verbose, dry_run = self.dry_run) *************** *** 236,240 **** sources = list(sources) ! print "building exe %s" % ext.name fullname = self.get_ext_fullname(ext.name) --- 271,275 ---- sources = list(sources) ! log.info("building exe '%s'", ext.name) fullname = self.get_ext_fullname(ext.name) *************** *** 351,356 **** self.swig_cpp = True try: - self.build_temp = os.path.join(self.build_temp, ext.name) - build_ext.build_extension(self, ext) --- 386,389 ---- *************** *** 414,430 **** # source -- but there should be an option to put SWIG output in # the temp dir. target_ext = '.cpp' for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! # Seems the files SWIG creates are not compiled separately, ! # they are #included somewhere else. So we don't include ! # the generated wrapper in the new_sources list. swig_sources.append(source) ! # and win32all has it's own naming convention for the wrappers: ! if base.endswith("win32pipe") or base.endswith("win32security"): ! swig_targets[source] = base + 'module' + target_ext ! else: swig_targets[source] = base + 'module_win32' + target_ext else: new_sources.append(source) --- 447,467 ---- # source -- but there should be an option to put SWIG output in # the temp dir. + # XXX - further, the way the win32/wince SWIG modules #include the + # real .cpp file prevents us generating the .cpp files in the temp dir. target_ext = '.cpp' for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! if os.path.split(base)[1] in swig_include_files: ! continue swig_sources.append(source) ! # Patch up the filenames for SWIG modules that also build ! # under WinCE - see defn of swig_wince_modules for details ! if os.path.basename(base) in swig_interface_parents: ! swig_targets[source] = base + target_ext ! elif os.path.basename(base) in swig_wince_modules: swig_targets[source] = base + 'module_win32' + target_ext + else: + swig_targets[source] = base + 'module' + target_ext else: new_sources.append(source) *************** *** 434,445 **** swig = self.find_swig() - swig_cmd = [swig, "-python"] - if self.swig_cpp: - swig_cmd.append("-c++") for source in swig_sources: target = swig_targets[source] log.info("swigging %s to %s", source, target) ! self.spawn(swig_cmd + ["-o", target, source]) return new_sources --- 471,506 ---- swig = self.find_swig() for source in swig_sources: + swig_cmd = [swig, "-python", "-c++"] + swig_cmd.append("-dnone",) # we never use the .doc files. target = swig_targets[source] + try: + interface_parent = swig_interface_parents[ + os.path.basename(os.path.splitext(source)[0])] + except KeyError: + # "normal" swig file - no special win32 issues. + pass + else: + # Using win32 extensions to SWIG for generating COM classes. + if interface_parent is not None: + # generating a class, not a module. + swig_cmd.append("-pythoncom") + if interface_parent: + # A class deriving from other than the default + swig_cmd.extend( + ["-com_interface_parent", interface_parent]) + + swig_cmd.extend(["-o", + os.path.abspath(target), + os.path.abspath(source)]) log.info("swigging %s to %s", source, target) ! out_dir = os.path.dirname(source) ! cwd = os.getcwd() ! os.chdir(out_dir) ! try: ! self.spawn(swig_cmd) ! finally: ! os.chdir(cwd) return new_sources *************** *** 562,565 **** --- 623,662 ---- ] + # Special definitions for SWIG. + swig_interface_parents = { + # source file base, "base class" for generated COM support + 'mapi': None, # not a class, but module + 'PyIMailUser': 'IMAPIContainer', + 'PyIABContainer': 'IMAPIContainer', + 'PyIAddrBook': 'IMAPIProp', + 'PyIAttach': 'IMAPIProp', + 'PyIDistList': 'IMAPIProp', + 'PyIMailUser': 'IMAPIContainer', + 'PyIMAPIContainer': 'IMAPIProp', + 'PyIMAPIFolder': 'IMAPIContainer', + 'PyIMAPIProp': '', # '' == default base + 'PyIMAPISession': '', + 'PyIMAPITable': '', + 'PyIMessage': 'IMAPIProp', + 'PyIMsgServiceAdmin': '', + 'PyIMsgStore': 'IMAPIProp', + 'PyIProfAdmin': '', + 'PyIProfSect': 'IMAPIProp', + # ADSI + 'adsi': None, # module + 'PyIADsContainer': 'IDispatch', + 'PyIADsUser': 'IDispatch', + 'PyIDirectoryObject': '', + } + + # A list of modules that can also be built for Windows CE. These generate + # their .i to _win32.cpp or _wince.cpp. + swig_wince_modules = "win32event win32file win32gui win32process".split() + + # .i files that are #included, and hence are not part of the build. Our .dsp + # parser isn't smart enough to differentiate these. + swig_include_files = "mapilib adsilib".split() + + # Helper to allow our script specifications to include wildcards. def expand_modules(module_dir): flist = FileList() *************** *** 596,606 **** path_use = os.path.join(base_dir, path_use) ret.append( (path_use, files_use)) - #print "DataFiles:" - #for f in ret: - # print f return ret ################################################################ dist = setup(name="pywin32", --- 693,704 ---- path_use = os.path.join(base_dir, path_use) ret.append( (path_use, files_use)) return ret ################################################################ + if len(sys.argv)==1: + # distutils will print usage - print our docstring first. + print __doc__ + print "Standard usage information follows:" dist = setup(name="pywin32", *************** *** 616,620 **** }, options = {"bdist_wininst": {"install_script": "pywin32_postinstall.py"}}, ! scripts = ["pywin32_postinstall.py"], --- 714,718 ---- }, options = {"bdist_wininst": {"install_script": "pywin32_postinstall.py"}}, ! scripts = ["pywin32_postinstall.py"], |