[Python-checkins] python/dist/src/Lib/distutils/command upload.py, NONE, 1.9.2.2 bdist_dumb.py, 1.20.2.2, 1.20.2.3 bdist_rpm.py, 1.29.2.2, 1.29.2.3 bdist_wininst.py, 1.33.2.2, 1.33.2.3 clean.py, 1.14.2.2, 1.14.2.3 install.py, 1.64.2.2, 1.64.2.3 register.py, 1.6.4.2, 1.6.4.3 sdist.py, 1.54.2.2, 1.54.2.3 wininst-6.exe, 1.7.2.1, 1.7.2.2 wininst-7.1.exe, 1.7.2.1, 1.7.2.2
jhylton@users.sourceforge.net
jhylton at users.sourceforge.net
Sun Oct 16 07:24:34 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib/distutils/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27718/Lib/distutils/command
Modified Files:
Tag: ast-branch
bdist_dumb.py bdist_rpm.py bdist_wininst.py clean.py
install.py register.py sdist.py wininst-6.exe wininst-7.1.exe
Added Files:
Tag: ast-branch
upload.py
Log Message:
Merge head to branch (for the last time)
--- NEW FILE: upload.py ---
"""distutils.command.upload
Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
from distutils.errors import *
from distutils.core import Command
from distutils.spawn import spawn
from distutils import log
from md5 import md5
import os
import socket
import platform
import ConfigParser
import httplib
import base64
import urlparse
import cStringIO as StringIO
class upload(Command):
description = "upload binary package to PyPI"
DEFAULT_REPOSITORY = 'http://www.python.org/pypi'
user_options = [
('repository=', 'r',
"url of repository [default: %s]" % DEFAULT_REPOSITORY),
('show-response', None,
'display full response text from server'),
('sign', 's',
'sign files to upload using gpg'),
]
boolean_options = ['show-response', 'sign']
def initialize_options(self):
self.username = ''
self.password = ''
self.repository = ''
self.show_response = 0
self.sign = False
def finalize_options(self):
if os.environ.has_key('HOME'):
rc = os.path.join(os.environ['HOME'], '.pypirc')
if os.path.exists(rc):
self.announce('Using PyPI login from %s' % rc)
config = ConfigParser.ConfigParser({
'username':'',
'password':'',
'repository':''})
config.read(rc)
if not self.repository:
self.repository = config.get('server-login', 'repository')
if not self.username:
self.username = config.get('server-login', 'username')
if not self.password:
self.password = config.get('server-login', 'password')
if not self.repository:
self.repository = self.DEFAULT_REPOSITORY
def run(self):
if not self.distribution.dist_files:
raise DistutilsOptionError("No dist file created in earlier command")
for command, pyversion, filename in self.distribution.dist_files:
self.upload_file(command, pyversion, filename)
def upload_file(self, command, pyversion, filename):
# Sign if requested
if self.sign:
spawn(("gpg", "--detach-sign", "-a", filename),
dry_run=self.dry_run)
# Fill in the data
content = open(filename,'rb').read()
data = {
':action':'file_upload',
'protcol_version':'1',
'name':self.distribution.get_name(),
'version':self.distribution.get_version(),
'content':(os.path.basename(filename),content),
'filetype':command,
'pyversion':pyversion,
'md5_digest':md5(content).hexdigest(),
}
comment = ''
if command == 'bdist_rpm':
dist, version, id = platform.dist()
if dist:
comment = 'built for %s %s' % (dist, version)
elif command == 'bdist_dumb':
comment = 'built for %s' % platform.platform(terse=1)
data['comment'] = comment
if self.sign:
data['gpg_signature'] = (os.path.basename(filename) + ".asc",
open(filename+".asc").read())
# set up the authentication
auth = "Basic " + base64.encodestring(self.username + ":" + self.password).strip()
# Build up the MIME payload for the POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary = '\n--' + boundary
end_boundary = sep_boundary + '--'
body = StringIO.StringIO()
for key, value in data.items():
# handle multiple entries for the same name
if type(value) != type([]):
value = [value]
for value in value:
if type(value) is tuple:
fn = ';filename="%s"' % value[0]
value = value[1]
else:
fn = ""
value = str(value)
body.write(sep_boundary)
body.write('\nContent-Disposition: form-data; name="%s"'%key)
body.write(fn)
body.write("\n\n")
body.write(value)
if value and value[-1] == '\r':
body.write('\n') # write an extra newline (lurve Macs)
body.write(end_boundary)
body.write("\n")
body = body.getvalue()
self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
# build the Request
# We can't use urllib2 since we need to send the Basic
# auth right with the first request
schema, netloc, url, params, query, fragments = \
urlparse.urlparse(self.repository)
assert not params and not query and not fragments
if schema == 'http':
http = httplib.HTTPConnection(netloc)
elif schema == 'https':
http = httplib.HTTPSConnection(netloc)
else:
raise AssertionError, "unsupported schema "+schema
data = ''
loglevel = log.INFO
try:
http.connect()
http.putrequest("POST", url)
http.putheader('Content-type',
'multipart/form-data; boundary=%s'%boundary)
http.putheader('Content-length', str(len(body)))
http.putheader('Authorization', auth)
http.endheaders()
http.send(body)
except socket.error, e:
self.announce(e.msg, log.ERROR)
return
r = http.getresponse()
if r.status == 200:
self.announce('Server response (%s): %s' % (r.status, r.reason),
log.INFO)
else:
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR)
if self.show_response:
print '-'*75, r.read(), '-'*75
Index: bdist_dumb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -u -d -r1.20.2.2 -r1.20.2.3
--- bdist_dumb.py 7 Jan 2005 06:58:17 -0000 1.20.2.2
+++ bdist_dumb.py 16 Oct 2005 05:24:00 -0000 1.20.2.3
@@ -13,6 +13,7 @@
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):
@@ -117,8 +118,14 @@
ensure_relative(install.install_base))
# Make the archive
- self.make_archive(pseudoinstall_root,
- self.format, root_dir=archive_root)
+ filename = self.make_archive(pseudoinstall_root,
+ self.format, root_dir=archive_root)
+ 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)
Index: bdist_rpm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v
retrieving revision 1.29.2.2
retrieving revision 1.29.2.3
diff -u -d -r1.29.2.2 -r1.29.2.3
--- bdist_rpm.py 7 Jan 2005 06:58:17 -0000 1.29.2.2
+++ bdist_rpm.py 16 Oct 2005 05:24:00 -0000 1.29.2.3
@@ -15,6 +15,7 @@
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):
@@ -297,12 +298,14 @@
# Make a source distribution and copy to SOURCES directory with
# optional icon.
+ saved_dist_files = self.distribution.dist_files[:]
sdist = self.reinitialize_command('sdist')
if self.use_bzip2:
sdist.formats = ['bztar']
else:
sdist.formats = ['gztar']
self.run_command('sdist')
+ self.distribution.dist_files = saved_dist_files
source = sdist.get_archive_files()[0]
source_dir = rpm_dir['SOURCES']
@@ -344,21 +347,31 @@
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)
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 = 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)
# run()
+ def _dist_path(self, path):
+ return os.path.join(self.dist_dir, os.path.basename(path))
def _make_spec_file(self):
"""Generate the text of an RPM spec file and return it as a
Index: bdist_wininst.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v
retrieving revision 1.33.2.2
retrieving revision 1.33.2.3
diff -u -d -r1.33.2.2 -r1.33.2.3
--- bdist_wininst.py 7 Jan 2005 06:58:17 -0000 1.33.2.2
+++ bdist_wininst.py 16 Oct 2005 05:24:00 -0000 1.33.2.3
@@ -162,6 +162,12 @@
root_dir=self.bdist_dir)
# create an exe containing the zip-file
self.create_exe(arcname, fullname, self.bitmap)
+ 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)
os.remove(arcname)
Index: clean.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/clean.py,v
retrieving revision 1.14.2.2
retrieving revision 1.14.2.3
diff -u -d -r1.14.2.2 -r1.14.2.3
--- clean.py 7 Jan 2005 06:58:18 -0000 1.14.2.2
+++ clean.py 16 Oct 2005 05:24:00 -0000 1.14.2.3
@@ -15,7 +15,7 @@
class clean (Command):
- description = "clean up output of 'build' command"
+ description = "clean up temporary files from 'build' command"
user_options = [
('build-base=', 'b',
"base build directory (default: 'build.build-base')"),
Index: install.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v
retrieving revision 1.64.2.2
retrieving revision 1.64.2.3
diff -u -d -r1.64.2.2 -r1.64.2.3
--- install.py 7 Jan 2005 06:58:18 -0000 1.64.2.2
+++ install.py 16 Oct 2005 05:24:00 -0000 1.64.2.3
@@ -352,8 +352,13 @@
opt_name = opt[0]
if opt_name[-1] == "=":
opt_name = opt_name[0:-1]
- opt_name = string.translate(opt_name, longopt_xlate)
- val = getattr(self, opt_name)
+ if self.negative_opt.has_key(opt_name):
+ opt_name = string.translate(self.negative_opt[opt_name],
+ longopt_xlate)
+ val = not getattr(self, opt_name)
+ else:
+ opt_name = string.translate(opt_name, longopt_xlate)
+ val = getattr(self, opt_name)
print " %s: %s" % (opt_name, val)
Index: register.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/register.py,v
retrieving revision 1.6.4.2
retrieving revision 1.6.4.3
diff -u -d -r1.6.4.2 -r1.6.4.3
--- register.py 7 Jan 2005 06:58:18 -0000 1.6.4.2
+++ register.py 16 Oct 2005 05:24:00 -0000 1.6.4.3
@@ -231,7 +231,13 @@
'platform': meta.get_platforms(),
'classifiers': meta.get_classifiers(),
'download_url': meta.get_download_url(),
+ # PEP 314
+ 'provides': meta.get_provides(),
+ 'requires': meta.get_requires(),
+ 'obsoletes': meta.get_obsoletes(),
}
+ if data['provides'] or data['requires'] or data['obsoletes']:
+ data['metadata_version'] = '1.1'
return data
def post_to_server(self, data, auth=None):
@@ -248,7 +254,7 @@
if type(value) != type([]):
value = [value]
for value in value:
- value = str(value)
+ value = unicode(value).encode("utf-8")
body.write(sep_boundary)
body.write('\nContent-Disposition: form-data; name="%s"'%key)
body.write("\n\n")
@@ -261,7 +267,7 @@
# build the Request
headers = {
- 'Content-type': 'multipart/form-data; boundary=%s'%boundary,
+ 'Content-type': 'multipart/form-data; boundary=%s; charset=utf-8'%boundary,
'Content-length': str(len(body))
}
req = urllib2.Request(self.repository, body, headers)
Index: sdist.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/sdist.py,v
retrieving revision 1.54.2.2
retrieving revision 1.54.2.3
diff -u -d -r1.54.2.2 -r1.54.2.3
--- sdist.py 7 Jan 2005 06:58:18 -0000 1.54.2.2
+++ sdist.py 16 Oct 2005 05:24:00 -0000 1.54.2.3
@@ -449,6 +449,7 @@
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.archive_files = archive_files
Index: wininst-6.exe
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
Binary files /tmp/cvsyel2jA and /tmp/cvsgGcGn6 differ
Index: wininst-7.1.exe
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
Binary files /tmp/cvstfihKA and /tmp/cvsxCmPU6 differ
More information about the Python-checkins
mailing list