[Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.18,1.19

Greg Ward python-dev@python.org
Sat, 9 Sep 2000 18:21:33 -0700


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

Modified Files:
	bdist_rpm.py 
Log Message:
Added --python and --fix-python options for better control over what
  interpreter the .spec file refers to.
Cosmetic tweaks.


Index: bdist_rpm.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** bdist_rpm.py	2000/09/07 02:38:42	1.18
--- bdist_rpm.py	2000/09/10 01:21:27	1.19
***************
*** 8,12 ****
  __revision__ = "$Id$"
  
! import os, string
  import glob
  from types import *
--- 8,12 ----
  __revision__ = "$Id$"
  
! import sys, os, string
  import glob
  from types import *
***************
*** 29,32 ****
--- 29,38 ----
           "directory to put final RPM files in "
           "(and .spec files if --spec-only)"),
+         ('python=', None,
+          "path to Python interpreter to hard-code in the .spec file "
+          "(default: \"python\")"),
+         ('fix-python', None,
+          "hard-code the exact path to the current Python interpreter in "
+          "the .spec file"),
          ('spec-only', None,
           "only regenerate spec file"),
***************
*** 115,118 ****
--- 121,126 ----
          self.rpm_base = None
          self.dist_dir = None
+         self.python = None
+         self.fix_python = None
          self.spec_only = None
          self.binary_only = None
***************
*** 160,163 ****
--- 168,180 ----
              self.rpm_base = os.path.join(self.bdist_base, "rpm")
  
+         if self.python is None:
+             if self.fix_python:
+                 self.python = sys.executable
+             else:
+                 self.python = "python"
+         elif self.fix_python:
+             raise DistutilsOptionError, \
+                   "--python and --fix-python are mutually exclusive options"
+ 
          if os.name != 'posix':
              raise DistutilsPlatformError, \
***************
*** 276,294 ****
  
          # build package
!         self.announce('Building RPMs')
!         rpm_args = ['rpm',]
          if self.source_only: # what kind of RPMs?
!             rpm_args.append('-bs')
          elif self.binary_only:
!             rpm_args.append('-bb')
          else:
!             rpm_args.append('-ba')
          if self.rpm3_mode:
!             rpm_args.extend(['--define',
                               '_topdir %s/%s' % (os.getcwd(), self.rpm_base),])
          if self.clean:
!             rpm_args.append('--clean')
!         rpm_args.append(spec_path)
!         self.spawn(rpm_args)
  
          # XXX this is a nasty hack -- we really should have a proper way to
--- 293,311 ----
  
          # build package
!         self.announce('building RPMs')
!         rpm_cmd = ['rpm']
          if self.source_only: # what kind of RPMs?
!             rpm_cmd.append('-bs')
          elif self.binary_only:
!             rpm_cmd.append('-bb')
          else:
!             rpm_cmd.append('-ba')
          if self.rpm3_mode:
!             rpm_cmd.extend(['--define',
                               '_topdir %s/%s' % (os.getcwd(), self.rpm_base),])
          if self.clean:
!             rpm_cmd.append('--clean')
!         rpm_cmd.append(spec_path)
!         self.spawn(rpm_cmd)
  
          # XXX this is a nasty hack -- we really should have a proper way to
***************
*** 399,406 ****
          # rpm scripts
          # figure out default build script
          if self.use_rpm_opt_flags:
!             def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build'
!         else:
!             def_build = 'python setup.py build'
          # insert contents of files
  
--- 416,423 ----
          # rpm scripts
          # figure out default build script
+         def_build = "%s setup.py build" % self.python
          if self.use_rpm_opt_flags:
!             def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
! 
          # insert contents of files
  
***************
*** 413,419 ****
              ('build', 'build_script', def_build),
              ('install', 'install_script',
!              "python setup.py install "
!              "--root=$RPM_BUILD_ROOT "
!              "--record=INSTALLED_FILES"),
              ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
              ('pre', 'pre_install', None),
--- 430,436 ----
              ('build', 'build_script', def_build),
              ('install', 'install_script',
!              ("%s setup.py install "
!               "--root=$RPM_BUILD_ROOT "
!               "--record=INSTALLED_FILES") % self.python),
              ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
              ('pre', 'pre_install', None),