Skip to content

Commit cb17598

Browse files
authored
Merge pull request #5522 from pypa/bump-requirementslib
More vendor bumps
2 parents 0a03b76 + bdce2e5 commit cb17598

File tree

14 files changed

+205
-613
lines changed

14 files changed

+205
-613
lines changed

news/5522.vendor.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Bump version of requirementslib to 2.2.1
2+
* Bump version of vistir to 0.7.5
3+
* Bump version of colorama to 0.4.6

pipenv/__init__.py

+16-11
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,26 @@
3838
if "urllib3" in sys.modules:
3939
del sys.modules["urllib3"]
4040

41-
from pipenv.vendor.vistir.misc import get_text_stream
42-
43-
stdout = get_text_stream("stdout")
44-
stderr = get_text_stream("stderr")
4541

4642
if os.name == "nt":
47-
from pipenv.vendor.vistir.misc import _can_use_color, _wrap_for_color
43+
from pipenv.vendor import colorama
4844

49-
if _can_use_color(stdout):
50-
stdout = _wrap_for_color(stdout)
51-
if _can_use_color(stderr):
52-
stderr = _wrap_for_color(stderr)
45+
# Backward compatability with vistir
46+
no_color = False
47+
for item in ("ANSI_COLORS_DISABLED", "VISTIR_DISABLE_COLORS", "CI"):
48+
warnings.warn(
49+
(
50+
f"Please do not use {item}, as it will be removed in future versions."
51+
"\nUse NO_COLOR instead."
52+
),
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
56+
if os.getenv(item):
57+
no_color = True
5358

54-
sys.stdout = stdout
55-
sys.stderr = stderr
59+
if not os.getenv("NO_COLOR") or no_color:
60+
colorama.just_fix_windows_console()
5661

5762
from . import resolver # noqa
5863
from .cli import cli

pipenv/vendor/colorama/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2-
from .initialise import init, deinit, reinit, colorama_text
2+
from .initialise import init, deinit, reinit, colorama_text, just_fix_windows_console
33
from .ansi import Fore, Back, Style, Cursor
44
from .ansitowin32 import AnsiToWin32
55

6-
__version__ = '0.4.4'
6+
__version__ = '0.4.6'
7+

pipenv/vendor/colorama/ansitowin32.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55

66
from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style, BEL
7-
from .winterm import WinTerm, WinColor, WinStyle
7+
from .winterm import enable_vt_processing, WinTerm, WinColor, WinStyle
88
from .win32 import windll, winapi_test
99

1010

@@ -37,6 +37,12 @@ def __enter__(self, *args, **kwargs):
3737
def __exit__(self, *args, **kwargs):
3838
return self.__wrapped.__exit__(*args, **kwargs)
3939

40+
def __setstate__(self, state):
41+
self.__dict__ = state
42+
43+
def __getstate__(self):
44+
return self.__dict__
45+
4046
def write(self, text):
4147
self.__convertor.write(text)
4248

@@ -57,7 +63,9 @@ def closed(self):
5763
stream = self.__wrapped
5864
try:
5965
return stream.closed
60-
except AttributeError:
66+
# AttributeError in the case that the stream doesn't support being closed
67+
# ValueError for the case that the stream has already been detached when atexit runs
68+
except (AttributeError, ValueError):
6169
return True
6270

6371

@@ -86,15 +94,22 @@ def __init__(self, wrapped, convert=None, strip=None, autoreset=False):
8694
# (e.g. Cygwin Terminal). In this case it's up to the terminal
8795
# to support the ANSI codes.
8896
conversion_supported = on_windows and winapi_test()
97+
try:
98+
fd = wrapped.fileno()
99+
except Exception:
100+
fd = -1
101+
system_has_native_ansi = not on_windows or enable_vt_processing(fd)
102+
have_tty = not self.stream.closed and self.stream.isatty()
103+
need_conversion = conversion_supported and not system_has_native_ansi
89104

90105
# should we strip ANSI sequences from our output?
91106
if strip is None:
92-
strip = conversion_supported or (not self.stream.closed and not self.stream.isatty())
107+
strip = need_conversion or not have_tty
93108
self.strip = strip
94109

95110
# should we should convert ANSI sequences into win32 calls?
96111
if convert is None:
97-
convert = conversion_supported and not self.stream.closed and self.stream.isatty()
112+
convert = need_conversion and have_tty
98113
self.convert = convert
99114

100115
# dict of ansi codes to win32 functions and parameters
@@ -256,3 +271,7 @@ def convert_osc(self, text):
256271
if params[0] in '02':
257272
winterm.set_title(params[1])
258273
return text
274+
275+
276+
def flush(self):
277+
self.wrapped.flush()

pipenv/vendor/colorama/initialise.py

+46-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,27 @@
66
from .ansitowin32 import AnsiToWin32
77

88

9-
orig_stdout = None
10-
orig_stderr = None
9+
def _wipe_internal_state_for_tests():
10+
global orig_stdout, orig_stderr
11+
orig_stdout = None
12+
orig_stderr = None
13+
14+
global wrapped_stdout, wrapped_stderr
15+
wrapped_stdout = None
16+
wrapped_stderr = None
1117

12-
wrapped_stdout = None
13-
wrapped_stderr = None
18+
global atexit_done
19+
atexit_done = False
20+
21+
global fixed_windows_console
22+
fixed_windows_console = False
1423

15-
atexit_done = False
24+
try:
25+
# no-op if it wasn't registered
26+
atexit.unregister(reset_all)
27+
except AttributeError:
28+
# python 2: no atexit.unregister. Oh well, we did our best.
29+
pass
1630

1731

1832
def reset_all():
@@ -55,6 +69,29 @@ def deinit():
5569
sys.stderr = orig_stderr
5670

5771

72+
def just_fix_windows_console():
73+
global fixed_windows_console
74+
75+
if sys.platform != "win32":
76+
return
77+
if fixed_windows_console:
78+
return
79+
if wrapped_stdout is not None or wrapped_stderr is not None:
80+
# Someone already ran init() and it did stuff, so we won't second-guess them
81+
return
82+
83+
# On newer versions of Windows, AnsiToWin32.__init__ will implicitly enable the
84+
# native ANSI support in the console as a side-effect. We only need to actually
85+
# replace sys.stdout/stderr if we're in the old-style conversion mode.
86+
new_stdout = AnsiToWin32(sys.stdout, convert=None, strip=None, autoreset=False)
87+
if new_stdout.convert:
88+
sys.stdout = new_stdout
89+
new_stderr = AnsiToWin32(sys.stderr, convert=None, strip=None, autoreset=False)
90+
if new_stderr.convert:
91+
sys.stderr = new_stderr
92+
93+
fixed_windows_console = True
94+
5895
@contextlib.contextmanager
5996
def colorama_text(*args, **kwargs):
6097
init(*args, **kwargs)
@@ -78,3 +115,7 @@ def wrap_stream(stream, convert, strip, autoreset, wrap):
78115
if wrapper.should_wrap():
79116
stream = wrapper.stream
80117
return stream
118+
119+
120+
# Use this for initial setup as well, to reduce code duplication
121+
_wipe_internal_state_for_tests()

pipenv/vendor/colorama/win32.py

+28
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
STDOUT = -11
55
STDERR = -12
66

7+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
8+
79
try:
810
import ctypes
911
from ctypes import LibraryLoader
@@ -89,6 +91,20 @@ def __str__(self):
8991
]
9092
_SetConsoleTitleW.restype = wintypes.BOOL
9193

