patch for making distutils cross compile on win32

Robin Becker robin at reportlab.com
Tue Dec 17 08:51:20 EST 2013


I have struggled to get Python-3.3.3 distutils to cross compile win-amd64 on 
win32. For the specific command (bdist_wininst) I am using the patch below seems 
to fix things so I can build amd64 binaries on win32. The code seems a bit 
schizophrenic about whether this is supposed to work, but without the patch it 
certainly doesn't.

*** \python33\lib\distutils\command\bdist_wininst.py    Wed Aug 01 10:05:14 2012
--- distutils\command\bdist_wininst.py  Tue Dec 17 13:14:02 2013
***************
*** 72,88 ****


       def finalize_options(self):
-         self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
-
           if self.bdist_dir is None:
!             if self.skip_build and self.plat_name:
                   # If build is skipped and plat_name is overridden, bdist will
                   # not see the correct 'plat_name' - so set that up manually.
!                 bdist = self.distribution.get_command_obj('bdist')
!                 bdist.plat_name = self.plat_name
                   # next the command will be initialized using that name
               bdist_base = self.get_finalized_command('bdist').bdist_base
               self.bdist_dir = os.path.join(bdist_base, 'wininst')

           if not self.target_version:
               self.target_version = ""
--- 72,89 ----


       def finalize_options(self):
           if self.bdist_dir is None:
!             if self.plat_name:
                   # If build is skipped and plat_name is overridden, bdist will
                   # not see the correct 'plat_name' - so set that up manually.
!                 self.distribution.get_command_obj('build').plat_name = 
self.plat_name
!                 self.distribution.get_command_obj('build_py').plat_name = 
self.plat_name
!                 self.distribution.get_command_obj('build_ext').plat_name = 
self.plat_name
!                 self.distribution.get_command_obj('bdist').plat_name = 
self.plat_name
                   # next the command will be initialized using that name
               bdist_base = self.get_finalized_command('bdist').bdist_base
               self.bdist_dir = os.path.join(bdist_base, 'wininst')
+         self.set_undefined_options('bdist', ('skip_build', 'skip_build'))

           if not self.target_version:
               self.target_version = ""
*** \python33\lib\distutils\command\build_ext.py        Sun Oct 27 17:02:50 2013
--- distutils\command\build_ext.py      Tue Dec 17 12:48:51 2013
***************
*** 218,224 ****
                   new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
                   if suffix:
                       new_lib = os.path.join(new_lib, suffix)
!                 self.library_dirs.append(new_lib)

               elif MSVC_VERSION == 8:
                   self.library_dirs.append(os.path.join(sys.exec_prefix,
--- 218,226 ----
                   new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
                   if suffix:
                       new_lib = os.path.join(new_lib, suffix)
!                     self.library_dirs.insert(0,new_lib)
!                 else:
!                     self.library_dirs.append(new_lib)

               elif MSVC_VERSION == 8:
                   self.library_dirs.append(os.path.join(sys.exec_prefix,
-- 
Robin Becker




More information about the Python-list mailing list