[Python-checkins] python/dist/src setup.py,1.126,1.127

mwh@users.sourceforge.net mwh@users.sourceforge.net
Tue, 17 Dec 2002 08:47:20 -0800


Update of /cvsroot/python/python/dist/src
In directory sc8-pr-cvs1:/tmp/cvs-serv8030

Modified Files:
	setup.py 
Log Message:
This is J. Lewis Muir's patch:

[ 629278 ] install lib-dynload .so files mode 555

fixing 

[ 583206 ] lib-dynload/*.so wrong permissions
[ 425007 ] Python 2.1 installs shared libs with mode 0700

Phew.


Index: setup.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/setup.py,v
retrieving revision 1.126
retrieving revision 1.127
diff -C2 -d -r1.126 -r1.127
*** setup.py	16 Dec 2002 20:31:57 -0000	1.126
--- setup.py	17 Dec 2002 16:47:17 -0000	1.127
***************
*** 5,8 ****
--- 5,10 ----
  
  import sys, os, getopt, imp, re
+ 
+ from distutils import log
  from distutils import sysconfig
  from distutils import text_file
***************
*** 11,14 ****
--- 13,17 ----
  from distutils.command.build_ext import build_ext
  from distutils.command.install import install
+ from distutils.command.install_lib import install_lib
  
  # This global variable is used to hold the list of modules to be disabled.
***************
*** 993,996 ****
--- 996,1036 ----
          self.warn_dir=0
  
+ class PyBuildInstallLib(install_lib):
+     # Do exactly what install_lib does but make sure correct access modes get
+     # set on installed directories and files. All installed files with get
+     # mode 644 unless they are a shared library in which case they will get
+     # mode 755. All installed directories will get mode 755.
+ 
+     so_ext = sysconfig.get_config_var("SO")
+ 
+     def install(self):
+         outfiles = install_lib.install(self)
+         self.set_file_modes(outfiles, 0644, 0755)
+         self.set_dir_modes(self.install_dir, 0755)
+         return outfiles
+ 
+     def set_file_modes(self, files, defaultMode, sharedLibMode):
+         if not self.is_chmod_supported(): return
+         if not files: return
+ 
+         for filename in files:
+             if os.path.islink(filename): continue
+             mode = defaultMode
+             if filename.endswith(self.so_ext): mode = sharedLibMode
+             log.info("changing mode of %s to %o", filename, mode)
+             if not self.dry_run: os.chmod(filename, mode)
+ 
+     def set_dir_modes(self, dirname, mode):
+         if not self.is_chmod_supported(): return
+         os.path.walk(dirname, self.set_dir_modes_visitor, mode)
+ 
+     def set_dir_modes_visitor(self, mode, dirname, names):
+         if os.path.islink(dirname): return
+         log.info("changing mode of %s to %o", dirname, mode)
+         if not self.dry_run: os.chmod(dirname, mode)
+ 
+     def is_chmod_supported(self):
+         return hasattr(os, 'chmod')
+ 
  def main():
      # turn off warnings when deprecated modules are imported
***************
*** 999,1003 ****
      setup(name = 'Python standard library',
            version = '%d.%d' % sys.version_info[:2],
!           cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall},
            # The struct module is defined here, because build_ext won't be
            # called unless there's at least one extension module defined.
--- 1039,1044 ----
      setup(name = 'Python standard library',
            version = '%d.%d' % sys.version_info[:2],
!           cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall,
!                       'install_lib':PyBuildInstallLib},
            # The struct module is defined here, because build_ext won't be
            # called unless there's at least one extension module defined.