summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2005-03-22 15:51:14 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2005-03-22 15:51:14 (GMT)
commitf74b923ae5e3ed890f02f8afbca41123276f6931 (patch)
treebedba4c0328773a9b7b9c4030ed713a4bc299af8 /Lib/distutils
parentc448a91ee855ee9c24ecf3e66410e04ae3c6ce98 (diff)
downloadcpython-f74b923ae5e3ed890f02f8afbca41123276f6931.zip
cpython-f74b923ae5e3ed890f02f8afbca41123276f6931.tar.gz
cpython-f74b923ae5e3ed890f02f8afbca41123276f6931.tar.bz2
Upload GPG signature.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/command/upload.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index aea2e4b..ad0e230 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -4,9 +4,10 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
from distutils.errors import *
from distutils.core import Command
-from md5 import md5
from distutils.sysconfig import get_python_version
+from distutils.spawn import spawn
from distutils import log
+from md5 import md5
import os
import platform
import ConfigParser
@@ -26,14 +27,17 @@ class upload(Command):
"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']
+ 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'):
@@ -61,11 +65,16 @@ class upload(Command):
self.upload_file(command, filename)
def upload_file(self, command, filename):
+ # Sign if requested
+ if self.sign:
+ spawn(("gpg", "--sign", "-a", filename),
+ dry_run=self.dry_run)
# Fill in the data
content = open(filename).read()
data = {
':action':'file_upload',
+ 'protcol_version':'1',
'name':self.distribution.get_name(),
'version':self.distribution.get_version(),
'content':(os.path.basename(filename),content),
@@ -82,6 +91,10 @@ class upload(Command):
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()
@@ -148,7 +161,7 @@ class upload(Command):
log.INFO)
else:
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
- log.INFO)
+ log.ERROR)
if self.show_response:
print '-'*75, r.read(), '-'*75