94+
_GetConsoleMode = windll.kernel32.GetConsoleMode
95+
_GetConsoleMode.argtypes = [
96+
wintypes.HANDLE,
97+
POINTER(wintypes.DWORD)
98+
]
99+
_GetConsoleMode.restype = wintypes.BOOL
100+
101+
_SetConsoleMode = windll.kernel32.SetConsoleMode
102+
_SetConsoleMode.argtypes = [
103+
wintypes.HANDLE,
104+
wintypes.DWORD
105+
]
106+
_SetConsoleMode.restype = wintypes.BOOL
107+
92108
def _winapi_test(handle):
93109
csbi = CONSOLE_SCREEN_BUFFER_INFO()
94110
success = _GetConsoleScreenBufferInfo(
@@ -150,3 +166,15 @@ def FillConsoleOutputAttribute(stream_id, attr, length, start):
150166

151167
def SetConsoleTitle(title):
152168
return _SetConsoleTitleW(title)
169+
170+
def GetConsoleMode(handle):
171+
mode = wintypes.DWORD()
172+
success = _GetConsoleMode(handle, byref(mode))
173+
if not success:
174+
raise ctypes.WinError()
175+
return mode.value
176+
177+
def SetConsoleMode(handle, mode):
178+
success = _SetConsoleMode(handle, mode)
179+
if not success:
180+
raise ctypes.WinError()

pipenv/vendor/colorama/winterm.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2-
from . import win32
2+
try:
3+
from msvcrt import get_osfhandle
4+
except ImportError:
5+
def get_osfhandle(_):
6+
raise OSError("This isn't windows!")
7+
38

9+
from . import win32
410

511
# from wincon.h
612
class WinColor(object):
@@ -167,3 +173,23 @@ def erase_line(self, mode=0, on_stderr=False):
167173

168174
def set_title(self, title):
169175
win32.SetConsoleTitle(title)
176+
177+
178+
def enable_vt_processing(fd):
179+
if win32.windll is None or not win32.winapi_test():
180+
return False
181+
182+
try:
183+
handle = get_osfhandle(fd)
184+
mode = win32.GetConsoleMode(handle)
185+
win32.SetConsoleMode(
186+
handle,
187+
mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING,
188+
)
189+
190+
mode = win32.GetConsoleMode(handle)
191+
if mode & win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING:
192+
return True
193+
# Can get TypeError in testsuite where 'fd' is a Mock()
194+
except (OSError, TypeError):
195+
return False

pipenv/vendor/requirementslib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .models.pipfile import Pipfile
66
from .models.requirements import Requirement
77

8-
__version__ = "2.2.0"
8+
__version__ = "2.2.1"
99

1010

1111
logger = logging.getLogger(__name__)

pipenv/vendor/requirementslib/models/setup_info.py

+9-24
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import contextlib
55
import os
66
import shutil
7+
import subprocess as sp
78
import sys
89
from collections.abc import Iterable, Mapping
910
from contextlib import ExitStack
@@ -30,7 +31,6 @@
3031
)
3132
from pipenv.patched.pip._vendor.platformdirs import user_cache_dir
3233
from pipenv.vendor.vistir.contextmanagers import cd, temp_path
33-
from pipenv.vendor.vistir.misc import run
3434
from pipenv.vendor.vistir.path import create_tracked_tempdir, rmtree
3535

