Make dist_files a triple, with the Python target version included,

so that bdist_wininst can specify 'any'.
This commit is contained in:
Martin v. Löwis 2005-03-23 18:54:36 +00:00
parent c8734a7257
commit 98da562600
6 changed files with 38 additions and 14 deletions

View File

@ -13,6 +13,7 @@ from distutils.core import Command
from distutils.util import get_platform
from distutils.dir_util import create_tree, remove_tree, ensure_relative
from distutils.errors import *
from distutils.sysconfig import get_python_version
from distutils import log
class bdist_dumb (Command):
@ -119,7 +120,12 @@ class bdist_dumb (Command):
# Make the archive
filename = self.make_archive(pseudoinstall_root,
self.format, root_dir=archive_root)
self.distribution.dist_files.append(('bdist_dumb', filename))
if self.distribution.has_ext_modules():
pyversion = get_python_version()
else:
pyversion = 'any'
self.distribution.dist_files.append(('bdist_dumb', pyversion,
filename))
if not self.keep_temp:
remove_tree(self.bdist_dir, dry_run=self.dry_run)

View File

@ -15,6 +15,7 @@ from distutils.debug import DEBUG
from distutils.util import get_platform
from distutils.file_util import write_file
from distutils.errors import *
from distutils.sysconfig import get_python_version
from distutils import log
class bdist_rpm (Command):
@ -346,6 +347,10 @@ class bdist_rpm (Command):
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', '',
os.path.join(self.dist_dir,
os.path.basename(srpms[0])))
self.distribution.dist_files.append(dist_file)
self.move_file(srpms[0], self.dist_dir)
if not self.source_only:
@ -356,9 +361,15 @@ class bdist_rpm (Command):
rpms.remove(debuginfo[0])
assert len(rpms) == 1, \
"unexpected number of RPM files found: %s" % rpms
dist_file = ('bdist_rpm', get_python_version(),
os.path.join(self.dist_dir,
os.path.basename(rpms[0])))
self.distribution.dist_files.append(dist_file)
self.move_file(rpms[0], self.dist_dir)
self.distribution.dist_files.append(('bdist_rpm', rpms[0]))
if debuginfo:
dist_file = ('bdist_rpm', get_python_version(),
os.path.join(self.dist_dir,
os.path.basename(debuginfo[0])))
self.move_file(debuginfo[0], self.dist_dir)
# run()

View File

@ -162,7 +162,11 @@ class bdist_wininst (Command):
root_dir=self.bdist_dir)
# create an exe containing the zip-file
self.create_exe(arcname, fullname, self.bitmap)
self.distribution.dist_files.append(('bdist_wininst',
if self.distribution.has_ext_modules():
pyversion = get_python_version()
else:
pyversion = 'any'
self.distribution.dist_files.append(('bdist_wininst', pyversion,
self.get_installer_filename(fullname)))
# remove the zip-file again
log.debug("removing temporary file '%s'", arcname)

View File

@ -449,7 +449,7 @@ class sdist (Command):
for fmt in self.formats:
file = self.make_archive(base_name, fmt, base_dir=base_dir)
archive_files.append(file)
self.distribution.dist_files.append(('sdist',file))
self.distribution.dist_files.append(('sdist', '', file))
self.archive_files = archive_files

View File

@ -4,7 +4,6 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
from distutils.errors import *
from distutils.core import Command
from distutils.sysconfig import get_python_version
from distutils.spawn import spawn
from distutils import log
from md5 import md5
@ -61,10 +60,10 @@ class upload(Command):
def run(self):
if not self.distribution.dist_files:
raise DistutilsOptionError("No dist file created in earlier command")
for command, filename in self.distribution.dist_files:
self.upload_file(command, filename)
for command, pyversion, filename in self.distribution.dist_files:
self.upload_file(command, pyversion, filename)
def upload_file(self, command, filename):
def upload_file(self, command, pyversion, filename):
# Sign if requested
if self.sign:
spawn(("gpg", "--detach-sign", "-a", filename),
@ -79,7 +78,7 @@ class upload(Command):
'version':self.distribution.get_version(),
'content':(os.path.basename(filename),content),
'filetype':command,
'pyversion':get_python_version(),
'pyversion':pyversion,
'md5_digest':md5(content).hexdigest(),
}
comment = ''
@ -89,8 +88,6 @@ class upload(Command):
comment = 'built for %s %s' % (dist, version)
elif command == 'bdist_dumb':
comment = 'built for %s' % platform.platform(terse=1)
elif command == 'sdist':
data['pyversion'] = ''
data['comment'] = comment
if self.sign:

View File

@ -177,9 +177,15 @@ Common commands: (see '--help-commands' for more)
# command_options = { command_name : { option : (source, value) } }
self.command_options = {}
# 'dist_files' is the list of (command, file) that have been created
# by any dist commands run so far. This is filled regardless
# of whether the run is dry or not.
# 'dist_files' is the list of (command, pyversion, file) that
# have been created by any dist commands run so far. This is
# filled regardless of whether the run is dry or not. pyversion
# gives sysconfig.get_python_version() if the dist file is
# specific to a Python version, 'any' if it is good for all
# Python versions on the target platform, and '' for a source
# file. pyversion should not be used to specify minimum or
# maximum required Python versions; use the metainfo for that
# instead.
self.dist_files = []
# These options are really the business of various commands, rather