[Python-checkins] CVS: distutils/distutils/command __init__.py,1.10,1.11 build.py,1.19,1.20 install_data.py,1.5,1.6 install_scripts.py,1.4,1.5

Greg Ward python-dev@python.org
Wed, 24 May 2000 18:19:20 -0700


Update of /cvsroot/python/distutils/distutils/command
In directory slayer.i.sourceforge.net:/tmp/cvs-serv15059

Modified Files:
	__init__.py build.py install_data.py install_scripts.py 
Log Message:
Bastian Kleineidam: the "build_scripts" command and changes
necessary to support it.

Details:
  - build command additionally calls build_scripts
  - build_scripts builds your scripts in 'build/scripts' and adjusts the
    first line if it begins with "#!" and ends with "python", optionally
    ending with commandline options (like -O, -t ...).  Adjusting means we
    write the current path to the Python interpreter in the first line.
  - install_scripts copies the scripts to the install_scripts dir
  - install_data copies your data_files in install_data. You can
    supply individual directories for your data_files:

    data_files = ['doc/info.txt', # copy this file in install_scripts dir
      ('testdata', ['a.dat', 'b.dat']), # copy these files in
                                        # install_scripts/testdata
      ('/etc', ['packagerc']),    # copy this in /etc. When --root is
                                  # given, copy this in rootdir/etc
    ]

    So you can use the --root option with absolute data paths.


Index: __init__.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/__init__.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** __init__.py	2000/05/13 01:48:15	1.10
--- __init__.py	2000/05/25 01:19:18	1.11
***************
*** 4,8 ****
  commands."""
  
! __revision__ = "$Id: __init__.py,v 1.10 2000/05/13 01:48:15 greg Exp $"
  
  __all__ = ['build',
--- 4,8 ----
  commands."""
  
! __revision__ = "$Id: __init__.py,v 1.11 2000/05/25 01:19:18 gward Exp $"
  
  __all__ = ['build',
***************
*** 10,13 ****
--- 10,14 ----
             'build_ext',
             'build_clib',
+            'build_scripts',
             'install',
             'install_lib',

Index: build.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/build.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** build.py	2000/05/25 01:10:04	1.19
--- build.py	2000/05/25 01:19:18	1.20
***************
*** 5,9 ****
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: build.py,v 1.19 2000/05/25 01:10:04 gward Exp $"
  
  import sys, os
--- 5,9 ----
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: build.py,v 1.20 2000/05/25 01:19:18 gward Exp $"
  
  import sys, os
***************
*** 25,28 ****
--- 25,30 ----
           "build directory for all distribution (defaults to either " +
           "build-purelib or build-platlib"),
+         ('build-scripts=', None,
+          "build directory for scripts"),
          ('build-temp=', 't',
           "temporary build directory"),
***************
*** 43,46 ****
--- 45,49 ----
          self.build_lib = None
          self.build_temp = None
+         self.build_scripts = None
          self.compiler = None
          self.debug = None
***************
*** 77,80 ****
--- 80,85 ----
              self.build_temp = os.path.join (self.build_base,
                                              'temp.' + self.plat)
+         if self.build_scripts is None:
+             self.build_scripts = os.path.join (self.build_base, 'scripts')
      # finalize_options ()
  
***************
*** 100,103 ****
--- 105,111 ----
          if self.distribution.has_ext_modules():
              self.run_peer ('build_ext')
+ 
+         if self.distribution.scripts:
+             self.run_peer ('build_scripts')
  
  # class build

Index: install_data.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** install_data.py	2000/05/13 03:09:50	1.5
--- install_data.py	2000/05/25 01:19:18	1.6
***************
*** 6,23 ****
  # contributed by Bastian Kleineidam
  
! __revision__ = "$Id: install_data.py,v 1.5 2000/05/13 03:09:50 greg Exp $"
  
! from distutils.cmd import install_misc
  
! class install_data (install_misc):
  
      description = "install data files"
  
      def finalize_options (self):
!         self._install_dir_from('install_data')
  
      def run (self):
!         self._copy_files(self.distribution.data_files)
  
      def get_inputs (self):
