未验证 提交 765f6025 编写于 作者: F Frost Ming 提交者: GitHub

Merge pull request #125 from frostming/upgrade-pip

Upgrade pip
Upgrade dependency `pip` to `20.1`.
此差异已折叠。
......@@ -69,6 +69,8 @@ class Core:
def main(self, args=None, prog_name=None, obj=None, **extra):
"""The main entry function"""
from pip._internal.utils.temp_dir import global_tempdir_manager
self.init_parser()
self.load_plugins()
......@@ -93,7 +95,8 @@ class Core:
sys.exit(1)
else:
try:
f(options.project, options)
with global_tempdir_manager():
f(options.project, options)
except Exception:
etype, err, traceback = sys.exc_info()
if stream.verbosity > stream.NORMAL:
......
......@@ -55,8 +55,13 @@ def requirement_from_ireq(ireq):
def parse_requirement_file(filename):
from pip._internal.req.constructors import install_req_from_parsed_requirement
finder = get_finder([])
ireqs = list(parse_requirements(filename, finder.session, finder))
ireqs = [
install_req_from_parsed_requirement(pr)
for pr in parse_requirements(filename, finder.session, finder)
]
return ireqs, finder
......
......@@ -31,6 +31,7 @@ from pdm.utils import (
get_python_version,
get_sys_config_paths,
get_venv_python,
populate_link,
temp_environ,
)
......@@ -272,7 +273,6 @@ class Environment:
:param allow_all: Allow building incompatible wheels.
:returns: The full path of the built artifact.
"""
from pip._internal.utils.temp_dir import global_tempdir_manager
from pdm.builders import EditableBuilder
from pdm.builders import WheelBuilder
......@@ -281,9 +281,9 @@ class Environment:
if allow_all:
with allow_all_wheels():
# temporarily allow all wheels to get a link.
ireq.populate_link(finder, False, bool(hashes))
populate_link(finder, ireq, False)
else:
ireq.populate_link(finder, False, bool(hashes))
populate_link(finder, ireq, False)
if not ireq.editable and not ireq.req.name:
ireq.source_dir = kwargs["build_dir"]
else:
......@@ -295,23 +295,22 @@ class Environment:
download_dir = kwargs["wheel_download_dir"]
only_download = True
if hashes:
ireq.options["hashes"] = convert_hashes(hashes)
ireq.hash_options = convert_hashes(hashes)
if not (ireq.editable and ireq.req.is_local_dir):
with global_tempdir_manager():
downloader = shims.Downloader(finder.session, "off")
downloaded = shims.unpack_url(
ireq.link,
ireq.source_dir,
downloader,
download_dir,
ireq.hashes(False),
)
# Preserve the downloaded file so that it won't be cleared.
if downloaded and only_download:
try:
shutil.copy(downloaded, download_dir)
except shutil.SameFileError:
pass
downloader = shims.Downloader(finder.session, "off")
downloaded = shims.unpack_url(
ireq.link,
ireq.source_dir,
downloader,
download_dir,
ireq.hashes(False),
)
# Preserve the downloaded file so that it won't be cleared.
if downloaded and only_download:
try:
shutil.copy(downloaded.path, download_dir)
except shutil.SameFileError:
pass
# Now all source is prepared, build it.
if ireq.link.is_wheel:
return (self.project.cache("wheels") / ireq.link.filename).as_posix()
......
......@@ -19,7 +19,13 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from distlib.wheel import Wheel
from packaging.version import parse as parse_version
from pip_shims.shims import InstallCommand, PackageFinder, TargetPython, url_to_path
from pip_shims.shims import (
InstallCommand,
InstallRequirement,
PackageFinder,
TargetPython,
url_to_path,
)
from pdm._types import Source
......@@ -506,3 +512,13 @@ def get_platform():
def highest_version(versions: List[str]) -> str:
"""Return the highest version of a given list."""
return max(versions, key=parse_version)
def populate_link(
finder: PackageFinder, ireq: InstallRequirement, upgrade: bool = False
):
"""Populate ireq's link attribute"""
if ireq.link:
return
link = finder.find_requirement(ireq, upgrade)
ireq.link = link
......@@ -27,7 +27,7 @@ Documentation = "https://pdm.fming.dev"
appdirs = "*"
click = "*"
distlib = "*"
pip = "<20.1,>=20.0"
pip = ">=20.1"
pip_shims = "*"
pythonfinder = "*"
tomlkit = "*"
......
......@@ -26,7 +26,7 @@ def main():
print("Installing base requirements...", flush=True)
subprocess.check_call(
[venv_python.as_posix(), "-m", "pip", "install", "-U", "pip<20.1", "pdm"]
[venv_python.as_posix(), "-m", "pip", "install", "-U", "pip", "pdm"]
)
print("Setup project for development...", flush=True)
......
......@@ -369,7 +369,6 @@ def test_list_dependency_graph(capsys):
actions.do_list(project, True)
content, _ = capsys.readouterr()
assert "halo 0.0.29 [ required: <1.0.0,>=0.0.28 ]" in content
assert "six 1.14.0 [ required: >=1.12.0 ]" in content
def test_list_dependency_graph_with_circular(project, capsys, repository, working_set):
......
......@@ -243,6 +243,14 @@ def get_local_finder(*args, **kwargs):
return finder
@pytest.fixture(autouse=True)
def pip_global_tempdir_manager():
from pip._internal.utils.temp_dir import global_tempdir_manager
with global_tempdir_manager():
yield
@pytest.fixture()
def project_no_init(tmp_path, mocker):
p = TestProject(tmp_path.as_posix())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册