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 in pip==22.0.4 #4966

Merged
merged 28 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 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
d612c9d
Update vendoring of pip to 22.0.4 which also fixes 1/2 final failing …
Mar 9, 2022
66aa70b
Update vendored version of pyparsing
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
183fe3a
rebase on main.
matteius Apr 18, 2022
fcaac84
Vendoring of pip-shims 0.7.0
matteius Apr 18, 2022
52987c7
Vendoring of requirementslib 1.6.2
matteius Apr 18, 2022
15baed1
Update pip index safety restrictions patch for pip==22.0.4
matteius Apr 18, 2022
16b498a
Merge branch 'issues-4651-vendor-pip-22.0.3' of github.com:pypa/pipen…
matteius Apr 18, 2022
4ab621b
show diff on failure of linting.
matteius Apr 18, 2022
fa583f9
exclude pyptoject.toml from black to see if that helps.
matteius Apr 18, 2022
82e5522
Resolve locking.
matteius Apr 18, 2022
c6ebe26
Vendor in requirementsib 1.6.3
matteius Apr 18, 2022
d12f654
apply pip-shims patch.
matteius Apr 18, 2022
bd2d1f4
gets most of the tests passing again by using the same packaging libr…
matteius Apr 19, 2022
11ac5be
Move this part of the hash collection back to the top (like prior imp…
matteius Apr 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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
PYTHONIOENCODING: "utf-8"
GIT_ASK_YESNO: "false"
run: |
pipenv run pre-commit run --all-files --verbose
pipenv run pre-commit run --all-files --verbose --show-diff-on-failure
- name: Run tests
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
Expand Down
18 changes: 9 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.4"
__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"""
oz123 marked this conversation as resolved.
Show resolved Hide resolved

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")
oz123 marked this conversation as resolved.
Show resolved Hide resolved
)

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