!         return self.distribution.data_files or []
--- 6,58 ----
  # contributed by Bastian Kleineidam
  
! __revision__ = "$Id: install_data.py,v 1.6 2000/05/25 01:19:18 gward Exp $"
  
! import os
! from types import StringType
! from distutils.core import Command
  
! class install_data (Command):
  
      description = "install data files"
  
+     user_options = [
+         ('install-dir=', 'd',
+          "directory to install the files to"),
+         ('root=', None,
+          "install everything relative to this alternate root directory"),
+         ]
+ 
+     def initialize_options (self):
+         self.install_dir = None
+         self.outfiles = None
+         self.root = None
+         self.data_files = self.distribution.data_files
+ 
      def finalize_options (self):
!         self.set_undefined_options('install',
! 	                           ('install_data', 'install_dir'),
! 				   ('root', 'root'),
! 				  )
  
      def run (self):
!         self.mkpath(self.install_dir)
!         for f in self.data_files:
!             if type(f) == StringType:
!                 # its a simple file, so copy it
!                 self.copy_file(f, self.install_dir)
!             else:
!                 # its a tuple with path to install to and a list of files
!                 dir = f[0]
!                 if not os.path.isabs(dir):
!                     dir = os.path.join(self.install_dir, dir)
!                 elif self.root:
!                     dir = os.path.join(self.root, dir[1:])
!                 self.mkpath(dir)
!                 for data in f[1]:
!                     self.copy_file(data, dir)
  
      def get_inputs (self):
!         return self.data_files or []
! 
!     def get_outputs (self):
!         return self.outfiles

Index: install_scripts.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/install_scripts.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** install_scripts.py	2000/05/13 03:07:53	1.4
--- install_scripts.py	2000/05/25 01:19:18	1.5
***************
*** 6,29 ****
  # contributed by Bastian Kleineidam
  
! __revision__ = "$Id: install_scripts.py,v 1.4 2000/05/13 03:07:53 greg Exp $"
  
  import os
! from distutils.cmd import install_misc
  from stat import ST_MODE
  
! class install_scripts(install_misc):
  
      description = "install scripts"
  
      def finalize_options (self):
!         self._install_dir_from('install_scripts')
  
      def run (self):
!         self._copy_files(self.distribution.scripts)
          if os.name == 'posix':
              # Set the executable bits (owner, group, and world) on
              # all the scripts we just installed.
!             files = self.get_outputs()
!             for file in files:
                  if self.dry_run:
                      self.announce("changing mode of %s" % file)
--- 6,45 ----
  # contributed by Bastian Kleineidam
  
! __revision__ = "$Id: install_scripts.py,v 1.5 2000/05/25 01:19:18 gward Exp $"
  
  import os
! from distutils.core import Command
  from stat import ST_MODE
  
! class install_scripts(Command):
  
      description = "install scripts"
  
+     user_options = [
+         ('install-dir=', 'd', "directory to install to"),
+         ('build-dir=','b', "build directory (where to install from)"),
+         ('skip-build', None, "skip the build steps"),
+     ]
+ 
+     def initialize_options (self):
+         self.install_dir = None
+         self.build_dir = None
+         self.skip_build = None
+ 
      def finalize_options (self):
!         self.set_undefined_options('build', ('build_scripts', 'build_dir'))
!         self.set_undefined_options ('install',
!                                     ('install_scripts', 'install_dir'),
!                                     ('skip_build', 'skip_build'),
!                                    )
  
      def run (self):
!         if not self.skip_build:
!             self.run_peer('build_scripts')
!         self.outfiles = self.copy_tree (self.build_dir, self.install_dir)
          if os.name == 'posix':
              # Set the executable bits (owner, group, and world) on
              # all the scripts we just installed.
!             for file in self.get_outputs():
                  if self.dry_run:
                      self.announce("changing mode of %s" % file)
***************
*** 35,38 ****
--- 51,57 ----
      def get_inputs (self):
          return self.distribution.scripts or []
+ 
+     def get_outputs(self):
+         return self.outfiles or []
  
  # class install_scripts