mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
+7
-5
@@ -22,7 +22,7 @@ from .utils import optional_instance_of, get_url_name
|
||||
|
||||
from ..environment import MYPY_RUNNING
|
||||
if MYPY_RUNNING:
|
||||
from typing import Union, Any, Dict, Iterable, Sequence, Mapping, List, NoReturn, Text
|
||||
from typing import Union, Any, Dict, Iterable, Mapping, List, Text
|
||||
package_type = Dict[Text, Dict[Text, Union[List[Text], Text]]]
|
||||
source_type = Dict[Text, Union[Text, bool]]
|
||||
sources_type = Iterable[source_type]
|
||||
@@ -264,7 +264,8 @@ class Pipfile(object):
|
||||
@classmethod
|
||||
def load_projectfile(cls, path, create=False):
|
||||
# type: (Text, bool) -> ProjectFile
|
||||
"""Given a path, load or create the necessary pipfile.
|
||||
"""
|
||||
Given a path, load or create the necessary pipfile.
|
||||
|
||||
:param Text path: Path to the project root or pipfile
|
||||
:param bool create: Whether to create the pipfile if not found, defaults to True
|
||||
@@ -289,7 +290,8 @@ class Pipfile(object):
|
||||
@classmethod
|
||||
def load(cls, path, create=False):
|
||||
# type: (Text, bool) -> Pipfile
|
||||
"""Given a path, load or create the necessary pipfile.
|
||||
"""
|
||||
Given a path, load or create the necessary pipfile.
|
||||
|
||||
:param Text path: Path to the project root or pipfile
|
||||
:param bool create: Whether to create the pipfile if not found, defaults to True
|
||||
@@ -340,8 +342,8 @@ class Pipfile(object):
|
||||
if not os.path.exists(self.path_to("setup.py")):
|
||||
if not build_system or not build_system.get("requires"):
|
||||
build_system = {
|
||||
"requires": ["setuptools>=38.2.5", "wheel"],
|
||||
"build-backend": "setuptools.build_meta",
|
||||
"requires": ["setuptools>=40.8", "wheel"],
|
||||
"build-backend": "setuptools.build_meta:__legacy__",
|
||||
}
|
||||
self._build_system = build_system
|
||||
|
||||
|
||||
+38
-20
@@ -77,7 +77,7 @@ from .utils import (
|
||||
from ..environment import MYPY_RUNNING
|
||||
|
||||
if MYPY_RUNNING:
|
||||
from typing import Optional, TypeVar, List, Dict, Union, Any, Tuple, Generator, Set, Text
|
||||
from typing import Optional, TypeVar, List, Dict, Union, Any, Tuple, Set, Text
|
||||
from pip_shims.shims import Link, InstallRequirement
|
||||
RequirementType = TypeVar('RequirementType', covariant=True, bound=PackagingRequirement)
|
||||
from six.moves.urllib.parse import SplitResult
|
||||
@@ -320,8 +320,8 @@ class Line(object):
|
||||
@specifiers.setter
|
||||
def specifiers(self, specifiers):
|
||||
# type: (Union[Text, SpecifierSet]) -> None
|
||||
if type(specifiers) is not SpecifierSet:
|
||||
if type(specifiers) in six.string_types:
|
||||
if not isinstance(specifiers, SpecifierSet):
|
||||
if isinstance(specifiers, six.string_types):
|
||||
specifiers = SpecifierSet(specifiers)
|
||||
else:
|
||||
raise TypeError("Must pass a string or a SpecifierSet")
|
||||
@@ -739,7 +739,7 @@ class Line(object):
|
||||
wheel_kwargs = self.wheel_kwargs.copy()
|
||||
wheel_kwargs["src_dir"] = repo.checkout_directory
|
||||
ireq.source_dir = wheel_kwargs["src_dir"]
|
||||
build_dir = ireq.build_location(wheel_kwargs["build_dir"])
|
||||
ireq.build_location(wheel_kwargs["build_dir"])
|
||||
ireq._temp_build_dir.path = wheel_kwargs["build_dir"]
|
||||
with temp_path():
|
||||
sys.path = [repo.checkout_directory, "", ".", get_python_lib(plat_specific=0)]
|
||||
@@ -936,6 +936,8 @@ class Line(object):
|
||||
self.relpath = relpath
|
||||
self.path = path
|
||||
self.uri = uri
|
||||
if prefer in ("path", "relpath") or uri.startswith("file"):
|
||||
self.is_local = True
|
||||
if link.egg_fragment:
|
||||
name, extras = pip_shims.shims._strip_extras(link.egg_fragment)
|
||||
self.extras = tuple(sorted(set(parse_extras(extras))))
|
||||
@@ -1787,7 +1789,7 @@ class FileRequirement(object):
|
||||
line = "{0}{1}".format(line, extras_to_string(extras))
|
||||
if "subdirectory" in pipfile:
|
||||
arg_dict["subdirectory"] = pipfile["subdirectory"]
|
||||
line = "{0}&subdirectory={1}".format(pipfile["subdirectory"])
|
||||
line = "{0}&subdirectory={1}".format(line, pipfile["subdirectory"])
|
||||
if pipfile.get("editable", False):
|
||||
line = "-e {0}".format(line)
|
||||
arg_dict["line"] = line
|
||||
@@ -2520,7 +2522,8 @@ class Requirement(object):
|
||||
@property
|
||||
def build_backend(self):
|
||||
# type: () -> Optional[Text]
|
||||
if self.is_vcs or (self.is_file_or_url and self.req.is_local):
|
||||
if self.is_vcs or (self.is_file_or_url and (
|
||||
self.req is not None and self.req.is_local)):
|
||||
setup_info = self.run_requires()
|
||||
build_backend = setup_info.get("build_backend")
|
||||
return build_backend
|
||||
@@ -2546,11 +2549,15 @@ class Requirement(object):
|
||||
@property
|
||||
def is_wheel(self):
|
||||
# type: () -> bool
|
||||
if not self.is_named and self.req.link is not None and self.req.link.is_wheel:
|
||||
if not self.is_named and (
|
||||
self.req is not None and
|
||||
self.req.link is not None and
|
||||
self.req.link.is_wheel
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@cached_property
|
||||
@property
|
||||
def normalized_name(self):
|
||||
# type: () -> Text
|
||||
return canonicalize_name(self.name)
|
||||
@@ -2600,7 +2607,7 @@ class Requirement(object):
|
||||
r.req.extras = args["extras"]
|
||||
if parsed_line.hashes:
|
||||
args["hashes"] = tuple(parsed_line.hashes) # type: ignore
|
||||
cls_inst = cls(**args)
|
||||
cls_inst = cls(**args) # type: ignore
|
||||
return cls_inst
|
||||
|
||||
@classmethod
|
||||
@@ -2694,7 +2701,9 @@ class Requirement(object):
|
||||
parts.extend(hashes)
|
||||
else:
|
||||
parts.append(hashes)
|
||||
if sources and not (self.requirement.local_file or self.vcs):
|
||||
|
||||
is_local = self.is_file_or_url and self.req and self.req.is_local
|
||||
if sources and self.requirement and not (is_local or self.vcs):
|
||||
from ..utils import prepare_pip_source_args
|
||||
|
||||
if self.index:
|
||||
@@ -2938,6 +2947,9 @@ class Requirement(object):
|
||||
def file_req_from_parsed_line(parsed_line):
|
||||
# type: (Line) -> FileRequirement
|
||||
path = parsed_line.relpath if parsed_line.relpath else parsed_line.path
|
||||
pyproject_requires = () # type: Tuple[Text]
|
||||
if parsed_line.pyproject_requires is not None:
|
||||
pyproject_requires = tuple(parsed_line.pyproject_requires)
|
||||
return FileRequirement(
|
||||
setup_path=parsed_line.setup_py,
|
||||
path=path,
|
||||
@@ -2946,7 +2958,7 @@ def file_req_from_parsed_line(parsed_line):
|
||||
uri_scheme=parsed_line.preferred_scheme,
|
||||
link=parsed_line.link,
|
||||
uri=parsed_line.uri,
|
||||
pyproject_requires=tuple(parsed_line.pyproject_requires) if parsed_line.pyproject_requires else None,
|
||||
pyproject_requires=pyproject_requires,
|
||||
pyproject_backend=parsed_line.pyproject_backend,
|
||||
pyproject_path=Path(parsed_line.pyproject_toml) if parsed_line.pyproject_toml else None,
|
||||
parsed_line=parsed_line,
|
||||
@@ -2960,14 +2972,20 @@ def vcs_req_from_parsed_line(parsed_line):
|
||||
line = "{0}".format(parsed_line.line)
|
||||
if parsed_line.editable:
|
||||
line = "-e {0}".format(line)
|
||||
link = create_link(build_vcs_uri(
|
||||
vcs=parsed_line.vcs,
|
||||
uri=parsed_line.url,
|
||||
name=parsed_line.name,
|
||||
ref=parsed_line.ref,
|
||||
subdirectory=parsed_line.subdirectory,
|
||||
extras=parsed_line.extras
|
||||
))
|
||||
if parsed_line.url is not None:
|
||||
link = create_link(build_vcs_uri(
|
||||
vcs=parsed_line.vcs,
|
||||
uri=parsed_line.url,
|
||||
name=parsed_line.name,
|
||||
ref=parsed_line.ref,
|
||||
subdirectory=parsed_line.subdirectory,
|
||||
extras=list(parsed_line.extras)
|
||||
))
|
||||
else:
|
||||
link = parsed_line.link
|
||||
pyproject_requires = () # type: Tuple[Text]
|
||||
if parsed_line.pyproject_requires is not None:
|
||||
pyproject_requires = tuple(parsed_line.pyproject_requires)
|
||||
return VCSRequirement(
|
||||
setup_path=parsed_line.setup_py,
|
||||
path=parsed_line.path,
|
||||
@@ -2979,7 +2997,7 @@ def vcs_req_from_parsed_line(parsed_line):
|
||||
uri_scheme=parsed_line.preferred_scheme,
|
||||
link=link,
|
||||
uri=parsed_line.uri,
|
||||
pyproject_requires=tuple(parsed_line.pyproject_requires) if parsed_line.pyproject_requires else None,
|
||||
pyproject_requires=pyproject_requires,
|
||||
pyproject_backend=parsed_line.pyproject_backend,
|
||||
pyproject_path=Path(parsed_line.pyproject_toml) if parsed_line.pyproject_toml else None,
|
||||
parsed_line=parsed_line,
|
||||
|
||||
+6
-6
@@ -15,7 +15,6 @@ import pep517.envbuild
|
||||
import pep517.wrappers
|
||||
import six
|
||||
from appdirs import user_cache_dir
|
||||
from cached_property import cached_property
|
||||
from distlib.wheel import Wheel
|
||||
from packaging.markers import Marker
|
||||
from six.moves import configparser
|
||||
@@ -303,8 +302,8 @@ def get_metadata_from_wheel(wheel_path):
|
||||
name = metadata.name
|
||||
version = metadata.version
|
||||
requires = []
|
||||
extras_keys = getattr(metadata, "extras", None)
|
||||
extras = {}
|
||||
extras_keys = getattr(metadata, "extras", [])
|
||||
extras = {k: [] for k in extras_keys}
|
||||
for req in getattr(metadata, "run_requires", []):
|
||||
parsed_req = init_requirement(req)
|
||||
parsed_marker = parsed_req.marker
|
||||
@@ -652,6 +651,7 @@ build-backend = "{1}"
|
||||
dist_type="wheel"
|
||||
)
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
def build_sdist(self):
|
||||
# type: () -> Text
|
||||
if not self.pyproject.exists():
|
||||
@@ -718,7 +718,7 @@ build-backend = "{1}"
|
||||
get_metadata(d, pkg_name=self.name, metadata_type=metadata_type)
|
||||
for d in metadata_dirs if os.path.exists(d)
|
||||
]
|
||||
metadata = next(iter(d for d in metadata if d is not None), None)
|
||||
metadata = next(iter(d for d in metadata if d), None)
|
||||
if metadata is not None:
|
||||
self.populate_metadata(metadata)
|
||||
|
||||
@@ -839,7 +839,7 @@ build-backend = "{1}"
|
||||
from .dependencies import get_finder
|
||||
|
||||
finder = get_finder()
|
||||
vcs_method, uri = split_vcs_method_from_uri(unquote(ireq.link.url_without_fragment))
|
||||
_, uri = split_vcs_method_from_uri(unquote(ireq.link.url_without_fragment))
|
||||
parsed = urlparse(uri)
|
||||
if "file" in parsed.scheme:
|
||||
url_path = parsed.path
|
||||
@@ -870,7 +870,7 @@ build-backend = "{1}"
|
||||
"The file URL points to a directory not installable: {}"
|
||||
.format(ireq.link)
|
||||
)
|
||||
build_dir = ireq.build_location(kwargs["build_dir"])
|
||||
ireq.build_location(kwargs["build_dir"])
|
||||
src_dir = ireq.ensure_has_source_dir(kwargs["src_dir"])
|
||||
ireq._temp_build_dir.path = kwargs["build_dir"]
|
||||
|
||||
|
||||
+6
-4
@@ -295,9 +295,11 @@ def strip_extras_markers_from_requirement(req):
|
||||
raise TypeError("Must pass in a valid requirement, received {0!r}".format(req))
|
||||
if getattr(req, "marker", None) is not None:
|
||||
marker = req.marker # type: TMarker
|
||||
req.marker._markers = _strip_extras_markers(req.marker._markers)
|
||||
if not req.marker._markers:
|
||||
marker._markers = _strip_extras_markers(marker._markers)
|
||||
if not marker._markers:
|
||||
req.marker = None
|
||||
else:
|
||||
req.marker = marker
|
||||
return req
|
||||
|
||||
|
||||
@@ -338,7 +340,7 @@ def get_default_pyproject_backend():
|
||||
st_version = get_setuptools_version()
|
||||
if st_version is not None:
|
||||
parsed_st_version = parse_version(st_version)
|
||||
if parsed_st_version >= parse_version("40.6.0"):
|
||||
if parsed_st_version >= parse_version("40.8.0"):
|
||||
return "setuptools.build_meta:__legacy__"
|
||||
return "setuptools.build_meta"
|
||||
|
||||
@@ -354,9 +356,9 @@ def get_pyproject(path):
|
||||
:rtype: Tuple[List[Text], Text]
|
||||
"""
|
||||
|
||||
from vistir.compat import Path
|
||||
if not path:
|
||||
return
|
||||
from vistir.compat import Path
|
||||
if not isinstance(path, Path):
|
||||
path = Path(path)
|
||||
if not path.is_dir():
|
||||
|
||||
Reference in New Issue
Block a user