summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/command')
-rw-r--r--Lib/distutils/command/bdist_rpm.py67
-rw-r--r--Lib/distutils/command/build_ext.py2
-rw-r--r--Lib/distutils/command/install_egg_info.py3
-rw-r--r--Lib/distutils/command/register.py2
-rw-r--r--Lib/distutils/command/wininst-8.exebin0 -> 61440 bytes
5 files changed, 44 insertions, 30 deletions
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index 5b09965..6f0e0d8 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -337,37 +337,47 @@ class bdist_rpm (Command):
if not self.keep_temp:
rpm_cmd.append('--clean')
rpm_cmd.append(spec_path)
+ # Determine the binary rpm names that should be built out of this spec
+ # file
+ # Note that some of these may not be really built (if the file
+ # list is empty)
+ nvr_string = "%{name}-%{version}-%{release}"
+ src_rpm = nvr_string + ".src.rpm"
+ non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
+ q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % (
+ src_rpm, non_src_rpm, spec_path)
+
+ out = os.popen(q_cmd)
+ binary_rpms = []
+ source_rpm = None
+ while 1:
+ line = out.readline()
+ if not line:
+ break
+ l = string.split(string.strip(line))
+ assert(len(l) == 2)
+ binary_rpms.append(l[1])
+ # The source rpm is named after the first entry in the spec file
+ if source_rpm is None:
+ source_rpm = l[0]
+
+ status = out.close()
+ if status:
+ raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
+
self.spawn(rpm_cmd)
- # XXX this is a nasty hack -- we really should have a proper way to
- # find out the names of the RPM files created; also, this assumes
- # that RPM creates exactly one source and one binary RPM.
if not self.dry_run:
if not self.binary_only:
- srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm"))
- assert len(srpms) == 1, \
- "unexpected number of SRPM files found: %s" % srpms
- dist_file = ('bdist_rpm', 'any',
- self._dist_path(srpms[0]))
- self.distribution.dist_files.append(dist_file)
- self.move_file(srpms[0], self.dist_dir)
+ srpm = os.path.join(rpm_dir['SRPMS'], source_rpm)
+ assert(os.path.exists(srpm))
+ self.move_file(srpm, self.dist_dir)
if not self.source_only:
- rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm"))
- debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'],
- "*/*debuginfo*.rpm"))
- if debuginfo:
- rpms.remove(debuginfo[0])
- assert len(rpms) == 1, \
- "unexpected number of RPM files found: %s" % rpms
- dist_file = ('bdist_rpm', get_python_version(),
- self._dist_path(rpms[0]))
- self.distribution.dist_files.append(dist_file)
- self.move_file(rpms[0], self.dist_dir)
- if debuginfo:
- dist_file = ('bdist_rpm', get_python_version(),
- self._dist_path(debuginfo[0]))
- self.move_file(debuginfo[0], self.dist_dir)
+ for rpm in binary_rpms:
+ rpm = os.path.join(rpm_dir['RPMS'], rpm)
+ if os.path.exists(rpm):
+ self.move_file(rpm, self.dist_dir)
# run()
def _dist_path(self, path):
@@ -381,6 +391,7 @@ class bdist_rpm (Command):
spec_file = [
'%define name ' + self.distribution.get_name(),
'%define version ' + self.distribution.get_version().replace('-','_'),
+ '%define unmangled_version ' + self.distribution.get_version(),
'%define release ' + self.release.replace('-','_'),
'',
'Summary: ' + self.distribution.get_description(),
@@ -402,9 +413,9 @@ class bdist_rpm (Command):
# but only after it has run: and we create the spec file before
# running "sdist", in case of --spec-only.
if self.use_bzip2:
- spec_file.append('Source0: %{name}-%{version}.tar.bz2')
+ spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2')
else:
- spec_file.append('Source0: %{name}-%{version}.tar.gz')
+ spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz')
spec_file.extend([
'License: ' + self.distribution.get_license(),
@@ -479,7 +490,7 @@ class bdist_rpm (Command):
# are just text that we drop in as-is. Hmmm.
script_options = [
- ('prep', 'prep_script', "%setup"),
+ ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"),
('build', 'build_script', def_build),
('install', 'install_script',
("%s install "
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index cd67544..f79eee3 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -186,7 +186,7 @@ class build_ext (Command):
# for extensions under Cygwin and AtheOS Python's library directory must be
# appended to library_dirs
if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' or \
- (sys.platform.startswith('linux') and
+ ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')) and
sysconfig.get_config_var('Py_ENABLE_SHARED')):
if string.find(sys.executable, sys.exec_prefix) != -1:
# building third party extensions
diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
index c31ac29..c888031 100644
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -35,6 +35,9 @@ class install_egg_info(Command):
dir_util.remove_tree(target, dry_run=self.dry_run)
elif os.path.exists(target):
self.execute(os.unlink,(self.target,),"Removing "+target)
+ elif not os.path.isdir(self.install_dir):
+ self.execute(os.makedirs, (self.install_dir,),
+ "Creating "+self.install_dir)
log.info("Writing %s", target)
if not self.dry_run:
f = open(target, 'w')
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index f891262..3177476 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -256,7 +256,7 @@ Your selection [default 1]: ''',
body = StringIO.StringIO()
for key, value in data.items():
# handle multiple entries for the same name
- if type(value) != type([]):
+ if type(value) not in (type([]), type( () )):
value = [value]
for value in value:
value = unicode(value).encode("utf-8")
diff --git a/Lib/distutils/command/wininst-8.exe b/Lib/distutils/command/wininst-8.exe
new file mode 100644
index 0000000..7403bfa
--- /dev/null
+++ b/Lib/distutils/command/wininst-8.exe
Binary files differ