commit python3-twine for openSUSE:Factory
Hello community, here is the log from the commit of package python3-twine for openSUSE:Factory checked in at 2016-08-31 14:31:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-twine (Old) and /work/SRC/openSUSE:Factory/.python3-twine.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python3-twine" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-twine/python3-twine.changes 2016-07-15 12:51:11.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python3-twine.new/python3-twine.changes 2016-08-31 14:31:48.000000000 +0200 @@ -1,0 +2,25 @@ +Wed Aug 31 03:32:31 UTC 2016 - arun@gmx.de + +- update to version 1.8.1: + * Check if a package exists for several download urls + +- changes from version 1.8.0: + * :feature:`201` Switch from upload.pypi.io to upload.pypi.org. + * :feature:`144` Retrieve configuration from the environment as a + default. + + Repository URL will default to TWINE_REPOSITORY + + Username will default to TWINE_USERNAME + + Password will default to TWINE_PASSWORD + * :feature:`166` Allow the Repository URL to be provided on the + command-line (--repository-url) or via an environment variable + (TWINE_REPOSITORY_URL). + * Generate SHA256 digest for all packages by default. + * :feature:`171` Generate Blake2b 256 digests for packages if + pyblake2 is installed. Users can use python -m pip install + twine[with-blake2] to have pyblake2 installed with Twine. + * Stop testing on Python 2.6. 2.6 support will be "best effort" + until 2.0.0 + * Warn users if they receive a 500 error when uploading to + *pypi.python.org + +------------------------------------------------------------------- Old: ---- twine-1.7.4.tar.gz New: ---- twine-1.8.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-twine.spec ++++++ --- /var/tmp/diff_new_pack.vwdi6z/_old 2016-08-31 14:31:49.000000000 +0200 +++ /var/tmp/diff_new_pack.vwdi6z/_new 2016-08-31 14:31:49.000000000 +0200 @@ -17,7 +17,7 @@ Name: python3-twine -Version: 1.7.4 +Version: 1.8.1 Release: 0 Summary: Collection of utilities for interacting with PyPI License: Apache-2.0 ++++++ twine-1.7.4.tar.gz -> twine-1.8.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/PKG-INFO new/twine-1.8.1/PKG-INFO --- old/twine-1.7.4/PKG-INFO 2016-07-09 13:22:23.000000000 +0200 +++ new/twine-1.8.1/PKG-INFO 2016-08-08 17:02:29.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: twine -Version: 1.7.4 +Version: 1.8.1 Summary: Collection of utilities for interacting with PyPI Home-page: https://github.com/pypa/twine Author: Donald Stufft and individual contributors @@ -172,7 +172,6 @@ Classifier: Operating System :: Microsoft :: Windows Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/docs/changelog.rst new/twine-1.8.1/docs/changelog.rst --- old/twine-1.7.4/docs/changelog.rst 2016-07-09 13:21:25.000000000 +0200 +++ new/twine-1.8.1/docs/changelog.rst 2016-08-08 17:01:12.000000000 +0200 @@ -4,6 +4,43 @@ Changelog ========= +* :release:`1.8.1 <2016-08-09>` + + * Check if a package exists if the URL is one of: + + - ``https://pypi.python.org/pypi/`` + - ``https://upload.pypi.org/`` + - ``https://upload.pypi.io/`` + + This helps people with ``https://upload.pypi.io`` still in their .pypirc + file. + +* :release:`1.8.0 <2016-08-08>` + + * :feature:`201` Switch from upload.pypi.io to upload.pypi.org. + + * :feature:`144` Retrieve configuration from the environment as a default. + + - Repository URL will default to ``TWINE_REPOSITORY`` + + - Username will default to ``TWINE_USERNAME`` + + - Password will default to ``TWINE_PASSWORD`` + + * :feature:`166` Allow the Repository URL to be provided on the command-line + (``--repository-url``) or via an environment variable + (``TWINE_REPOSITORY_URL``). + + * Generate SHA256 digest for all packages by default. + + * :feature:`171` Generate Blake2b 256 digests for packages *if* ``pyblake2`` + is installed. Users can use ``python -m pip install twine[with-blake2]`` + to have ``pyblake2`` installed with Twine. + + * Stop testing on Python 2.6. 2.6 support will be "best effort" until 2.0.0 + + * Warn users if they receive a 500 error when uploading to \*pypi.python.org + * :release:`1.7.4 <2016-07-09>` * Correct a packaging error. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/setup.cfg new/twine-1.8.1/setup.cfg --- old/twine-1.7.4/setup.cfg 2016-07-09 13:22:23.000000000 +0200 +++ new/twine-1.8.1/setup.cfg 2016-08-08 17:02:29.000000000 +0200 @@ -14,6 +14,7 @@ pkginfo >= 1.0 setuptools >= 0.7.0 argparse; python_version == '2.6' + pyblake2; extra == 'with-blake2' [egg_info] tag_build = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/setup.py new/twine-1.8.1/setup.py --- old/twine-1.7.4/setup.py 2016-06-15 03:16:21.000000000 +0200 +++ new/twine-1.8.1/setup.py 2016-08-08 17:01:12.000000000 +0200 @@ -55,7 +55,6 @@ "Operating System :: Microsoft :: Windows", "Programming Language :: Python", "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", @@ -79,4 +78,9 @@ }, install_requires=install_requires, + extras_require={ + 'with-blake2': [ + 'pyblake2', + ] + }, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/tests/helpers.py new/twine-1.8.1/tests/helpers.py --- old/twine-1.7.4/tests/helpers.py 1970-01-01 01:00:00.000000000 +0100 +++ new/twine-1.8.1/tests/helpers.py 2016-08-08 17:01:12.000000000 +0200 @@ -0,0 +1,40 @@ +# Copyright 2016 Ian Cordasco +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Test functions useful across twine's tests.""" + +import contextlib +import os + + +@contextlib.contextmanager +def set_env(**environ): + """Set the process environment variables temporarily. + + >>> with set_env(PLUGINS_DIR=u'test/plugins'): + ... "PLUGINS_DIR" in os.environ + True + + >>> "PLUGINS_DIR" in os.environ + False + + :param environ: Environment variables to set + :type environ: dict[str, unicode] + """ + old_environ = dict(os.environ) + os.environ.update(environ) + try: + yield + finally: + os.environ.clear() + os.environ.update(old_environ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/tests/test_upload.py new/twine-1.8.1/tests/test_upload.py --- old/twine-1.7.4/tests/test_upload.py 2016-06-15 03:16:21.000000000 +0200 +++ new/twine-1.8.1/tests/test_upload.py 2016-08-08 17:01:12.000000000 +0200 @@ -20,8 +20,10 @@ import pytest from twine.commands import upload -from twine import package +from twine import package, cli +import twine +import helpers WHEEL_FIXTURE = 'tests/fixtures/twine-1.5.0-py2.py3-none-any.whl' @@ -48,7 +50,8 @@ def test_find_dists_expands_globs(): files = sorted(upload.find_dists(['twine/__*.py'])) - expected = ['twine/__init__.py', 'twine/__main__.py'] + expected = [os.path.join('twine', '__init__.py'), + os.path.join('twine', '__main__.py')] assert expected == files @@ -79,10 +82,13 @@ upload.upload(dists=dists, repository="pypi", sign=None, identity=None, username=None, password=None, comment=None, cert=None, client_cert=None, - sign_with=None, config_file=pypirc, skip_existing=False) + sign_with=None, config_file=pypirc, skip_existing=False, + repository_url=None, + ) except KeyError as err: assert err.args[0] == ( - "Missing 'pypi' section from the configuration file.\n" + "Missing 'pypi' section from the configuration file\n" + "or not a complete URL in --repository.\n" "Maybe you have a out-dated '{0}' format?\n" "more info: " "https://docs.python.org/distutils/packageindex.html#pypirc\n" @@ -124,3 +130,22 @@ assert upload.skip_upload(response=response, skip_existing=False, package=pkg) is False + + +def test_password_and_username_from_env(monkeypatch): + def none_upload(*args, **kwargs): + pass + + replaced_upload = pretend.call_recorder(none_upload) + monkeypatch.setattr(twine.commands.upload, "upload", replaced_upload) + testenv = {"TWINE_USERNAME": "pypiuser", + "TWINE_PASSWORD": "pypipassword"} + with helpers.set_env(**testenv): + cli.dispatch(["upload", "path/to/file"]) + cli.dispatch(["upload", "path/to/file"]) + result_kwargs = replaced_upload.calls[0].kwargs + assert "pypipassword" == result_kwargs["password"] + assert "pypiuser" == result_kwargs["username"] + result_kwargs = replaced_upload.calls[1].kwargs + assert None is result_kwargs["password"] + assert None is result_kwargs["username"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/tests/test_utils.py new/twine-1.8.1/tests/test_utils.py --- old/twine-1.7.4/tests/test_utils.py 2014-12-21 21:11:38.000000000 +0100 +++ new/twine-1.8.1/tests/test_utils.py 2016-08-08 17:01:12.000000000 +0200 @@ -16,9 +16,12 @@ import os.path import textwrap + import pytest -from twine.utils import DEFAULT_REPOSITORY, get_config, get_userpass_value +from twine import utils + +import helpers def test_get_config(tmpdir): @@ -34,9 +37,9 @@ password = testpassword """)) - assert get_config(pypirc) == { + assert utils.get_config(pypirc) == { "pypi": { - "repository": DEFAULT_REPOSITORY, + "repository": utils.DEFAULT_REPOSITORY, "username": "testuser", "password": "testpassword", }, @@ -53,9 +56,9 @@ password = testpassword """)) - assert get_config(pypirc) == { + assert utils.get_config(pypirc) == { "pypi": { - "repository": DEFAULT_REPOSITORY, + "repository": utils.DEFAULT_REPOSITORY, "username": "testuser", "password": "testpassword", }, @@ -75,9 +78,9 @@ password = testpassword """)) - assert get_config(pypirc) == { + assert utils.get_config(pypirc) == { "pypi": { - "repository": DEFAULT_REPOSITORY, + "repository": utils.DEFAULT_REPOSITORY, "username": "testuser", "password": "testpassword", }, @@ -87,23 +90,47 @@ def test_get_config_missing(tmpdir): pypirc = os.path.join(str(tmpdir), ".pypirc") - assert get_config(pypirc) == { + assert utils.get_config(pypirc) == { "pypi": { - "repository": DEFAULT_REPOSITORY, + "repository": utils.DEFAULT_REPOSITORY, "username": None, "password": None, }, + "pypitest": { + "repository": utils.TEST_REPOSITORY, + "username": None, + "password": None + }, } +def test_get_repository_config_missing(tmpdir): + pypirc = os.path.join(str(tmpdir), ".pypirc") + + repository_url = "https://notexisting.python.org/pypi" + exp = { + "repository": repository_url, + "username": None, + "password": None, + } + assert (utils.get_repository_from_config(pypirc, 'foo', repository_url) == + exp) + exp = { + "repository": utils.DEFAULT_REPOSITORY, + "username": None, + "password": None, + } + assert utils.get_repository_from_config(pypirc, "pypi") == exp + + def test_get_config_deprecated_pypirc(): tests_dir = os.path.dirname(os.path.abspath(__file__)) deprecated_pypirc_path = os.path.join(tests_dir, 'fixtures', 'deprecated-pypirc') - assert get_config(deprecated_pypirc_path) == { + assert utils.get_config(deprecated_pypirc_path) == { "pypi": { - "repository": DEFAULT_REPOSITORY, + "repository": utils.DEFAULT_REPOSITORY, "username": 'testusername', "password": 'testpassword', }, @@ -119,5 +146,29 @@ ), ) def test_get_userpass_value(cli_value, config, key, strategy, expected): - ret = get_userpass_value(cli_value, config, key, strategy) + ret = utils.get_userpass_value(cli_value, config, key, strategy) assert ret == expected + + +@pytest.mark.parametrize( + ('env_name', 'default', 'environ', 'expected'), + [ + ('MY_PASSWORD', None, {}, None), + ('MY_PASSWORD', None, {'MY_PASSWORD': 'foo'}, 'foo'), + ('URL', 'https://example.org', {}, 'https://example.org'), + ('URL', 'https://example.org', {'URL': 'https://pypi.org'}, + 'https://pypi.org'), + ], +) +def test_default_to_environment_action(env_name, default, environ, expected): + option_strings = ('-x', '--example') + dest = 'example' + with helpers.set_env(**environ): + action = utils.EnvironmentDefault( + env=env_name, + default=default, + option_strings=option_strings, + dest=dest, + ) + assert action.env == env_name + assert action.default == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/__init__.py new/twine-1.8.1/twine/__init__.py --- old/twine-1.7.4/twine/__init__.py 2016-07-09 13:21:34.000000000 +0200 +++ new/twine-1.8.1/twine/__init__.py 2016-08-08 17:01:12.000000000 +0200 @@ -23,7 +23,7 @@ __summary__ = "Collection of utilities for interacting with PyPI" __uri__ = "https://github.com/pypa/twine" -__version__ = "1.7.4" +__version__ = "1.8.1" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/commands/register.py new/twine-1.8.1/twine/commands/register.py --- old/twine-1.7.4/twine/commands/register.py 2015-12-17 00:37:02.000000000 +0100 +++ new/twine-1.8.1/twine/commands/register.py 2016-08-08 17:01:12.000000000 +0200 @@ -24,8 +24,12 @@ def register(package, repository, username, password, comment, config_file, - cert, client_cert): - config = utils.get_repository_from_config(config_file, repository) + cert, client_cert, repository_url): + config = utils.get_repository_from_config( + config_file, + repository, + repository_url, + ) config["repository"] = utils.normalize_repository_url( config["repository"] ) @@ -62,17 +66,38 @@ parser = argparse.ArgumentParser(prog="twine register") parser.add_argument( "-r", "--repository", + action=utils.EnvironmentDefault, + env="TWINE_REPOSITORY", default="pypi", - help="The repository to register the package to (default: " + help="The repository to register the package to. Can be a section in " + "the config file or a full URL to the repository (default: " "%(default)s)", ) parser.add_argument( + "--repository-url", + action=utils.EnvironmentDefault, + env="TWINE_REPOSITORY_URL", + default=None, + required=False, + help="The repository URL to upload the package to. This can be " + "specified with --repository because it will be used if there is " + "no configuration for the value passed to --repository." + ) + parser.add_argument( "-u", "--username", - help="The username to authenticate to the repository as", + action=utils.EnvironmentDefault, + env="TWINE_USERNAME", + required=False, help="The username to authenticate to the repository " + "as (can also be set via %(env)s environment " + "variable)", ) parser.add_argument( "-p", "--password", - help="The password to authenticate to the repository with", + action=utils.EnvironmentDefault, + env="TWINE_PASSWORD", + required=False, help="The password to authenticate to the repository " + "with (can also be set via %(env)s environment " + "variable)", ) parser.add_argument( "-c", "--comment", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/commands/upload.py new/twine-1.8.1/twine/commands/upload.py --- old/twine-1.7.4/twine/commands/upload.py 2016-07-09 13:20:09.000000000 +0200 +++ new/twine-1.8.1/twine/commands/upload.py 2016-08-08 17:01:12.000000000 +0200 @@ -72,7 +72,8 @@ def upload(dists, repository, sign, identity, username, password, comment, - sign_with, config_file, skip_existing, cert, client_cert): + sign_with, config_file, skip_existing, cert, client_cert, + repository_url): # Check that a nonsensical option wasn't given if not sign and identity: raise ValueError("sign must be given along with identity") @@ -85,7 +86,11 @@ ) uploads = [i for i in dists if not i.endswith(".asc")] - config = utils.get_repository_from_config(config_file, repository) + config = utils.get_repository_from_config( + config_file, + repository, + repository_url, + ) config["repository"] = utils.normalize_repository_url( config["repository"] @@ -138,7 +143,7 @@ print(skip_message) continue - resp.raise_for_status() + utils.check_status_code(resp) # Bug 28. Try to silence a ResourceWarning by clearing the connection # pool. @@ -149,8 +154,22 @@ parser = argparse.ArgumentParser(prog="twine upload") parser.add_argument( "-r", "--repository", + action=utils.EnvironmentDefault, + env="TWINE_REPOSITORY", default="pypi", - help="The repository to upload the files to (default: %(default)s)", + help="The repository to register the package to. Can be a section in " + "the config file or a full URL to the repository (default: " + "%(default)s)", + ) + parser.add_argument( + "--repository-url", + action=utils.EnvironmentDefault, + env="TWINE_REPOSITORY_URL", + default=None, + required=False, + help="The repository URL to upload the package to. This can be " + "specified with --repository because it will be used if there is " + "no configuration for the value passed to --repository." ) parser.add_argument( "-s", "--sign", @@ -169,11 +188,19 @@ ) parser.add_argument( "-u", "--username", - help="The username to authenticate to the repository as", + action=utils.EnvironmentDefault, + env="TWINE_USERNAME", + required=False, help="The username to authenticate to the repository " + "as (can also be set via %(env)s environment " + "variable)", ) parser.add_argument( "-p", "--password", - help="The password to authenticate to the repository with", + action=utils.EnvironmentDefault, + env="TWINE_PASSWORD", + required=False, help="The password to authenticate to the repository " + "with (can also be set via %(env)s environment " + "variable)", ) parser.add_argument( "-c", "--comment", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/package.py new/twine-1.8.1/twine/package.py --- old/twine-1.7.4/twine/package.py 2016-02-05 00:23:50.000000000 +0100 +++ new/twine-1.8.1/twine/package.py 2016-08-08 17:01:12.000000000 +0200 @@ -13,12 +13,18 @@ # limitations under the License. from __future__ import absolute_import, unicode_literals, print_function import hashlib +import io import os import subprocess import pkginfo import pkg_resources +try: + import pyblake2 +except ImportError: + pyblake2 = None + from twine.wheel import Wheel from twine.wininst import WinInst @@ -52,17 +58,24 @@ self.signed_basefilename = self.basefilename + '.asc' self.gpg_signature = None + blake2_256_hash = None + if pyblake2 is not None: + blake2_256_hash = pyblake2.blake2b(digest_size=256 // 8) + # NOTE(sigmavirus24): We may or may not be able to use blake2 so let's + # either use the methods or lambdas to do nothing. + blake_update = getattr(blake2_256_hash, 'update', lambda *args: None) + blake_hexdigest = getattr(blake2_256_hash, 'hexdigest', lambda: None) md5_hash = hashlib.md5() sha2_hash = hashlib.sha256() with open(filename, "rb") as fp: - content = fp.read(4096) - while content: + for content in iter(lambda: fp.read(io.DEFAULT_BUFFER_SIZE), b''): md5_hash.update(content) sha2_hash.update(content) - content = fp.read(4096) + blake_update(content) self.md5_digest = md5_hash.hexdigest() self.sha2_digest = sha2_hash.hexdigest() + self.blake2_256_digest = blake_hexdigest() @classmethod def from_filename(cls, filename, comment): @@ -117,11 +130,8 @@ "supported_platform": meta.supported_platforms, "comment": self.comment, "md5_digest": self.md5_digest, - - # When https://github.com/pypa/warehouse/issues/681 is closed and - # warehouse is deployed, uncomment the line below to start sending - # a more up-to-date digest. - # "sha256_digest": self.sha256_digest, + "sha256_digest": self.sha2_digest, + "blake2_256_digest": self.blake2_256_digest, # PEP 314 "provides": meta.provides, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/repository.py new/twine-1.8.1/twine/repository.py --- old/twine-1.7.4/twine/repository.py 2016-07-09 13:20:09.000000000 +0200 +++ new/twine-1.8.1/twine/repository.py 2016-08-08 17:01:12.000000000 +0200 @@ -29,7 +29,8 @@ KEYWORDS_TO_NOT_FLATTEN = set(["gpg_signature", "content"]) LEGACY_PYPI = 'https://pypi.python.org/' -WAREHOUSE = 'https://upload.pypi.io/' +WAREHOUSE = 'https://upload.pypi.org/' +OLD_WAREHOUSE = 'https://upload.pypi.io/' class Repository(object): @@ -158,7 +159,7 @@ def package_is_uploaded(self, package, bypass_cache=False): # NOTE(sigmavirus24): Not all indices are PyPI and pypi.io doesn't # have a similar interface for finding the package versions. - if not self.url.startswith((LEGACY_PYPI, WAREHOUSE)): + if not self.url.startswith((LEGACY_PYPI, WAREHOUSE, OLD_WAREHOUSE)): return False safe_name = package.safe_name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine/utils.py new/twine-1.8.1/twine/utils.py --- old/twine-1.7.4/twine/utils.py 2016-07-04 21:45:58.000000000 +0200 +++ new/twine-1.8.1/twine/utils.py 2016-08-08 17:01:12.000000000 +0200 @@ -19,6 +19,8 @@ import functools import getpass import sys +import argparse + try: import configparser @@ -37,7 +39,8 @@ input_func = raw_input -DEFAULT_REPOSITORY = "https://upload.pypi.io/legacy/" +DEFAULT_REPOSITORY = "https://upload.pypi.org/legacy/" +TEST_REPOSITORY = "https://test.pypi.org/legacy/" def get_config(path="~/.pypirc"): @@ -48,7 +51,11 @@ return {"pypi": {"repository": DEFAULT_REPOSITORY, "username": None, "password": None - } + }, + "pypitest": {"repository": TEST_REPOSITORY, + "username": None, + "password": None + }, } # Parse the rc file @@ -92,13 +99,22 @@ return config -def get_repository_from_config(config_file, repository): +def get_repository_from_config(config_file, repository, repository_url=None): # Get our config from the .pypirc file try: return get_config(config_file)[repository] except KeyError: + if repository_url and "://" in repository_url: + # assume that the repsoitory is actually an URL and just sent + # them a dummy with the repo set + return { + "repository": repository_url, + "username": None, + "password": None, + } msg = ( - "Missing '{repo}' section from the configuration file.\n" + "Missing '{repo}' section from the configuration file\n" + "or not a complete URL in --repository.\n" "Maybe you have a out-dated '{cfg}' format?\n" "more info: " "https://docs.python.org/distutils/packageindex.html#pypirc\n" @@ -109,13 +125,29 @@ raise KeyError(msg) +_HOSTNAMES = set(["pypi.python.org", "testpypi.python.org", "upload.pypi.org", + "test.pypi.org"]) + + def normalize_repository_url(url): parsed = urlparse(url) - if parsed.netloc in ["pypi.python.org", "testpypi.python.org"]: + if parsed.netloc in _HOSTNAMES: return urlunparse(("https",) + parsed[1:]) return urlunparse(parsed) +def check_status_code(response): + if (response.status_code == 500 and + response.url.startswith(("https://pypi.python.org", + "https://testpypi.python.org"))): + print("It appears you're uploading to pypi.python.org (or testpypi) " + "you've recieved a 500 error response. PyPI is being phased " + "out for pypi.org. Try using https://upload.pypi.org/legacy/ " + "(or https://test.pypi.org/legacy/) to upload your packages " + "instead. These are the default URLs for Twine now.") + response.raise_for_status() + + def get_userpass_value(cli_value, config, key, prompt_strategy=None): """Gets the username / password from config. @@ -172,3 +204,21 @@ get_userpass_value, key='client_cert', ) + + +class EnvironmentDefault(argparse.Action): + """Get values from environment variable.""" + + def __init__(self, env, required=True, default=None, **kwargs): + default = os.environ.get(env, default) + self.env = env + if default: + required = False + super(EnvironmentDefault, self).__init__( + default=default, + required=required, + **kwargs + ) + + def __call__(self, parser, namespace, values, option_string=None): + setattr(namespace, self.dest, values) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine.egg-info/PKG-INFO new/twine-1.8.1/twine.egg-info/PKG-INFO --- old/twine-1.7.4/twine.egg-info/PKG-INFO 2016-07-09 13:22:22.000000000 +0200 +++ new/twine-1.8.1/twine.egg-info/PKG-INFO 2016-08-08 17:02:28.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: twine -Version: 1.7.4 +Version: 1.8.1 Summary: Collection of utilities for interacting with PyPI Home-page: https://github.com/pypa/twine Author: Donald Stufft and individual contributors @@ -172,7 +172,6 @@ Classifier: Operating System :: Microsoft :: Windows Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine.egg-info/SOURCES.txt new/twine-1.8.1/twine.egg-info/SOURCES.txt --- old/twine-1.7.4/twine.egg-info/SOURCES.txt 2016-07-09 13:22:23.000000000 +0200 +++ new/twine-1.8.1/twine.egg-info/SOURCES.txt 2016-08-08 17:02:29.000000000 +0200 @@ -10,6 +10,7 @@ docs/index.rst docs/make.bat docs/_static/.empty +tests/helpers.py tests/test_cli.py tests/test_package.py tests/test_repository.py @@ -30,6 +31,7 @@ twine.egg-info/SOURCES.txt twine.egg-info/dependency_links.txt twine.egg-info/entry_points.txt +twine.egg-info/pbr.json twine.egg-info/requires.txt twine.egg-info/top_level.txt twine/commands/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine.egg-info/pbr.json new/twine-1.8.1/twine.egg-info/pbr.json --- old/twine-1.7.4/twine.egg-info/pbr.json 1970-01-01 01:00:00.000000000 +0100 +++ new/twine-1.8.1/twine.egg-info/pbr.json 2015-10-01 17:27:14.000000000 +0200 @@ -0,0 +1 @@ +{"is_release": true, "git_version": "5c06ed2"} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/twine-1.7.4/twine.egg-info/requires.txt new/twine-1.8.1/twine.egg-info/requires.txt --- old/twine-1.7.4/twine.egg-info/requires.txt 2016-07-09 13:22:22.000000000 +0200 +++ new/twine-1.8.1/twine.egg-info/requires.txt 2016-08-08 17:02:28.000000000 +0200 @@ -3,3 +3,6 @@ requests >= 2.5.0 requests-toolbelt >= 0.5.1 setuptools >= 0.7.0 + +[with-blake2] +pyblake2
participants (1)
-
root@hilbert.suse.de