未验证 提交 63fa7b5b 编写于 作者: F Frost Ming

update pdm dependencies

上级 07a3871b
Update dependencies `pythonfinder`, `python-cfonts`, `pip-shims` and many others.
Drop dependency `vistir`.
此差异已折叠。
......@@ -14,13 +14,13 @@ from distlib.wheel import Wheel
from pip._internal.utils import logging as pip_logging
from pip._vendor.pkg_resources import Distribution, EggInfoDistribution, safe_name
from pip_shims import shims
from vistir import cd
from pdm.exceptions import InstallationError
from pdm.iostream import stream
from pdm.models.candidates import Candidate
from pdm.models.environment import Environment
from pdm.models.requirements import parse_requirement, strip_extras
from pdm.utils import cd
def _is_dist_editable(dist: Distribution) -> bool:
......
......@@ -5,10 +5,10 @@ from typing import TYPE_CHECKING, Any, Dict, Optional
import pip_shims
from pip._vendor import requests
from vistir.contextmanagers import open_file
from pdm._types import CandidateInfo
from pdm.exceptions import CorruptedCacheError
from pdm.utils import open_file
if TYPE_CHECKING:
from pdm.models.candidates import Candidate
......
......@@ -15,8 +15,6 @@ from pip._vendor import packaging, pkg_resources
from pip_shims import shims
from pythonfinder import Finder
from pythonfinder.environment import PYENV_INSTALLED, PYENV_ROOT
from vistir.contextmanagers import temp_environ
from vistir.path import normalize_path
from pdm.exceptions import NoPythonVersion
from pdm.iostream import stream
......@@ -31,6 +29,7 @@ from pdm.utils import (
get_python_version,
get_sys_config_paths,
get_venv_python,
temp_environ,
)
if TYPE_CHECKING:
......@@ -181,8 +180,8 @@ class Environment:
def is_local(self, path) -> bool:
"""PEP 582 version of ``is_local()`` function."""
return normalize_path(path).startswith(
normalize_path(self.packages_path.as_posix())
return misc.normalize_path(path).startswith(
misc.normalize_path(self.packages_path.as_posix())
)
def evaluate_marker(self, text: str, extra=None) -> bool:
......@@ -356,8 +355,8 @@ class GlobalEnvironment(Environment):
return paths
def is_local(self, path) -> bool:
return normalize_path(path).startswith(
normalize_path(self.get_paths()["prefix"])
return misc.normalize_path(path).startswith(
misc.normalize_path(self.get_paths()["prefix"])
)
@property
......
......@@ -11,7 +11,6 @@ import halo
import tomlkit
from pip._vendor.pkg_resources import safe_name
from pip_shims import shims
from vistir.contextmanagers import atomic_open_for_write
from pdm._types import Source
from pdm.exceptions import ProjectError
......@@ -26,7 +25,12 @@ from pdm.project.config import Config
from pdm.project.meta import PackageMeta
from pdm.resolver import BaseProvider, EagerUpdateProvider, ReusePinProvider
from pdm.resolver.reporters import SpinnerReporter
from pdm.utils import cached_property, find_project_root, get_venv_python
from pdm.utils import (
atomic_open_for_write,
cached_property,
find_project_root,
get_venv_python,
)
if TYPE_CHECKING:
from tomlkit.container import Container
......
......@@ -6,11 +6,11 @@ import re
from typing import TYPE_CHECKING, Dict, List, Union
import setuptools
import vistir
from pkg_resources import safe_name
from pdm.exceptions import ProjectError
from pdm.models.markers import Marker
from pdm.utils import cd
if TYPE_CHECKING:
from pdm.project import Project
......@@ -148,7 +148,7 @@ class PackageMeta:
package_data = {"": ["*"]}
exclude_package_data = {}
with vistir.cd(self.project.root.as_posix()):
with cd(self.project.root.as_posix()):
if not self.includes:
if os.path.isdir("src"):
package_dir[""] = "src"
......
......@@ -14,10 +14,10 @@ import tempfile
import urllib.parse as parse
from contextlib import contextmanager
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from distlib.wheel import Wheel
from pip_shims.shims import InstallCommand, PackageFinder, TargetPython
from pip_shims.shims import InstallCommand, PackageFinder, TargetPython, url_to_path
from pdm._types import Source
......@@ -418,3 +418,66 @@ def get_venv_python() -> Optional[str]:
suffix = ""
scripts = "bin"
return os.path.join(venv, scripts, f"python{suffix}")
@contextmanager
def atomic_open_for_write(filename: Union[Path, str], *, encoding: str = "utf-8"):
fd, name = tempfile.mkstemp("-atomic-write", "pdm-")
try:
f = open(fd, "w", encoding=encoding)
yield f
except Exception:
f.close()
os.unlink(name)
raise
else:
f.close()
try:
os.unlink(filename)
except OSError:
pass
os.rename(name, filename)
@contextmanager
def cd(path: str):
_old_cwd = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(_old_cwd)
@contextmanager
def temp_environ():
environ = os.environ.copy()
try:
yield
finally:
os.environ.clear()
os.environ.update(environ)
@contextmanager
def open_file(url, session=None):
if url.startswith("file://"):
local_path = url_to_path(url)
if os.path.isdir(local_path):
raise ValueError("Cannot open directory for read: {}".format(url))
else:
with open(local_path, "rb") as local_file:
yield local_file
else:
headers = {"Accept-Encoding": "identity"}
with session.get(url, headers=headers, stream=True) as resp:
try:
raw = getattr(resp, "raw", None)
result = raw if raw else resp
yield result
finally:
if raw:
conn = getattr(raw, "_connection")
if conn is not None:
conn.close()
result.close()
......@@ -39,7 +39,6 @@ pytest = "*"
pytest-cov = "*"
pytest-mock = "*"
towncrier = "<20.0.0,>=19.2.0"
pytest-sugar = "<1.0.0,>=0.9.2"
pytest-xdist = "<2.0.0,>=1.31.0"
[tool.pdm.doc-dependencies]
......
......@@ -46,7 +46,6 @@ known_first_party = pdm
known_third_party =
click
halo
vistir
distlib
pythonfinder
pytest
......
......@@ -28,7 +28,16 @@ def main():
subprocess.check_call([venv_python.as_posix(), "-m", "pip", "install", "pdm"])
subprocess.check_call(
[venv_python.as_posix(), "-m", "pip", "install", "pip", "pip_shims", "-U"]
[
venv_python.as_posix(),
"-m",
"pip",
"install",
"-U",
"pip",
"pip_shims",
"vistir",
]
)
print("Setup project for development...", flush=True)
......
......@@ -357,7 +357,7 @@ def test_list_dependency_graph(capsys):
project = Project()
actions.do_list(project, True)
content, _ = capsys.readouterr()
assert "halo 0.0.28 [ required: <1.0.0,>=0.0.28 ]" in content
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
......
......@@ -4,11 +4,10 @@ import sys
from pathlib import Path
import pytest
from vistir.contextmanagers import temp_environ
from pdm.cli import actions
from pdm.models.requirements import parse_requirement
from pdm.utils import get_python_version
from pdm.utils import get_python_version, temp_environ
def test_help_option(invoke):
......
......@@ -2,9 +2,9 @@ import os
from pathlib import Path
import pytest
from vistir import temp_environ
from pdm.project import Project
from pdm.utils import temp_environ
def test_project_python_with_pyenv_support(project, mocker):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册