From 174c80947b1b4c77d6d3113496952e5817d5eef4 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Mon, 28 Sep 2015 07:47:19 -0500 Subject: [PATCH] Expand unexpanded globs earlier than before If we receive a glob that was unexpanded, we already expand that. However, we were not then updating our signatures dictionary and as such we were probably uploading packages and signatures incorrectly in that very rare case. This changes twine-upload to expand those globs much earlier in the execution so we do not miss any signature data or anything else while uploading a package. Related to #132 --- tests/test_upload.py | 3 ++- twine/commands/upload.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_upload.py b/tests/test_upload.py index b40660f8..7f995106 100644 --- a/tests/test_upload.py +++ b/tests/test_upload.py @@ -66,6 +66,7 @@ def test_find_dists_handles_real_files(): def test_get_config_old_format(tmpdir): pypirc = os.path.join(str(tmpdir), ".pypirc") + dists = ["tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"] with open(pypirc, "w") as fp: fp.write(textwrap.dedent(""" @@ -75,7 +76,7 @@ def test_get_config_old_format(tmpdir): """)) try: - upload.upload(dists="foo", repository="pypi", sign=None, identity=None, + upload.upload(dists=dists, repository="pypi", sign=None, identity=None, username=None, password=None, comment=None, sign_with=None, config_file=pypirc, skip_existing=False) except KeyError as err: diff --git a/twine/commands/upload.py b/twine/commands/upload.py index ca13fe6e..2bd4a527 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -67,11 +67,13 @@ def upload(dists, repository, sign, identity, username, password, comment, if not sign and identity: raise ValueError("sign must be given along with identity") + dists = find_dists(dists) + # Determine if the user has passed in pre-signed distributions signatures = dict( (os.path.basename(d), d) for d in dists if d.endswith(".asc") ) - dists = [i for i in dists if not i.endswith(".asc")] + uploads = [i for i in dists if not i.endswith(".asc")] config = utils.get_repository_from_config(config_file, repository) @@ -86,8 +88,6 @@ def upload(dists, repository, sign, identity, username, password, comment, repository = Repository(config["repository"], username, password) - uploads = find_dists(dists) - for filename in uploads: package = PackageFile.from_filename(filename, comment)