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

Vendor pip 22.0.4 follow-up changes [Diff of actual changes to code] #4969

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
53682cf
check point progress on only bringing in pip==22.0.3
Feb 20, 2022
f3ba76f
updating vendor packaging version
Feb 20, 2022
512b22b
update pipdeptree to fix pipenv graph with new version of pip.
Feb 20, 2022
c37e470
Apply patch logic to pipdeptree.py
Feb 20, 2022
86242c4
Update patch file for pipdeptree
matteius Feb 20, 2022
f814c9c
corrected vendor.text
matteius Feb 20, 2022
aece086
port pip21 patch to pip22 patch
matteius Feb 21, 2022
e4dc20e
fix tabs issue in making patch
matteius Feb 21, 2022
ead6fe2
fix tabs issues from patching
Feb 21, 2022
631dada
correct patch paths
matteius Feb 21, 2022
289c4c9
hardcoded cachecontrol license to satisfy build.
matteius Feb 21, 2022
442882d
hardcoded cachecontrol license to satisfy build.
matteius Feb 21, 2022
7904d41
realizing that I am not to change pip internal, this at least gets th…
Feb 23, 2022
d83570d
This gest the hashes back and fixes handling Specifer or SpecifierSet…
Feb 23, 2022
98b9e9f
new pip requires verrbosity integer argument.
Feb 23, 2022
c3ecd9b
followup verbosity error
matteius Feb 23, 2022
2ec2eb2
Solve for extras packages not getting the specifer set as well.
Feb 23, 2022
b1da183
This test depends on the Pipfile.lock hashes which calls out 1.22 of …
matteius Feb 23, 2022
2d75f08
attempt to change this to the form we use elsewhere in this file
matteius Mar 9, 2022
85d2e8b
small victory: revert change to pip now that I chanegd methodology sa…
Mar 9, 2022
7078e9e
these changes no longer neccessary too
Mar 9, 2022
4da76e2
remove unused imports now
matteius Mar 9, 2022
d612c9d
Update vendoring of pip to 22.0.4 which also fixes 1/2 final failing …
Mar 9, 2022
ff8310b
Merge branch 'issues-4651-vendor-pip-22.0.3' into vendor-pip-22.0.3-f…
Mar 9, 2022
69c75fc
test toggling verbosity to be hardcoded on since someone is going to …
matteius Mar 9, 2022
66aa70b
Update vendored version of pyparsing
Mar 10, 2022
57510b5
Merge branch 'issues-4651-vendor-pip-22.0.3' into vendor-pip-22.0.3-f…
Mar 10, 2022
2a03dc4
This fixes the last test I believe, not sure why I needed this origin…
Mar 10, 2022
40fad79
put this back how it was I guess
Mar 10, 2022
77c98b9
revert this change too because I guess pip 22.0.4 doesnt require it w…
Mar 10, 2022
15763c6
this test also no longer needs to be modified
Mar 10, 2022
d12dec2
Merge branch 'main' into issues-4651-vendor-pip-22.0.3
matteius Mar 19, 2022
f92c63e
Add news fragment and remove python 3.6 runner
matteius Mar 19, 2022
db04891
Merge branch 'issues-4651-vendor-pip-22.0.3' into vendor-pip-22.0.3-f…
matteius Mar 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ jobs:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
os: [MacOS, Ubuntu, Windows]
include:
- python-version: 3.6
os: Ubuntu

steps:
- uses: actions/checkout@v1
Expand Down
3 changes: 3 additions & 0 deletions news/4995.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Updated vendor version of ``pip`` from ``21.2.2`` to ``22.0.4`` which fixes a number of bugs including
several reports of pipenv locking for an infinite amount of time when using certain package constraints.
This also drops support for python 3.6 as it is EOL and support was removed in pip 22.x
2 changes: 1 addition & 1 deletion pipenv/patched/notpip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

__version__ = "21.2.2"
__version__ = "22.0.4"


def main(args: Optional[List[str]] = None) -> int:
Expand Down
190 changes: 96 additions & 94 deletions pipenv/patched/notpip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@


class _Prefix:

def __init__(self, path):
# type: (str) -> None
def __init__(self, path: str) -> None:
self.path = path
self.setup = False
self.bin_dir = get_paths(
'nt' if os.name == 'nt' else 'posix_prefix',
vars={'base': path, 'platbase': path}
)['scripts']
"nt" if os.name == "nt" else "posix_prefix",
vars={"base": path, "platbase": path},
)["scripts"]
self.lib_dirs = get_prefixed_libs(path)


