2014-05-10 14:20:28 -03:00
|
|
|
"""
|
|
|
|
distutils.command.upload
|
2005-03-21 16:56:35 -04:00
|
|
|
|
2014-05-10 14:20:28 -03:00
|
|
|
Implements the Distutils 'upload' subcommand (upload package to a package
|
|
|
|
index).
|
|
|
|
"""
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2014-05-10 14:20:28 -03:00
|
|
|
import os
|
|
|
|
import io
|
2014-05-10 14:22:43 -03:00
|
|
|
import hashlib
|
2010-07-22 09:50:05 -03:00
|
|
|
from base64 import standard_b64encode
|
2013-11-10 19:50:10 -04:00
|
|
|
from urllib.request import urlopen, Request, HTTPError
|
|
|
|
from urllib.parse import urlparse
|
2014-06-19 00:07:46 -03:00
|
|
|
from distutils.errors import DistutilsError, DistutilsOptionError
|
2014-05-10 14:20:28 -03:00
|
|
|
from distutils.core import PyPIRCCommand
|
|
|
|
from distutils.spawn import spawn
|
|
|
|
from distutils import log
|
2010-07-22 09:50:05 -03:00
|
|
|
|
2020-05-20 11:37:25 -03:00
|
|
|
|
|
|
|
# PyPI Warehouse supports MD5, SHA256, and Blake2 (blake2-256)
|
|
|
|
# https://bugs.python.org/issue40698
|
|
|
|
_FILE_CONTENT_DIGESTS = {
|
|
|
|
"md5_digest": getattr(hashlib, "md5", None),
|
|
|
|
"sha256_digest": getattr(hashlib, "sha256", None),
|
|
|
|
"blake2_256_digest": getattr(hashlib, "blake2b", None),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
class upload(PyPIRCCommand):
|
2005-03-21 17:00:59 -04:00
|
|
|
|
|
|
|
description = "upload binary package to PyPI"
|
|
|
|
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
user_options = PyPIRCCommand.user_options + [
|
2005-03-22 11:51:14 -04:00
|
|
|
('sign', 's',
|
|
|
|
'sign files to upload using gpg'),
|
2006-04-21 07:40:58 -03:00
|
|
|
('identity=', 'i', 'GPG identity used to sign files'),
|
2005-03-21 17:00:59 -04:00
|
|
|
]
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
|
|
|
|
boolean_options = PyPIRCCommand.boolean_options + ['sign']
|
2005-03-21 17:00:59 -04:00
|
|
|
|
|
|
|
def initialize_options(self):
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
PyPIRCCommand.initialize_options(self)
|
2005-03-21 17:00:59 -04:00
|
|
|
self.username = ''
|
|
|
|
self.password = ''
|
|
|
|
self.show_response = 0
|
2005-03-22 11:51:14 -04:00
|
|
|
self.sign = False
|
2006-04-21 07:40:58 -03:00
|
|
|
self.identity = None
|
2005-03-21 17:00:59 -04:00
|
|
|
|
|
|
|
def finalize_options(self):
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
PyPIRCCommand.finalize_options(self)
|
2006-04-21 07:40:58 -03:00
|
|
|
if self.identity and not self.sign:
|
|
|
|
raise DistutilsOptionError(
|
|
|
|
"Must use --sign for --identity to have meaning"
|
|
|
|
)
|
Merged revisions 62998-63003,63005-63006,63009-63012,63014-63017,63019-63020,63022-63024,63026-63029,63031-63041,63043-63045,63047-63054,63056-63062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62998 | andrew.kuchling | 2008-05-10 15:51:55 -0400 (Sat, 10 May 2008) | 7 lines
#1858 from Tarek Ziade:
Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
for discussion.
The patch is slightly revised from Tarek's last patch: I've simplified
the PyPIRCCommand.finalize_options() method to not look at sys.argv.
Tests still pass.
........
r63000 | alexandre.vassalotti | 2008-05-10 15:59:16 -0400 (Sat, 10 May 2008) | 5 lines
Cleaned up io._BytesIO.write().
I am amazed that the old code, for inserting null-bytes, actually
worked. Who wrote that thing? Oh, it is me... doh.
........
r63002 | brett.cannon | 2008-05-10 16:52:01 -0400 (Sat, 10 May 2008) | 2 lines
Revert r62998 as it broke the build (seems distutils.config is missing).
........
r63014 | andrew.kuchling | 2008-05-10 18:12:38 -0400 (Sat, 10 May 2008) | 1 line
#1858: add distutils.config module
........
r63027 | brett.cannon | 2008-05-10 21:09:32 -0400 (Sat, 10 May 2008) | 2 lines
Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
r63028 | skip.montanaro | 2008-05-10 22:59:30 -0400 (Sat, 10 May 2008) | 4 lines
Copied two versions of the example from the interactive session. Delete
one.
........
r63037 | georg.brandl | 2008-05-11 03:02:17 -0400 (Sun, 11 May 2008) | 2 lines
reload() takes the module itself.
........
r63038 | alexandre.vassalotti | 2008-05-11 03:06:04 -0400 (Sun, 11 May 2008) | 4 lines
Added test framework for handling module renames.
Factored the import guard in test_py3kwarn.TestStdlibRemovals into
a context manager, namely test_support.CleanImport.
........
r63039 | georg.brandl | 2008-05-11 03:06:05 -0400 (Sun, 11 May 2008) | 2 lines
#2742: ``''`` is not converted to NULL in getaddrinfo.
........
r63040 | alexandre.vassalotti | 2008-05-11 03:08:12 -0400 (Sun, 11 May 2008) | 2 lines
Fixed typo in a comment of test_support.CleanImport.
........
r63041 | alexandre.vassalotti | 2008-05-11 03:10:25 -0400 (Sun, 11 May 2008) | 2 lines
Removed a dead line of code.
........
r63043 | georg.brandl | 2008-05-11 04:47:53 -0400 (Sun, 11 May 2008) | 2 lines
#2812: document property.getter/setter/deleter.
........
r63049 | georg.brandl | 2008-05-11 05:06:30 -0400 (Sun, 11 May 2008) | 2 lines
#1153769: document PEP 237 changes to string formatting.
........
r63050 | georg.brandl | 2008-05-11 05:11:40 -0400 (Sun, 11 May 2008) | 2 lines
#2809: elaborate str.split docstring a bit.
........
r63051 | georg.brandl | 2008-05-11 06:13:59 -0400 (Sun, 11 May 2008) | 2 lines
Fix typo.
........
r63052 | georg.brandl | 2008-05-11 06:33:27 -0400 (Sun, 11 May 2008) | 2 lines
#2709: clarification.
........
r63053 | georg.brandl | 2008-05-11 06:42:28 -0400 (Sun, 11 May 2008) | 2 lines
#2659: add ``break_on_hyphens`` to TextWrapper.
........
r63057 | georg.brandl | 2008-05-11 06:59:39 -0400 (Sun, 11 May 2008) | 2 lines
#2741: clarification of value range for address_family.
........
r63058 | georg.brandl | 2008-05-11 07:09:35 -0400 (Sun, 11 May 2008) | 2 lines
#2452: timeout is used for all blocking operations.
........
r63059 | andrew.kuchling | 2008-05-11 09:33:56 -0400 (Sun, 11 May 2008) | 2 lines
#1792: Improve performance of marshal.dumps() on large objects by increasing
the size of the buffer more quickly.
........
r63060 | andrew.kuchling | 2008-05-11 10:00:00 -0400 (Sun, 11 May 2008) | 1 line
#1858: re-apply patch for this, adding the missing files
........
r63061 | benjamin.peterson | 2008-05-11 10:13:25 -0400 (Sun, 11 May 2008) | 2 lines
Add the "until" command to pdb
........
r63062 | georg.brandl | 2008-05-11 10:17:13 -0400 (Sun, 11 May 2008) | 2 lines
Add some sentence endings.
........
2008-05-15 21:03:33 -03:00
|
|
|
config = self._read_pypirc()
|
|
|
|
if config != {}:
|
|
|
|
self.username = config['username']
|
|
|
|
self.password = config['password']
|
|
|
|
self.repository = config['repository']
|
|
|
|
self.realm = config['realm']
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2009-01-08 20:15:45 -04:00
|
|
|
# getting the password from the distribution
|
|
|
|
# if previously set by the register command
|
|
|
|
if not self.password and self.distribution.password:
|
|
|
|
self.password = self.distribution.password
|
|
|
|
|
2005-03-21 17:00:59 -04:00
|
|
|
def run(self):
|
|
|
|
if not self.distribution.dist_files:
|
2018-02-18 19:14:54 -04:00
|
|
|
msg = ("Must create and upload files in one command "
|
|
|
|
"(e.g. setup.py sdist upload)")
|
2014-05-10 14:24:58 -03:00
|
|
|
raise DistutilsOptionError(msg)
|
2005-03-23 14:54:36 -04:00
|
|
|
for command, pyversion, filename in self.distribution.dist_files:
|
|
|
|
self.upload_file(command, pyversion, filename)
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2005-03-23 14:54:36 -04:00
|
|
|
def upload_file(self, command, pyversion, filename):
|
2013-11-10 19:50:10 -04:00
|
|
|
# Makes sure the repository URL is compliant
|
|
|
|
schema, netloc, url, params, query, fragments = \
|
|
|
|
urlparse(self.repository)
|
|
|
|
if params or query or fragments:
|
|
|
|
raise AssertionError("Incompatible url %s" % self.repository)
|
|
|
|
|
|
|
|
if schema not in ('http', 'https'):
|
|
|
|
raise AssertionError("unsupported schema " + schema)
|
|
|
|
|
2005-03-22 11:51:14 -04:00
|
|
|
# Sign if requested
|
|
|
|
if self.sign:
|
2006-04-21 07:40:58 -03:00
|
|
|
gpg_args = ["gpg", "--detach-sign", "-a", filename]
|
|
|
|
if self.identity:
|
|
|
|
gpg_args[2:2] = ["--local-user", self.identity]
|
|
|
|
spawn(gpg_args,
|
2005-03-22 11:51:14 -04:00
|
|
|
dry_run=self.dry_run)
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2006-01-08 06:48:54 -04:00
|
|
|
# Fill in the data - send all the meta-data in case we need to
|
|
|
|
# register a new release
|
2010-11-05 20:51:56 -03:00
|
|
|
f = open(filename,'rb')
|
|
|
|
try:
|
|
|
|
content = f.read()
|
|
|
|
finally:
|
|
|
|
f.close()
|
2020-05-20 11:37:25 -03:00
|
|
|
|
2006-01-08 06:48:54 -04:00
|
|
|
meta = self.distribution.metadata
|
2005-03-21 17:00:59 -04:00
|
|
|
data = {
|
2006-01-08 06:48:54 -04:00
|
|
|
# action
|
|
|
|
':action': 'file_upload',
|
2016-06-18 15:42:37 -03:00
|
|
|
'protocol_version': '1',
|
2006-01-08 06:48:54 -04:00
|
|
|
|
|
|
|
# identify release
|
|
|
|
'name': meta.get_name(),
|
|
|
|
'version': meta.get_version(),
|
|
|
|
|
|
|
|
# file content
|
|
|
|
'content': (os.path.basename(filename),content),
|
|
|
|
'filetype': command,
|
|
|
|
'pyversion': pyversion,
|
|
|
|
|
|
|
|
# additional meta-data
|
2014-05-10 14:20:28 -03:00
|
|
|
'metadata_version': '1.0',
|
2006-01-08 06:48:54 -04:00
|
|
|
'summary': meta.get_description(),
|
|
|
|
'home_page': meta.get_url(),
|
|
|
|
'author': meta.get_contact(),
|
|
|
|
'author_email': meta.get_contact_email(),
|
|
|
|
'license': meta.get_licence(),
|
|
|
|
'description': meta.get_long_description(),
|
|
|
|
'keywords': meta.get_keywords(),
|
|
|
|
'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(),
|
2005-03-21 17:00:59 -04:00
|
|
|
}
|
2018-12-17 03:59:02 -04:00
|
|
|
|
|
|
|
data['comment'] = ''
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2020-05-20 11:37:25 -03:00
|
|
|
# file content digests
|
|
|
|
for digest_name, digest_cons in _FILE_CONTENT_DIGESTS.items():
|
|
|
|
if digest_cons is None:
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
data[digest_name] = digest_cons(content).hexdigest()
|
|
|
|
except ValueError:
|
|
|
|
# hash digest not available or blocked by security policy
|
|
|
|
pass
|
|
|
|
|
2005-03-22 11:51:14 -04:00
|
|
|
if self.sign:
|
2019-04-08 10:08:48 -03:00
|
|
|
with open(filename + ".asc", "rb") as f:
|
|
|
|
data['gpg_signature'] = (os.path.basename(filename) + ".asc",
|
|
|
|
f.read())
|
2005-03-22 11:51:14 -04:00
|
|
|
|
2005-03-21 17:00:59 -04:00
|
|
|
# set up the authentication
|
2008-11-20 19:53:46 -04:00
|
|
|
user_pass = (self.username + ":" + self.password).encode('ascii')
|
|
|
|
# The exact encoding of the authentication string is debated.
|
|
|
|
# Anyway PyPI only accepts ascii for both username or password.
|
2009-12-20 20:02:20 -04:00
|
|
|
auth = "Basic " + standard_b64encode(user_pass).decode('ascii')
|
2005-03-21 17:00:59 -04:00
|
|
|
|
|
|
|
# Build up the MIME payload for the POST data
|
|
|
|
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
|
2014-09-27 17:56:15 -03:00
|
|
|
sep_boundary = b'\r\n--' + boundary.encode('ascii')
|
|
|
|
end_boundary = sep_boundary + b'--\r\n'
|
2008-11-20 19:53:46 -04:00
|
|
|
body = io.BytesIO()
|
2005-03-21 17:00:59 -04:00
|
|
|
for key, value in data.items():
|
2014-09-27 17:56:15 -03:00
|
|
|
title = '\r\nContent-Disposition: form-data; name="%s"' % key
|
2005-03-21 17:00:59 -04:00
|
|
|
# handle multiple entries for the same name
|
2014-05-10 14:24:18 -03:00
|
|
|
if not isinstance(value, list):
|
2005-03-21 17:00:59 -04:00
|
|
|
value = [value]
|
|
|
|
for value in value:
|
2010-07-22 09:50:05 -03:00
|
|
|
if type(value) is tuple:
|
2008-11-20 19:53:46 -04:00
|
|
|
title += '; filename="%s"' % value[0]
|
2005-03-21 17:00:59 -04:00
|
|
|
value = value[1]
|
|
|
|
else:
|
2008-11-20 19:53:46 -04:00
|
|
|
value = str(value).encode('utf-8')
|
2005-03-21 17:00:59 -04:00
|
|
|
body.write(sep_boundary)
|
2008-11-20 19:53:46 -04:00
|
|
|
body.write(title.encode('utf-8'))
|
2014-09-27 17:56:15 -03:00
|
|
|
body.write(b"\r\n\r\n")
|
2005-03-21 17:00:59 -04:00
|
|
|
body.write(value)
|
|
|
|
body.write(end_boundary)
|
|
|
|
body = body.getvalue()
|
|
|
|
|
2014-05-10 14:20:28 -03:00
|
|
|
msg = "Submitting %s to %s" % (filename, self.repository)
|
|
|
|
self.announce(msg, log.INFO)
|
2005-03-21 17:00:59 -04:00
|
|
|
|
|
|
|
# build the Request
|
2014-05-10 14:20:28 -03:00
|
|
|
headers = {
|
|
|
|
'Content-type': 'multipart/form-data; boundary=%s' % boundary,
|
|
|
|
'Content-length': str(len(body)),
|
|
|
|
'Authorization': auth,
|
|
|
|
}
|
2013-11-10 19:50:10 -04:00
|
|
|
|
|
|
|
request = Request(self.repository, data=body,
|
|
|
|
headers=headers)
|
|
|
|
# send the data
|
2005-03-21 17:00:59 -04:00
|
|
|
try:
|
2013-11-10 19:50:10 -04:00
|
|
|
result = urlopen(request)
|
|
|
|
status = result.getcode()
|
|
|
|
reason = result.msg
|
|
|
|
except HTTPError as e:
|
|
|
|
status = e.code
|
|
|
|
reason = e.msg
|
2016-06-02 17:45:53 -03:00
|
|
|
except OSError as e:
|
|
|
|
self.announce(str(e), log.ERROR)
|
|
|
|
raise
|
2005-03-21 17:00:59 -04:00
|
|
|
|
2013-11-10 19:50:10 -04:00
|
|
|
if status == 200:
|
|
|
|
self.announce('Server response (%s): %s' % (status, reason),
|
2005-03-21 17:00:59 -04:00
|
|
|
log.INFO)
|
2016-06-02 17:45:53 -03:00
|
|
|
if self.show_response:
|
|
|
|
text = self._read_pypi_response(result)
|
|
|
|
msg = '\n'.join(('-' * 75, text, '-' * 75))
|
|
|
|
self.announce(msg, log.INFO)
|
2005-03-21 17:00:59 -04:00
|
|
|
else:
|
2014-06-19 00:07:46 -03:00
|
|
|
msg = 'Upload failed (%s): %s' % (status, reason)
|
|
|
|
self.announce(msg, log.ERROR)
|
|
|
|
raise DistutilsError(msg)
|