3636
from ..environment import MYPY_RUNNING
@@ -94,16 +94,8 @@ def pep517_subprocess_runner(cmd, cwd=None, extra_environ=None):
9494
if extra_environ:
9595
env.update(extra_environ)
9696

97-
run(
98-
cmd,
99-
cwd=cwd,
100-
env=env,
101-
block=True,
102-
combine_stderr=True,
103-
return_object=False,
104-
write_to_stdout=False,
105-
nospin=True,
106-
)
97+
cmd_as_str = " ".join(cmd)
98+
sp.run(cmd_as_str, cwd=cwd, env=env, stdout=sp.PIPE, stderr=sp.STDOUT, shell=True)
10799

108100

109101
class BuildEnv(envbuild.BuildEnvironment):
@@ -117,14 +109,8 @@ def pip_install(self, reqs):
117109
"--prefix",
118110
self.path,
119111
] + list(reqs)
120-
run(
121-
cmd,
122-
block=True,
123-
combine_stderr=True,
124-
return_object=False,
125-
write_to_stdout=False,
126-
nospin=True,
127-
)
112+
113+
sp.run(cmd, shell=True, stderr=sp.PIPE, stdout=sp.PIPE)
128114

129115

130116
class HookCaller(wrappers.Pep517HookCaller):
@@ -892,13 +878,12 @@ def run_setup(script_path, egg_base=None):
892878
# We couldn't import everything needed to run setup
893879
except Exception:
894880
python = os.environ.get("PIP_PYTHON_PATH", sys.executable)
895-
out, _ = run(
881+
882+
sp.run(
896883
[python, "setup.py"] + args,
897884
cwd=target_cwd,
898-
block=True,
899-
combine_stderr=False,
900-
return_object=False,
901-
nospin=True,
885+
stdout=sp.PIPE,
886+
stderr=sp.PIPE,
902887
)
903888
finally:
904889
_setup_stop_after = None

pipenv/vendor/vendor.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ attrs==22.1.0
22
cerberus==1.3.4
33
click-didyoumean==0.0.3
44
click==8.0.3
5-
colorama==0.4.4
5+
colorama==0.4.6
66
dparse==0.6.2
77
markupsafe==2.0.1
88
pexpect==4.8.0
@@ -12,9 +12,9 @@ ptyprocess==0.7.0
1212
pyparsing==3.0.9
1313
python-dotenv==0.19.0
1414
pythonfinder==1.3.1
15-
requirementslib==2.2.0
15+
requirementslib==2.2.1
1616
ruamel.yaml==0.17.21
1717
shellingham==1.5.0
1818
toml==0.10.2
1919
tomlkit==0.9.2
20-
vistir==0.7.4
20+
vistir==0.7.5

0 commit comments

Comments
 (0)