From 1414243c0141134830d47a188080e4e04f2ea9e4 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Sat, 5 May 2018 19:12:52 +0100 Subject: [PATCH 1/8] Retry pypi.org requests on CI, or if an environment variable is set Use PIPENV_MAX_RETRIES environment variable to determine how many times to retry requests to pypi.org. Default to 0 retries, unless running on CI, in which case default to 1 retry. --- pipenv/environments.py | 3 +++ pipenv/utils.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pipenv/environments.py b/pipenv/environments.py index f5d53a1a..3837363d 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -23,6 +23,9 @@ PIPENV_COLORBLIND = bool(os.environ.get('PIPENV_COLORBLIND')) PIPENV_NOSPIN = bool(os.environ.get('PIPENV_NOSPIN')) # Tells Pipenv how many rounds of resolving to do for Pip-Tools. PIPENV_MAX_ROUNDS = int(os.environ.get('PIPENV_MAX_ROUNDS', '16')) +# Specify how many retries Pipenv should attempt for network requests. +default_retries = '1' if 'CI' in os.environ else '0' +PIPENV_MAX_RETRIES = int(os.environ.get('PIPENV_MAX_RETRIES', default_retries)) # Specify a custom Pipfile location. PIPENV_PIPFILE = os.environ.get('PIPENV_PIPFILE') # Tells Pipenv which Python to default to, when none is provided. diff --git a/pipenv/utils.py b/pipenv/utils.py index e5a1cb87..c3d5efb1 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -45,7 +45,11 @@ except ImportError: from distutils.spawn import find_executable from contextlib import contextmanager from .pep508checker import lookup -from .environments import PIPENV_MAX_ROUNDS, PIPENV_CACHE_DIR +from .environments import ( + PIPENV_MAX_ROUNDS, + PIPENV_CACHE_DIR, + PIPENV_MAX_RETRIES +) try: from collections.abc import Mapping @@ -72,6 +76,8 @@ def _get_requests_session(): return requests_session import requests requests_session = requests.Session() + adapter = requests.adapters.HTTPAdapter(max_retries=PIPENV_MAX_RETRIES) + requests_session.mount('https://pypi.org/pypi', adapter) return requests_session From 5e41e8c6c14334bbe21429471ac0ff5cccc9600f Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Mon, 7 May 2018 15:24:49 -0400 Subject: [PATCH 2/8] Bump version, update history Signed-off-by: Dan Ryan --- HISTORY.txt | 17 +++++++++++++++++ pipenv/__version__.py | 2 +- pipenv/vendor/pip9/__main__.py | 2 +- setup.py | 5 +++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 9a9967e7..2dc0aa6b 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,3 +1,20 @@ +11.10.2: + - Backport NamedTemporaryFile for python 2. + - Implement atomic lockfile writing / rewriting. + - Allow non-interactive pyenv installations for CI. + - Bugfix regression which restricted pipfiles to two sources. + - Update default python 2.7 version to 2.7.15. + - Fix bug preventing usage within premade virtualenvs. + - Add PIPENV_DEFAULT_RETRIES environment variable to allow retrying installs. + - Fix regression with `pipenv sync` which caused it to lock if out of sync. + - Update colorblind mode to respect progress bars. + - Use `\n` to generate new lockfiles and pipfiles, default to current newlines. + - Fix bug with environment variable expansion writing back to Pipfiles when + running `pipenv install ` + - Accurately parse extras from egg fragments. + - Allow `editable=False` in pipfile. + - Fix `keep-outdated` argument for installation (previously unenforced). + - Update vendoring scripts to include licenses for vendored pip. 11.10.1: - Fix broken resolution when using multiple sources in pipfiles and passing `--skip-lock`. diff --git a/pipenv/__version__.py b/pipenv/__version__.py index 9714b0cd..875327b9 100644 --- a/pipenv/__version__.py +++ b/pipenv/__version__.py @@ -2,4 +2,4 @@ # // ) ) / / // ) ) //___) ) // ) ) || / / # //___/ / / / //___/ / // // / / || / / # // / / // ((____ // / / ||/ / -__version__ = '11.10.2.dev1' +__version__ = '11.10.2' diff --git a/pipenv/vendor/pip9/__main__.py b/pipenv/vendor/pip9/__main__.py index da041f92..9849a65c 100644 --- a/pipenv/vendor/pip9/__main__.py +++ b/pipenv/vendor/pip9/__main__.py @@ -16,4 +16,4 @@ if __package__ == '': import pip9 # noqa if __name__ == '__main__': - sys.exit(pip.main()) + sys.exit(pip9.main()) diff --git a/setup.py b/setup.py index 5954684e..5fcecb66 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ required = [ 'setuptools>=36.2.1', 'virtualenv-clone>=0.2.5', 'virtualenv', - 'pathlib2==2.1.0;python_version<"3.4"', + 'pathlib2;python_version<"3.4"', 'requests[security];python_version<"2.7"', 'ordereddict;python_version<"2.7"', ] @@ -88,7 +88,7 @@ class UploadCommand(Command): except FileNotFoundError: pass self.status('Building Source distribution…') - os.system('{0} setup.py sdist'.format(sys.executable)) + os.system('{0} setup.py sdist bdist_wheel'.format(sys.executable)) self.status('Uploading the package to PyPi via Twine…') os.system('twine upload dist/*') self.status('Pushing git tags…') @@ -114,6 +114,7 @@ setup( ] }, package_data={ + '': ['LICENSE', 'NOTICES'], "pipenv.vendor.requests": ["*.pem"], "pipenv.vendor.certifi": ["*.pem"], "pipenv.patched.notpip._vendor.certifi": ["*.pem"], From c7c8953c1e81973e45a5ff9e4a3740649cdf67dd Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Mon, 7 May 2018 22:46:38 +0100 Subject: [PATCH 3/8] Fix typo in HISTORY.txt --- HISTORY.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.txt b/HISTORY.txt index 2dc0aa6b..b6234580 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -5,7 +5,7 @@ - Bugfix regression which restricted pipfiles to two sources. - Update default python 2.7 version to 2.7.15. - Fix bug preventing usage within premade virtualenvs. - - Add PIPENV_DEFAULT_RETRIES environment variable to allow retrying installs. + - Add PIPENV_MAX_RETRIES environment variable to allow retrying installs. - Fix regression with `pipenv sync` which caused it to lock if out of sync. - Update colorblind mode to respect progress bars. - Use `\n` to generate new lockfiles and pipfiles, default to current newlines. From 0eb95ecbfc79e9e0ead59387a81ffacaf805ae98 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Mon, 7 May 2018 17:48:56 -0400 Subject: [PATCH 4/8] Drop dependency on pathlib2 Signed-off-by: Dan Ryan --- HISTORY.txt | 2 ++ pipenv/__version__.py | 2 +- pipenv/patched/pew/_utils.py | 2 +- pipenv/patched/pew/pew.py | 2 +- setup.py | 1 - tasks/vendoring/patches/patched/pew.patch | 4 ++-- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 2dc0aa6b..2b997774 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,3 +1,5 @@ +11.10.3: + - Bugfix release (break dependency on pathlib2). 11.10.2: - Backport NamedTemporaryFile for python 2. - Implement atomic lockfile writing / rewriting. diff --git a/pipenv/__version__.py b/pipenv/__version__.py index 875327b9..1a58249a 100644 --- a/pipenv/__version__.py +++ b/pipenv/__version__.py @@ -2,4 +2,4 @@ # // ) ) / / // ) ) //___) ) // ) ) || / / # //___/ / / / //___/ / // // / / || / / # // / / // ((____ // / / ||/ / -__version__ = '11.10.2' +__version__ = '11.10.3' diff --git a/pipenv/patched/pew/_utils.py b/pipenv/patched/pew/_utils.py index c45c37e0..a45c227f 100644 --- a/pipenv/patched/pew/_utils.py +++ b/pipenv/patched/pew/_utils.py @@ -9,7 +9,7 @@ from functools import partial, wraps try: from pathlib import Path except ImportError: - from pathlib2 import Path + from pipenv.vendor.pathlib2 import Path from tempfile import NamedTemporaryFile as _ntf try: from shutil import which diff --git a/pipenv/patched/pew/pew.py b/pipenv/patched/pew/pew.py index 960a1263..2d3889a0 100644 --- a/pipenv/patched/pew/pew.py +++ b/pipenv/patched/pew/pew.py @@ -11,7 +11,7 @@ from subprocess import CalledProcessError try: from pathlib import Path except ImportError: - from pathlib2 import Path + from pipenv.vendor.pathlib2 import Path try: from shutil import get_terminal_size diff --git a/setup.py b/setup.py index 5fcecb66..8dc09a32 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,6 @@ required = [ 'setuptools>=36.2.1', 'virtualenv-clone>=0.2.5', 'virtualenv', - 'pathlib2;python_version<"3.4"', 'requests[security];python_version<"2.7"', 'ordereddict;python_version<"2.7"', ] diff --git a/tasks/vendoring/patches/patched/pew.patch b/tasks/vendoring/patches/patched/pew.patch index 27513fe3..e6e5f737 100644 --- a/tasks/vendoring/patches/patched/pew.patch +++ b/tasks/vendoring/patches/patched/pew.patch @@ -23,7 +23,7 @@ index d1d8e0a..c45c37e 100644 +try: + from pathlib import Path +except ImportError: -+ from pathlib2 import Path ++ from pipenv.vendor.pathlib2 import Path from tempfile import NamedTemporaryFile as _ntf try: from shutil import which @@ -39,7 +39,7 @@ index bcaabad..b8fc3e7 100644 +try: + from pathlib import Path +except ImportError: -+ from pathlib2 import Path ++ from pipenv.vendor.pathlib2 import Path try: from shutil import get_terminal_size From bc82cb8c09a70a8b7e3f2b7a9cebce1e7dfabd58 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Tue, 8 May 2018 17:52:23 +0800 Subject: [PATCH 5/8] Correct _mkstemp_inner call on Python < 3.4 --- pipenv/_compat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipenv/_compat.py b/pipenv/_compat.py index 6769d8d4..14326813 100644 --- a/pipenv/_compat.py +++ b/pipenv/_compat.py @@ -8,6 +8,7 @@ import functools import io import os import six +import sys import warnings from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp from .utils import (logging, rmtree) @@ -257,7 +258,7 @@ def NamedTemporaryFile( # the file when it is closed. This is only supported by Windows. if os.name == "nt" and delete: flags |= os.O_TEMPORARY - if six.PY2: + if sys.version_info < (3, 5): (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags) else: (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type) From c2352029dce5b886b604ed8a41a8cced8c6886ca Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 9 May 2018 02:26:10 +0800 Subject: [PATCH 6/8] Add a message to talk the user away from reporting --- pipenv/core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pipenv/core.py b/pipenv/core.py index 79357ce5..4d1b559d 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2012,6 +2012,14 @@ def do_install( err=True, ) click.echo(crayons.blue(format_pip_error(c.err)), err=True) + if 'setup.py egg_info' in c.err: + click.echo( + "This is likely caused by a bug in {0}. " + "Report this to its maintainers.".format( + crayons.green(package_name), + ), + err=True, + ) requirements_directory.cleanup() sys.exit(1) click.echo( From 8c171e943ebbde16a8cc009c002689f2368c0ce3 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 8 May 2018 16:57:37 -0400 Subject: [PATCH 7/8] Version bump for bugfix release Signed-off-by: Dan Ryan --- HISTORY.txt | 2 ++ pipenv/__version__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HISTORY.txt b/HISTORY.txt index 43e9280f..7382a8e4 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,3 +1,5 @@ +11.10.4: + - Bugfix release (_mkstmp_inner backport breaks python3.4/3.5 compat) 11.10.3: - Bugfix release (break dependency on pathlib2). 11.10.2: diff --git a/pipenv/__version__.py b/pipenv/__version__.py index 1a58249a..ca48c4bd 100644 --- a/pipenv/__version__.py +++ b/pipenv/__version__.py @@ -2,4 +2,4 @@ # // ) ) / / // ) ) //___) ) // ) ) || / / # //___/ / / / //___/ / // // / / || / / # // / / // ((____ // / / ||/ / -__version__ = '11.10.3' +__version__ = '11.10.4' From 55e4eb07c716052503ba45c378fd2c0fcf2f99e8 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 8 May 2018 23:54:25 -0400 Subject: [PATCH 8/8] Expand short paths on windows during testing - Fixes #2132 Signed-off-by: Dan Ryan --- tests/integration/conftest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 3a07d145..66ce8be7 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -10,6 +10,11 @@ from pipenv.vendor import requests from pipenv.vendor import six from pipenv.vendor import toml +try: + from pathlib import Path +except ImportError: + from pipenv.vendor.pathlib2 import Path + if six.PY2: class ResourceWarning(Warning): @@ -45,7 +50,7 @@ class _PipenvInstance(object): self.original_umask = os.umask(0o007) self.original_dir = os.path.abspath(os.curdir) self._path = TemporaryDirectory(suffix='-project', prefix='pipenv-') - self.path = self._path.name + self.path = str(Path(self._path.name).resolve()) # set file creation perms self.pipfile_path = None self.chdir = chdir