Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vendor #3096

Merged
merged 13 commits into from
Oct 30, 2018
Merged
19 changes: 19 additions & 0 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
name: Pipenv Build Rules
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- docs/*
- news/*
- README.md
- pipenv/*.txt
- CHANGELOG.rst
- CONTRIBUTING.md
- CODE_OF_CONDUCT.md
- .gitignore
- .gitattributes
- .editorconfig

phases:
- template: phases/test.yml
parameters:
Expand Down
10 changes: 5 additions & 5 deletions .vsts-ci/phases/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ steps:
mkdir -p "$AGENT_HOMEDIRECTORY/.virtualenvs"
mkdir -p "$WORKON_HOME"
pip install certifi
export GIT_SSL_CAINFO=$(python -m certifi)
export LANG=C.UTF-8
export GIT_SSL_CAINFO="$(python -m certifi)"
export LANG="C.UTF-8"
export PIP_PROCESS_DEPENDENCY_LINKS="1"
echo "Path: $PATH"
echo "Path $PATH"
echo "Installing Pipenv…"
pip install -e "$(pwd)" --upgrade
pipenv install --deploy --dev
Expand All @@ -23,8 +23,8 @@ steps:

- script: |
# Fix Git SSL errors
export GIT_SSL_CAINFO=$(python -m certifi)
export LANG=C.UTF-8
export GIT_SSL_CAINFO="$(python -m certifi)"
export LANG="C.UTF-8"
export PIP_PROCESS_DEPENDENCY_LINKS="1"
pipenv run pytest --junitxml=test-results.xml
displayName: Run integration tests
Expand Down
13 changes: 8 additions & 5 deletions .vsts-ci/steps/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ steps:
# Fix Git SSL errors
pip install certifi
python -m certifi > cacert.txt
$env:GIT_SSL_CAINFO = $(Get-Content cacert.txt)
Write-Host "##vso[task.setvariable variable=GIT_SSL_CAINFO]$(Get-Content cacert.txt)"
$env:GIT_SSL_CAINFO="$(Get-Content cacert.txt)"
# Shorten paths to get under MAX_PATH or else integration tests will fail
# https://bugs.python.org/issue18199
subst T: $env:TEMP
$env:TEMP = "T:\"
$env:TMP = "T:\"
D:\.venv\Scripts\pipenv run pytest -n 4 --ignore=pipenv\patched --ignore=pipenv\vendor --junitxml=test-results.xml tests
subst T: "$env:TEMP"
Write-Host "##vso[task.setvariable variable=TEMP]T:\"
$env:TEMP='T:\'
Write-Host "##vso[task.setvariable variable=TMP]T:\"
$env:TEMP='T:\'
D:\.venv\Scripts\pipenv run pytest -ra --ignore=pipenv\patched --ignore=pipenv\vendor --junitxml=test-results.xml tests
displayName: Run integration tests

- task: PublishTestResults@2
Expand Down
19 changes: 19 additions & 0 deletions .vsts-ci/windows.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
name: Pipenv Build Rules
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- docs/*
- news/*
- README.md
- pipenv/*.txt
- CHANGELOG.rst
- CONTRIBUTING.md
- CODE_OF_CONDUCT.md
- .gitignore
- .gitattributes
- .editorconfig

phases:
- template: phases/test.yml
parameters:
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions news/3088.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug which caused ``Unexpected EOF`` errors to be thrown when PIP awaited input from users who put login credentials in their environment.
1 change: 1 addition & 0 deletions news/3089.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added windows-compatible spinner via upgraded ``vistir`` dependency.
11 changes: 11 additions & 0 deletions news/3089.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Updated vendored dependencies:
- ``certifi 2018.08.24 => 2018.10.15``
- ``urllib3 1.23 => 1.24``
- ``requests 2.19.1 => 2.20.0``
- ``shellingham ``1.2.6 => 1.2.7``
- ``tomlkit 0.4.4. => 0.4.6``
- ``vistir 0.1.6 => 0.1.8``
- ``pythonfinder 0.1.2 => 0.1.3``
- ``requirementslib 1.1.9 => 1.1.10``
- ``backports.functools_lru_cache 1.5.0 (new)``
- ``cursor 1.2.0 (new)``
1 change: 1 addition & 0 deletions news/3090.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug in ``requirementslib`` which prevented successful installation from mercurial repositories.
1 change: 1 addition & 0 deletions news/3094.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed random resource warnings when using pyenv or any other subprocess calls.
1 change: 1 addition & 0 deletions news/3102.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue in ``delegator.py`` related to subprocess calls when using ``PopenSpawn`` to stream output, which sometimes threw unexpected ``EOF`` errors.
1 change: 1 addition & 0 deletions news/3109.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed issues with broken subprocess calls leaking resource handles and causing random and sporadic failures.
1 change: 1 addition & 0 deletions news/3113.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue resolving virtualenv paths for users without ``platlib`` values on their systems.
1 change: 1 addition & 0 deletions news/3114.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue in ``delegator.py`` related to subprocess calls when using ``PopenSpawn`` to stream output, which sometimes threw unexpected ``EOF`` errors.
1 change: 1 addition & 0 deletions news/3117.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue in ``delegator.py`` related to subprocess calls when using ``PopenSpawn`` to stream output, which sometimes threw unexpected ``EOF`` errors.
1 change: 1 addition & 0 deletions news/3121.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``pythonfinder`` to correct an issue with unnesting of nested paths when searching for python versions.
1 change: 1 addition & 0 deletions news/3121.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated ``pythonfinder`` to correct an issue with unnesting of nested paths when searching for python versions.
21 changes: 20 additions & 1 deletion pipenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# -*- coding=utf-8 -*-
# |~~\' |~~
# |__/||~~\|--|/~\\ /
# | ||__/|__| |\/
# |

import os
import sys
from .__version__ import __version__
import warnings

from .__version__ import __version__

PIPENV_ROOT = os.path.dirname(os.path.realpath(__file__))
PIPENV_VENDOR = os.sep.join([PIPENV_ROOT, "vendor"])
Expand All @@ -14,12 +17,28 @@
sys.path.insert(0, PIPENV_VENDOR)
# Inject patched directory into system path.
sys.path.insert(0, PIPENV_PATCHED)

from pipenv.vendor.urllib3.exceptions import DependencyWarning
from pipenv.vendor.vistir.compat import ResourceWarning, fs_str
warnings.filterwarnings("ignore", category=DependencyWarning)
warnings.filterwarnings("ignore", category=ResourceWarning)

if sys.version_info >= (3, 1) and sys.version_info <= (3, 6):
if sys.stdout.isatty() and sys.stderr.isatty():
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf8')

os.environ["PIP_DISABLE_PIP_VERSION_CHECK"] = fs_str("1")
os.environ["PIP_SHIMS_BASE_MODULE"] = fs_str("pipenv.patched.notpip")

# Hack to make things work better.
try:
if "concurrency" in sys.modules:
del sys.modules["concurrency"]
except Exception:
pass

from .cli import cli
from . import resolver

Expand Down
93 changes: 90 additions & 3 deletions pipenv/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import six
import sys
import warnings
import vistir
from tempfile import _bin_openflags, gettempdir, _mkstemp_inner, mkdtemp
from .utils import logging, rmtree

Expand Down Expand Up @@ -59,10 +60,10 @@ def detach(self):
return False


if six.PY2:
from vistir.compat import ResourceWarning

class ResourceWarning(Warning):
pass

warnings.filterwarnings("ignore", category=ResourceWarning)


def pip_import(module_path, subimport=None, old_path=None):
Expand Down Expand Up @@ -300,3 +301,89 @@ def NamedTemporaryFile(
os.unlink(name)
os.close(fd)
raise


def getpreferredencoding():
import locale
# Borrowed from Invoke
# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)
_encoding = locale.getpreferredencoding(False)
if six.PY2 and not sys.platform == "win32":
_default_encoding = locale.getdefaultlocale()[1]
if _default_encoding is not None:
_encoding = _default_encoding
return _encoding


DEFAULT_ENCODING = getpreferredencoding()


# From https://github.com/CarlFK/veyepar/blob/5c5de47/dj/scripts/fixunicode.py
# MIT LIcensed, thanks Carl!
def force_encoding():
try:
stdout_isatty = sys.stdout.isatty
stderr_isatty = sys.stderr.isatty
except AttributeError:
return DEFAULT_ENCODING, DEFAULT_ENCODING
else:
if not (stdout_isatty() and stderr_isatty()):
return DEFAULT_ENCODING, DEFAULT_ENCODING
stdout_encoding = sys.stdout.encoding
stderr_encoding = sys.stderr.encoding
if sys.platform == "win32" and sys.version_info >= (3, 1):
return DEFAULT_ENCODING, DEFAULT_ENCODING
if stdout_encoding.lower() != "utf-8" or stderr_encoding.lower() != "utf-8":

from ctypes import pythonapi, py_object, c_char_p
try:
PyFile_SetEncoding = pythonapi.PyFile_SetEncoding
except AttributeError:
return DEFAULT_ENCODING, DEFAULT_ENCODING
else:
PyFile_SetEncoding.argtypes = (py_object, c_char_p)
if stdout_encoding.lower() != "utf-8":
try:
was_set = PyFile_SetEncoding(sys.stdout, "utf-8")
except OSError:
was_set = False
if not was_set:
stdout_encoding = DEFAULT_ENCODING
else:
stdout_encoding = "utf-8"

if stderr_encoding.lower() != "utf-8":
try:
was_set = PyFile_SetEncoding(sys.stderr, "utf-8")
except OSError:
was_set = False
if not was_set:
stderr_encoding = DEFAULT_ENCODING
else:
stderr_encoding = "utf-8"

return stdout_encoding, stderr_encoding


OUT_ENCODING, ERR_ENCODING = force_encoding()


UNICODE_TO_ASCII_TRANSLATION_MAP = {
8230: u"...",
8211: u"-"
}


def decode_output(output):
if not isinstance(output, six.string_types):
return output
try:
output = output.encode(DEFAULT_ENCODING)
except (AttributeError, UnicodeDecodeError):
if six.PY2:
output = unicode.translate(vistir.misc.to_text(output),
UNICODE_TO_ASCII_TRANSLATION_MAP)
else:
output = output.translate(UNICODE_TO_ASCII_TRANSLATION_MAP)
output = output.decode(DEFAULT_ENCODING)
return output
Loading