Expand Down Expand Up @@ -70,22 +68,18 @@ def _create_standalone_pip() -> Iterator[str]:


class BuildEnvironment:
"""Creates and manages an isolated environment to install build deps
"""
"""Creates and manages an isolated environment to install build deps"""

def __init__(self):
# type: () -> None
temp_dir = TempDirectory(
kind=tempdir_kinds.BUILD_ENV, globally_managed=True
)
def __init__(self) -> None:
temp_dir = TempDirectory(kind=tempdir_kinds.BUILD_ENV, globally_managed=True)

self._prefixes = OrderedDict(
(name, _Prefix(os.path.join(temp_dir.path, name)))
for name in ('normal', 'overlay')
for name in ("normal", "overlay")
)

self._bin_dirs = [] # type: List[str]
self._lib_dirs = [] # type: List[str]
self._bin_dirs: List[str] = []
self._lib_dirs: List[str] = []
for prefix in reversed(list(self._prefixes.values())):
self._bin_dirs.append(prefix.bin_dir)
self._lib_dirs.extend(prefix.lib_dirs)
Expand All @@ -96,12 +90,15 @@ def __init__(self):
system_sites = {
os.path.normcase(site) for site in (get_purelib(), get_platlib())
}
self._site_dir = os.path.join(temp_dir.path, 'site')
self._site_dir = os.path.join(temp_dir.path, "site")
if not os.path.exists(self._site_dir):
os.mkdir(self._site_dir)
with open(os.path.join(self._site_dir, 'sitecustomize.py'), 'w') as fp:
fp.write(textwrap.dedent(
'''
with open(
os.path.join(self._site_dir, "sitecustomize.py"), "w", encoding="utf-8"
) as fp:
fp.write(
textwrap.dedent(
"""
import os, site, sys

# First, drop system-sites related paths.
Expand All @@ -124,47 +121,49 @@ def __init__(self):
for path in {lib_dirs!r}:
assert not path in sys.path
site.addsitedir(path)
'''
).format(system_sites=system_sites, lib_dirs=self._lib_dirs))
"""
).format(system_sites=system_sites, lib_dirs=self._lib_dirs)
)

def __enter__(self):
# type: () -> None
def __enter__(self) -> None:
self._save_env = {
name: os.environ.get(name, None)
for name in ('PATH', 'PYTHONNOUSERSITE', 'PYTHONPATH')
for name in ("PATH", "PYTHONNOUSERSITE", "PYTHONPATH")
}

path = self._bin_dirs[:]
old_path = self._save_env['PATH']
old_path = self._save_env["PATH"]
if old_path:
path.extend(old_path.split(os.pathsep))

pythonpath = [self._site_dir]

os.environ.update({
'PATH': os.pathsep.join(path),
'PYTHONNOUSERSITE': '1',
'PYTHONPATH': os.pathsep.join(pythonpath),
})
os.environ.update(
{
"PATH": os.pathsep.join(path),
"PYTHONNOUSERSITE": "1",
"PYTHONPATH": os.pathsep.join(pythonpath),
}
)

def __exit__(
self,
exc_type, # type: Optional[Type[BaseException]]
exc_val, # type: Optional[BaseException]
exc_tb # type: Optional[TracebackType]
):
# type: (...) -> None
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> None:
for varname, old_value in self._save_env.items():
if old_value is None:
os.environ.pop(varname, None)
else:
os.environ[varname] = old_value

def check_requirements(self, reqs):
# type: (Iterable[str]) -> Tuple[Set[Tuple[str, str]], Set[str]]
def check_requirements(
self, reqs: Iterable[str]
) -> Tuple[Set[Tuple[str, str]], Set[str]]:
"""Return 2 sets:
- conflicting requirements: set of (installed, wanted) reqs tuples
- missing requirements: set of reqs
- conflicting requirements: set of (installed, wanted) reqs tuples
- missing requirements: set of reqs
"""
missing = set()
conflicting = set()
Expand All @@ -187,32 +186,25 @@ def check_requirements(self, reqs):

def install_requirements(
self,
finder, # type: PackageFinder
requirements, # type: Iterable[str]
prefix_as_string, # type: str
message # type: str
):
# type: (...) -> None
finder: "PackageFinder",
requirements: Iterable[str],
prefix_as_string: str,
*,
kind: str,
) -> None:
prefix = self._prefixes[prefix_as_string]
assert not prefix.setup
prefix.setup = True
if not requirements:
return
with contextlib.ExitStack() as ctx:
# TODO: Remove this block when dropping 3.6 support. Python 3.6
# lacks importlib.resources and pep517 has issues loading files in
# a zip, so we fallback to the "old" method by adding the current
# pip directory to the child process's sys.path.
if sys.version_info < (3, 7):
pip_runnable = os.path.dirname(pip_location)
else:
pip_runnable = ctx.enter_context(_create_standalone_pip())
pip_runnable = ctx.enter_context(_create_standalone_pip())
self._install_requirements(
pip_runnable,
finder,
requirements,
prefix,
message,
kind=kind,
)

@staticmethod
Expand All @@ -221,75 +213,85 @@ def _install_requirements(
finder: "PackageFinder",
requirements: Iterable[str],
prefix: _Prefix,
message: str,
*,
kind: str,
) -> None:
sys_executable = os.environ.get('PIP_PYTHON_PATH', sys.executable)
args = [
sys_executable, pip_runnable, 'install',
'--ignore-installed', '--no-user', '--prefix', prefix.path,
'--no-warn-script-location',
] # type: List[str]
args: List[str] = [
sys_executable,
pip_runnable,
"install",
"--ignore-installed",
"--no-user",
"--prefix",
prefix.path,
"--no-warn-script-location",
]
if logger.getEffectiveLevel() <= logging.DEBUG:
args.append('-v')
for format_control in ('no_binary', 'only_binary'):
args.append("-v")
for format_control in ("no_binary", "only_binary"):
formats = getattr(finder.format_control, format_control)
args.extend(('--' + format_control.replace('_', '-'),
','.join(sorted(formats or {':none:'}))))
args.extend(
(
"--" + format_control.replace("_", "-"),
",".join(sorted(formats or {":none:"})),
)
)

index_urls = finder.index_urls
if index_urls:
args.extend(['-i', index_urls[0]])
args.extend(["-i", index_urls[0]])
for extra_index in index_urls[1:]:
args.extend(['--extra-index-url', extra_index])
args.extend(["--extra-index-url", extra_index])
else:
args.append('--no-index')
args.append("--no-index")
for link in finder.find_links:
args.extend(['--find-links', link])
args.extend(["--find-links", link])

for host in finder.trusted_hosts:
args.extend(['--trusted-host', host])
args.extend(["--trusted-host", host])
if finder.allow_all_prereleases:
args.append('--pre')
args.append("--pre")
if finder.prefer_binary:
args.append('--prefer-binary')
args.append('--')
args.append("--prefer-binary")
args.append("--")
args.extend(requirements)
extra_environ = {"_PIP_STANDALONE_CERT": where()}
with open_spinner(message) as spinner:
call_subprocess(args, spinner=spinner, extra_environ=extra_environ)
with open_spinner(f"Installing {kind}") as spinner:
call_subprocess(
args,
command_desc=f"pip subprocess to install {kind}",
spinner=spinner,
extra_environ=extra_environ,
)


class NoOpBuildEnvironment(BuildEnvironment):
"""A no-op drop-in replacement for BuildEnvironment
"""
"""A no-op drop-in replacement for BuildEnvironment"""

def __init__(self):
# type: () -> None
def __init__(self) -> None:
pass

def __enter__(self):
# type: () -> None
def __enter__(self) -> None:
pass

def __exit__(
self,
exc_type, # type: Optional[Type[BaseException]]
exc_val, # type: Optional[BaseException]
exc_tb # type: Optional[TracebackType]
):
# type: (...) -> None
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> None:
pass

def cleanup(self):
# type: () -> None
def cleanup(self) -> None:
pass

def install_requirements(
self,
finder, # type: PackageFinder
requirements, # type: Iterable[str]
prefix_as_string, # type: str
message # type: str
):
# type: (...) -> None
finder: "PackageFinder",
requirements: Iterable[str],
prefix_as_string: str,
*,
kind: str,
) -> None:
raise NotImplementedError()
Loading