mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 14:50:16 +00:00
Update vendor.txt and ecosystem libraries
- Update `pip_shims`, `pythonfinder`, `requirementslib`, `vistir` - Add patches to update or fix import paths where necessary - Hardcode funcsigs license Signed-off-by: Dan Ryan <dan.ryan@canonical.com>
This commit is contained in:
Vendored
+1
-1
@@ -5,7 +5,7 @@ import sys
|
||||
|
||||
from . import shims
|
||||
|
||||
__version__ = "0.4.0"
|
||||
__version__ = "0.5.1"
|
||||
|
||||
|
||||
if "pip_shims" in sys.modules:
|
||||
|
||||
Vendored
+1511
File diff suppressed because it is too large
Load Diff
+5
@@ -1,4 +1,9 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
"""
|
||||
Module with functionality to learn about the environment.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import importlib
|
||||
import os
|
||||
|
||||
|
||||
Vendored
+79
-24
@@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Helper module for shimming functionality across pip versions.
|
||||
"""
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import collections
|
||||
@@ -12,7 +15,7 @@ import weakref
|
||||
|
||||
import six
|
||||
|
||||
from . import backports
|
||||
from . import compat
|
||||
from .environment import BASE_IMPORT_PATH, MYPY_RUNNING, get_pip_version
|
||||
from .utils import (
|
||||
add_mixin_to_class,
|
||||
@@ -801,7 +804,7 @@ ConfigOptionParser.create_path("baseparser.ConfigOptionParser", "7.0.0", "18.0")
|
||||
|
||||
InstallCommand = ShimmedPathCollection("InstallCommand", ImportTypes.CLASS)
|
||||
InstallCommand.pre_shim(
|
||||
functools.partial(backports.partial_command, cmd_mapping=commands_dict)
|
||||
functools.partial(compat.partial_command, cmd_mapping=commands_dict)
|
||||
)
|
||||
InstallCommand.create_path("commands.install.InstallCommand", "7.0.0", "9999")
|
||||
|
||||
@@ -911,12 +914,19 @@ is_file_url = ShimmedPathCollection("is_file_url", ImportTypes.FUNCTION)
|
||||
is_file_url.set_default(fallback_is_file_url)
|
||||
is_file_url.create_path("download.is_file_url", "7.0.0", "19.2.3")
|
||||
|
||||
Downloader = ShimmedPathCollection("Downloader", ImportTypes.CLASS)
|
||||
Downloader.create_path("network.download.Downloader", "19.3.9", "9999")
|
||||
|
||||
unpack_url = ShimmedPathCollection("unpack_url", ImportTypes.FUNCTION)
|
||||
unpack_url.create_path("download.unpack_url", "7.0.0", "19.3.9")
|
||||
unpack_url.create_path("operations.prepare.unpack_url", "20.0", "9999")
|
||||
|
||||
shim_unpack = ShimmedPathCollection("shim_unpack", ImportTypes.FUNCTION)
|
||||
shim_unpack.set_default(functools.partial(backports.shim_unpack, unpack_fn=unpack_url))
|
||||
shim_unpack.set_default(
|
||||
functools.partial(
|
||||
compat.shim_unpack, unpack_fn=unpack_url, downloader_provider=Downloader
|
||||
)
|
||||
)
|
||||
|
||||
is_installable_dir = ShimmedPathCollection("is_installable_dir", ImportTypes.FUNCTION)
|
||||
is_installable_dir.create_path("utils.misc.is_installable_dir", "10.0.0", "9999")
|
||||
@@ -930,7 +940,10 @@ Link.create_path("index.Link", "7.0.0", "18.1")
|
||||
|
||||
make_abstract_dist = ShimmedPathCollection("make_abstract_dist", ImportTypes.FUNCTION)
|
||||
make_abstract_dist.create_path(
|
||||
"distributions.make_distribution_for_install_requirement", "19.1.2", "9999"
|
||||
"distributions.make_distribution_for_install_requirement", "20.0.0", "9999"
|
||||
)
|
||||
make_abstract_dist.create_path(
|
||||
"distributions.make_distribution_for_install_requirement", "19.1.2", "19.3.9"
|
||||
)
|
||||
make_abstract_dist.create_path(
|
||||
"operations.prepare.make_abstract_dist", "10.0.0", "19.1.1"
|
||||
@@ -938,10 +951,13 @@ make_abstract_dist.create_path(
|
||||
make_abstract_dist.create_path("req.req_set.make_abstract_dist", "7.0.0", "9.0.3")
|
||||
|
||||
make_distribution_for_install_requirement = ShimmedPathCollection(
|
||||
"make_distribution_for_install_requirement", ImportTypes.CLASS
|
||||
"make_distribution_for_install_requirement", ImportTypes.FUNCTION
|
||||
)
|
||||
make_distribution_for_install_requirement.create_path(
|
||||
"distributions.make_distribution_for_install_requirement", "19.1.2", "9999"
|
||||
"distributions.make_distribution_for_install_requirement", "20.0.0", "9999"
|
||||
)
|
||||
make_distribution_for_install_requirement.create_path(
|
||||
"distributions.make_distribution_for_install_requirement", "19.1.2", "19.9.9"
|
||||
)
|
||||
|
||||
make_option_group = ShimmedPathCollection("make_option_group", ImportTypes.FUNCTION)
|
||||
@@ -953,38 +969,38 @@ PackageFinder.create_path("index.PackageFinder", "7.0.0", "19.9")
|
||||
PackageFinder.create_path("index.package_finder.PackageFinder", "20.0", "9999")
|
||||
|
||||
CandidateEvaluator = ShimmedPathCollection("CandidateEvaluator", ImportTypes.CLASS)
|
||||
CandidateEvaluator.set_default(backports.CandidateEvaluator)
|
||||
CandidateEvaluator.set_default(compat.CandidateEvaluator)
|
||||
CandidateEvaluator.create_path("index.CandidateEvaluator", "19.1.0", "19.3.9")
|
||||
CandidateEvaluator.create_path("index.package_finder.CandidateEvaluator", "20.0", "9999")
|
||||
|
||||
CandidatePreferences = ShimmedPathCollection("CandidatePreferences", ImportTypes.CLASS)
|
||||
CandidatePreferences.set_default(backports.CandidatePreferences)
|
||||
CandidatePreferences.set_default(compat.CandidatePreferences)
|
||||
CandidatePreferences.create_path("index.CandidatePreferences", "19.2.0", "19.9")
|
||||
CandidatePreferences.create_path(
|
||||
"index.package_finder.CandidatePreferences", "20.0", "9999"
|
||||
)
|
||||
|
||||
LinkCollector = ShimmedPathCollection("LinkCollector", ImportTypes.CLASS)
|
||||
LinkCollector.set_default(backports.LinkCollector)
|
||||
LinkCollector.set_default(compat.LinkCollector)
|
||||
LinkCollector.create_path("collector.LinkCollector", "19.3.0", "19.9")
|
||||
LinkCollector.create_path("index.collector.LinkCollector", "20.0", "9999")
|
||||
|
||||
LinkEvaluator = ShimmedPathCollection("LinkEvaluator", ImportTypes.CLASS)
|
||||
LinkEvaluator.set_default(backports.LinkEvaluator)
|
||||
LinkEvaluator.set_default(compat.LinkEvaluator)
|
||||
LinkEvaluator.create_path("index.LinkEvaluator", "19.2.0", "19.9")
|
||||
LinkEvaluator.create_path("index.package_finder.LinkEvaluator", "20.0", "9999")
|
||||
|
||||
TargetPython = ShimmedPathCollection("TargetPython", ImportTypes.CLASS)
|
||||
backports.TargetPython.fallback_get_tags = get_tags
|
||||
TargetPython.set_default(backports.TargetPython)
|
||||
compat.TargetPython.fallback_get_tags = get_tags
|
||||
TargetPython.set_default(compat.TargetPython)
|
||||
TargetPython.create_path("models.target_python.TargetPython", "19.2.0", "9999")
|
||||
|
||||
SearchScope = ShimmedPathCollection("SearchScope", ImportTypes.CLASS)
|
||||
SearchScope.set_default(backports.SearchScope)
|
||||
SearchScope.set_default(compat.SearchScope)
|
||||
SearchScope.create_path("models.search_scope.SearchScope", "19.2.0", "9999")
|
||||
|
||||
SelectionPreferences = ShimmedPathCollection("SelectionPreferences", ImportTypes.CLASS)
|
||||
SelectionPreferences.set_default(backports.SelectionPreferences)
|
||||
SelectionPreferences.set_default(compat.SelectionPreferences)
|
||||
SelectionPreferences.create_path(
|
||||
"models.selection_prefs.SelectionPreferences", "19.2.0", "9999"
|
||||
)
|
||||
@@ -1013,11 +1029,18 @@ RequirementTracker.create_path("req.req_tracker.RequirementTracker", "7.0.0", "9
|
||||
TempDirectory = ShimmedPathCollection("TempDirectory", ImportTypes.CLASS)
|
||||
TempDirectory.create_path("utils.temp_dir.TempDirectory", "7.0.0", "9999")
|
||||
|
||||
global_tempdir_manager = ShimmedPathCollection(
|
||||
"global_tempdir_manager", ImportTypes.CONTEXTMANAGER
|
||||
)
|
||||
global_tempdir_manager.create_path(
|
||||
"utils.temp_dir.global_tempdir_manager", "7.0.0", "9999"
|
||||
)
|
||||
|
||||
get_requirement_tracker = ShimmedPathCollection(
|
||||
"get_requirement_tracker", ImportTypes.CONTEXTMANAGER
|
||||
)
|
||||
get_requirement_tracker.set_default(
|
||||
functools.partial(backports.get_requirement_tracker, RequirementTracker.shim())
|
||||
functools.partial(compat.get_requirement_tracker, RequirementTracker.shim())
|
||||
)
|
||||
get_requirement_tracker.create_path(
|
||||
"req.req_tracker.get_requirement_tracker", "7.0.0", "9999"
|
||||
@@ -1025,7 +1048,8 @@ get_requirement_tracker.create_path(
|
||||
|
||||
Resolver = ShimmedPathCollection("Resolver", ImportTypes.CLASS)
|
||||
Resolver.create_path("resolve.Resolver", "7.0.0", "19.1.1")
|
||||
Resolver.create_path("legacy_resolve.Resolver", "19.1.2", "9999")
|
||||
Resolver.create_path("legacy_resolve.Resolver", "19.1.2", "20.0.89999")
|
||||
Resolver.create_path("resolution.legacy.resolver.Resolver", "20.0.99999", "99999")
|
||||
|
||||
SafeFileCache = ShimmedPathCollection("SafeFileCache", ImportTypes.CLASS)
|
||||
SafeFileCache.create_path("network.cache.SafeFileCache", "19.3.0", "9999")
|
||||
@@ -1046,7 +1070,8 @@ VcsSupport.create_path("vcs.VcsSupport", "7.0.0", "19.1.1")
|
||||
VcsSupport.create_path("vcs.versioncontrol.VcsSupport", "19.2", "9999")
|
||||
|
||||
Wheel = ShimmedPathCollection("Wheel", ImportTypes.CLASS)
|
||||
Wheel.create_path("wheel.Wheel", "7.0.0", "9999")
|
||||
Wheel.create_path("wheel.Wheel", "7.0.0", "19.3.9")
|
||||
Wheel.set_default(compat.Wheel)
|
||||
|
||||
WheelCache = ShimmedPathCollection("WheelCache", ImportTypes.CLASS)
|
||||
WheelCache.create_path("cache.WheelCache", "10.0.0", "9999")
|
||||
@@ -1054,7 +1079,15 @@ WheelCache.create_path("wheel.WheelCache", "7", "9.0.3")
|
||||
|
||||
WheelBuilder = ShimmedPathCollection("WheelBuilder", ImportTypes.CLASS)
|
||||
WheelBuilder.create_path("wheel.WheelBuilder", "7.0.0", "19.9")
|
||||
WheelBuilder.create_path("wheel_builder.WheelBuilder", "20.0", "9999")
|
||||
|
||||
build = ShimmedPathCollection("build", ImportTypes.FUNCTION)
|
||||
build.create_path("wheel_builder.build", "19.9", "9999")
|
||||
|
||||
build_one = ShimmedPathCollection("build_one", ImportTypes.FUNCTION)
|
||||
build_one.create_path("wheel_builder._build_one", "19.9", "9999")
|
||||
|
||||
build_one_inside_env = ShimmedPathCollection("build_one_inside_env", ImportTypes.FUNCTION)
|
||||
build_one_inside_env.create_path("wheel_builder._build_one_inside_env", "19.9", "9999")
|
||||
|
||||
AbstractDistribution = ShimmedPathCollection("AbstractDistribution", ImportTypes.CLASS)
|
||||
AbstractDistribution.create_path(
|
||||
@@ -1075,11 +1108,14 @@ SourceDistribution.create_path(
|
||||
SourceDistribution.create_path(
|
||||
"distributions.source.legacy.SourceDistribution", "19.3.0", "19.9"
|
||||
)
|
||||
SourceDistribution.create_path("distributions.source.SourceDistribution", "20.0", "9999")
|
||||
SourceDistribution.create_path("distributions.sdist.SourceDistribution", "20.0", "9999")
|
||||
|
||||
WheelDistribution = ShimmedPathCollection("WheelDistribution", ImportTypes.CLASS)
|
||||
WheelDistribution.create_path("distributions.wheel.WheelDistribution", "19.1.2", "9999")
|
||||
|
||||
Downloader = ShimmedPathCollection("Downloader", ImportTypes.CLASS)
|
||||
Downloader.create_path("network.download.Downloader", "20.0.0", "9999")
|
||||
|
||||
PyPI = ShimmedPathCollection("PyPI", ImportTypes.ATTRIBUTE)
|
||||
PyPI.create_path("models.index.PyPI", "7.0.0", "9999")
|
||||
|
||||
@@ -1095,7 +1131,7 @@ DEV_PKGS.set_default({"setuptools", "pip", "distribute", "wheel"})
|
||||
get_package_finder = ShimmedPathCollection("get_package_finder", ImportTypes.FUNCTION)
|
||||
get_package_finder.set_default(
|
||||
functools.partial(
|
||||
backports.get_package_finder,
|
||||
compat.get_package_finder,
|
||||
install_cmd_provider=InstallCommand,
|
||||
target_python_builder=TargetPython.shim(),
|
||||
)
|
||||
@@ -1105,10 +1141,12 @@ get_package_finder.set_default(
|
||||
make_preparer = ShimmedPathCollection("make_preparer", ImportTypes.FUNCTION)
|
||||
make_preparer.set_default(
|
||||
functools.partial(
|
||||
backports.make_preparer,
|
||||
compat.make_preparer,
|
||||
install_cmd_provider=InstallCommand,
|
||||
preparer_fn=RequirementPreparer,
|
||||
downloader_provider=Downloader,
|
||||
req_tracker_fn=get_requirement_tracker,
|
||||
finder_provider=get_package_finder,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1116,7 +1154,7 @@ make_preparer.set_default(
|
||||
get_resolver = ShimmedPathCollection("get_resolver", ImportTypes.FUNCTION)
|
||||
get_resolver.set_default(
|
||||
functools.partial(
|
||||
backports.get_resolver,
|
||||
compat.get_resolver,
|
||||
install_cmd_provider=InstallCommand,
|
||||
resolver_fn=Resolver,
|
||||
install_req_provider=install_req_from_req_string,
|
||||
@@ -1129,7 +1167,7 @@ get_resolver.set_default(
|
||||
get_requirement_set = ShimmedPathCollection("get_requirement_set", ImportTypes.FUNCTION)
|
||||
get_requirement_set.set_default(
|
||||
functools.partial(
|
||||
backports.get_requirement_set,
|
||||
compat.get_requirement_set,
|
||||
install_cmd_provider=InstallCommand,
|
||||
req_set_provider=RequirementSet,
|
||||
)
|
||||
@@ -1139,7 +1177,7 @@ get_requirement_set.set_default(
|
||||
resolve = ShimmedPathCollection("resolve", ImportTypes.FUNCTION)
|
||||
resolve.set_default(
|
||||
functools.partial(
|
||||
backports.resolve,
|
||||
compat.resolve,
|
||||
install_cmd_provider=InstallCommand,
|
||||
reqset_provider=get_requirement_set,
|
||||
finder_provider=get_package_finder,
|
||||
@@ -1148,5 +1186,22 @@ resolve.set_default(
|
||||
format_control_provider=FormatControl,
|
||||
make_preparer_provider=make_preparer,
|
||||
req_tracker_provider=get_requirement_tracker,
|
||||
tempdir_manager_provider=global_tempdir_manager,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
build_wheel = ShimmedPathCollection("build_wheel", ImportTypes.FUNCTION)
|
||||
build_wheel.set_default(
|
||||
functools.partial(
|
||||
compat.build_wheel,
|
||||
install_command_provider=InstallCommand,
|
||||
wheel_cache_provider=WheelCache,
|
||||
wheel_builder_provider=WheelBuilder,
|
||||
build_one_provider=build_one,
|
||||
build_one_inside_env_provider=build_one_inside_env,
|
||||
build_many_provider=build,
|
||||
preparer_provider=make_preparer,
|
||||
format_control_provider=FormatControl,
|
||||
)
|
||||
)
|
||||
|
||||
Vendored
+3
@@ -1,4 +1,7 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
"""
|
||||
Main module with magic self-replacement mechanisms to handle import speedups.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import sys
|
||||
|
||||
Vendored
+3
@@ -1,4 +1,7 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
"""
|
||||
Shared utility functions which are not specific to any particular module.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import contextlib
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ from .exceptions import InvalidPythonVersion
|
||||
from .models import SystemPath, WindowsFinder
|
||||
from .pythonfinder import Finder
|
||||
|
||||
__version__ = "1.2.2.dev0"
|
||||
__version__ = "1.2.2"
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
Vendored
+10
-12
@@ -1,10 +1,7 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
import click
|
||||
import crayons
|
||||
|
||||
from . import __version__
|
||||
from .pythonfinder import Finder
|
||||
@@ -32,10 +29,11 @@ def cli(
|
||||
if version:
|
||||
click.echo(
|
||||
"{0} version {1}".format(
|
||||
crayons.white("PythonFinder", bold=True), crayons.yellow(__version__)
|
||||
click.style("PythonFinder", fg="white", bold=True),
|
||||
click.style(str(__version__), fg="yellow")
|
||||
)
|
||||
)
|
||||
sys.exit(0)
|
||||
ctx.exit()
|
||||
finder = Finder(ignore_unsupported=ignore_unsupported)
|
||||
if findall:
|
||||
versions = [v for v in finder.find_all_python_versions()]
|
||||
@@ -54,7 +52,7 @@ def cli(
|
||||
),
|
||||
fg="yellow",
|
||||
)
|
||||
sys.exit(0)
|
||||
ctx.exit()
|
||||
else:
|
||||
click.secho(
|
||||
"ERROR: No valid python versions found! Check your path and try again.",
|
||||
@@ -78,22 +76,22 @@ def cli(
|
||||
),
|
||||
fg="yellow",
|
||||
)
|
||||
sys.exit(0)
|
||||
ctx.exit()
|
||||
else:
|
||||
click.secho("Failed to find matching executable...", fg="yellow")
|
||||
sys.exit(1)
|
||||
ctx.exit(1)
|
||||
elif which:
|
||||
found = finder.system_path.which(which.strip())
|
||||
if found:
|
||||
click.secho("Found Executable: {0}".format(found), fg="white")
|
||||
sys.exit(0)
|
||||
ctx.exit()
|
||||
else:
|
||||
click.secho("Failed to find matching executable...", fg="yellow")
|
||||
sys.exit(1)
|
||||
ctx.exit(1)
|
||||
else:
|
||||
click.echo("Please provide a command", color="red")
|
||||
sys.exit(1)
|
||||
sys.exit()
|
||||
ctx.exit(1)
|
||||
ctx.exit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
import sys
|
||||
|
||||
import six
|
||||
|
||||
if sys.version_info[:2] <= (3, 4):
|
||||
from pipenv.vendor.pathlib2 import Path # type: ignore # noqa
|
||||
else:
|
||||
from pathlib import Path
|
||||
|
||||
if six.PY3:
|
||||
from functools import lru_cache
|
||||
from builtins import TimeoutError
|
||||
else:
|
||||
from backports.functools_lru_cache import lru_cache # type: ignore # noqa
|
||||
|
||||
class TimeoutError(OSError):
|
||||
pass
|
||||
|
||||
|
||||
def getpreferredencoding():
|
||||
import locale
|
||||
# Borrowed from Invoke
|
||||
# (see https://github.com/pyinvoke/invoke/blob/93af29d/invoke/runners.py#L881)
|
||||
_encoding = locale.getpreferredencoding(False)
|
||||
if six.PY2 and not sys.platform == "win32":
|
||||
_default_encoding = locale.getdefaultlocale()[1]
|
||||
if _default_encoding is not None:
|
||||
_encoding = _default_encoding
|
||||
return _encoding
|
||||
|
||||
|
||||
DEFAULT_ENCODING = getpreferredencoding()
|
||||
|
||||
|
||||
def fs_str(string):
|
||||
"""Encodes a string into the proper filesystem encoding"""
|
||||
|
||||
if isinstance(string, str):
|
||||
return string
|
||||
assert not isinstance(string, bytes)
|
||||
return string.encode(DEFAULT_ENCODING)
|
||||
+2
-2
@@ -7,8 +7,8 @@ from collections import defaultdict
|
||||
|
||||
import attr
|
||||
import six
|
||||
from vistir.compat import fs_str
|
||||
|
||||
from ..compat import fs_str
|
||||
from ..environment import MYPY_RUNNING
|
||||
from ..exceptions import InvalidPythonVersion
|
||||
from ..utils import (
|
||||
@@ -35,7 +35,7 @@ if MYPY_RUNNING:
|
||||
TypeVar,
|
||||
Type,
|
||||
)
|
||||
from vistir.compat import Path
|
||||
from ..compat import Path # noqa
|
||||
|
||||
BaseFinderType = TypeVar("BaseFinderType")
|
||||
|
||||
|
||||
+2
-2
@@ -10,8 +10,7 @@ from itertools import chain
|
||||
import attr
|
||||
import six
|
||||
from cached_property import cached_property
|
||||
from vistir.compat import Path, fs_str
|
||||
from vistir.misc import dedup
|
||||
from ..compat import Path, fs_str
|
||||
|
||||
from ..environment import (
|
||||
ASDF_DATA_DIR,
|
||||
@@ -26,6 +25,7 @@ from ..exceptions import InvalidPythonVersion
|
||||
from ..utils import (
|
||||
Iterable,
|
||||
Sequence,
|
||||
dedup,
|
||||
ensure_path,
|
||||
expand_paths,
|
||||
filter_pythons,
|
||||
|
||||
+1
-1
@@ -10,8 +10,8 @@ from collections import defaultdict
|
||||
import attr
|
||||
import six
|
||||
from packaging.version import Version
|
||||
from vistir.compat import Path, lru_cache
|
||||
|
||||
from ..compat import Path, lru_cache
|
||||
from ..environment import ASDF_DATA_DIR, MYPY_RUNNING, PYENV_ROOT, SYSTEM_ARCH
|
||||
from ..exceptions import InvalidPythonVersion
|
||||
from ..utils import (
|
||||
|
||||
+23
-7
@@ -7,9 +7,9 @@ import os
|
||||
|
||||
import six
|
||||
from click import secho
|
||||
from vistir.compat import lru_cache
|
||||
|
||||
from . import environment
|
||||
from .compat import lru_cache
|
||||
from .exceptions import InvalidPythonVersion
|
||||
from .utils import Iterable, filter_pythons, version_re
|
||||
|
||||
@@ -51,7 +51,8 @@ class Finder(object):
|
||||
:param system: bool, optional
|
||||
:param global_search: Whether to search the global path from os.environ, defaults to True
|
||||
:param global_search: bool, optional
|
||||
:param ignore_unsupported: Whether to ignore unsupported python versions, if False, an error is raised, defaults to True
|
||||
:param ignore_unsupported: Whether to ignore unsupported python versions, if False, an
|
||||
error is raised, defaults to True
|
||||
:param ignore_unsupported: bool, optional
|
||||
:param bool sort_by_path: Whether to always sort by path
|
||||
:returns: a :class:`~pythonfinder.pythonfinder.Finder` object.
|
||||
@@ -133,8 +134,16 @@ class Finder(object):
|
||||
return self.system_path.which(exe)
|
||||
|
||||
@classmethod
|
||||
def parse_major(cls, major, minor=None, patch=None, pre=None, dev=None, arch=None):
|
||||
# type: (Optional[str], Optional[int], Optional[int], Optional[bool], Optional[bool], Optional[str]) -> Dict[str, Union[int, str, bool, None]]
|
||||
def parse_major(
|
||||
cls,
|
||||
major, # type: Optional[str]
|
||||
minor=None, # type: Optional[int]
|
||||
patch=None, # type: Optional[int]
|
||||
pre=None, # type: Optional[bool]
|
||||
dev=None, # type: Optional[bool]
|
||||
arch=None, # type: Optional[str]
|
||||
):
|
||||
# type: (...) -> Dict[str, Union[int, str, bool, None]]
|
||||
from .models import PythonVersion
|
||||
|
||||
major_is_str = major and isinstance(major, six.string_types)
|
||||
@@ -289,11 +298,18 @@ class Finder(object):
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def find_all_python_versions(
|
||||
self, major=None, minor=None, patch=None, pre=None, dev=None, arch=None, name=None
|
||||
self,
|
||||
major=None, # type: Optional[Union[str, int]]
|
||||
minor=None, # type: Optional[int]
|
||||
patch=None, # type: Optional[int]
|
||||
pre=None, # type: Optional[bool]
|
||||
dev=None, # type: Optional[bool]
|
||||
arch=None, # type: Optional[str]
|
||||
name=None, # type: Optional[str]
|
||||
):
|
||||
# type: (Optional[Union[str, int]], Optional[int], Optional[int], Optional[bool], Optional[bool], Optional[str], Optional[str]) -> List[PathEntry]
|
||||
# type: (...) -> List[PathEntry]
|
||||
version_sort = operator.attrgetter("as_python.version_sort")
|
||||
python_version_dict = getattr(self.system_path, "python_version_dict")
|
||||
python_version_dict = getattr(self.system_path, "python_version_dict", {})
|
||||
if python_version_dict:
|
||||
paths = (
|
||||
path
|
||||
|
||||
Vendored
+38
-28
@@ -5,14 +5,16 @@ import io
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from collections import OrderedDict
|
||||
from fnmatch import fnmatch
|
||||
from threading import Timer
|
||||
|
||||
import attr
|
||||
import six
|
||||
import vistir
|
||||
from packaging.version import LegacyVersion, Version
|
||||
|
||||
from .compat import Path, lru_cache, TimeoutError # noqa
|
||||
from .environment import MYPY_RUNNING, PYENV_ROOT, SUBPROCESS_TIMEOUT
|
||||
from .exceptions import InvalidPythonVersion
|
||||
|
||||
@@ -27,11 +29,6 @@ from six.moves import Iterable # type: ignore # noqa # isort:skip
|
||||
from six.moves import Sequence # type: ignore # noqa # isort:skip
|
||||
# fmt: on
|
||||
|
||||
try:
|
||||
from functools import lru_cache
|
||||
except ImportError:
|
||||
from backports.functools_lru_cache import lru_cache # type: ignore # noqa
|
||||
|
||||
if MYPY_RUNNING:
|
||||
from typing import Any, Union, List, Callable, Set, Tuple, Dict, Optional, Iterator
|
||||
from attr.validators import _OptionalValidator # type: ignore
|
||||
@@ -98,21 +95,26 @@ def get_python_version(path):
|
||||
"-c",
|
||||
"import sys; print('.'.join([str(i) for i in sys.version_info[:3]]))",
|
||||
]
|
||||
subprocess_kwargs = {
|
||||
"env": os.environ.copy(),
|
||||
"universal_newlines": True,
|
||||
"stdout": subprocess.PIPE,
|
||||
"stderr": subprocess.PIPE,
|
||||
"shell": False,
|
||||
}
|
||||
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
|
||||
timer = Timer(SUBPROCESS_TIMEOUT, c.kill)
|
||||
try:
|
||||
c = vistir.misc.run(
|
||||
version_cmd,
|
||||
block=True,
|
||||
nospin=True,
|
||||
return_object=True,
|
||||
combine_stderr=False,
|
||||
write_to_stdout=False,
|
||||
)
|
||||
timer = Timer(SUBPROCESS_TIMEOUT, c.kill)
|
||||
out, _ = c.communicate()
|
||||
except (SystemExit, KeyboardInterrupt, TimeoutError):
|
||||
c.terminate()
|
||||
out, _ = c.communicate()
|
||||
raise
|
||||
except OSError:
|
||||
raise InvalidPythonVersion("%s is not a valid python path" % path)
|
||||
if not c.out:
|
||||
if not out:
|
||||
raise InvalidPythonVersion("%s is not a valid python path" % path)
|
||||
return c.out.strip()
|
||||
return out.strip()
|
||||
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
@@ -190,13 +192,13 @@ def path_is_executable(path):
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def path_is_known_executable(path):
|
||||
# type: (vistir.compat.Path) -> bool
|
||||
# type: (Path) -> bool
|
||||
"""
|
||||
Returns whether a given path is a known executable from known executable extensions
|
||||
or has the executable bit toggled.
|
||||
|
||||
:param path: The path to the target executable.
|
||||
:type path: :class:`~vistir.compat.Path`
|
||||
:type path: :class:`~Path`
|
||||
:return: True if the path has chmod +x, or is a readable, known executable extension.
|
||||
:rtype: bool
|
||||
"""
|
||||
@@ -229,12 +231,12 @@ def looks_like_python(name):
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def path_is_python(path):
|
||||
# type: (vistir.compat.Path) -> bool
|
||||
# type: (Path) -> bool
|
||||
"""
|
||||
Determine whether the supplied path is executable and looks like a possible path to python.
|
||||
|
||||
:param path: The path to an executable.
|
||||
:type path: :class:`~vistir.compat.Path`
|
||||
:type path: :class:`~Path`
|
||||
:return: Whether the provided path is an executable path to python.
|
||||
:rtype: bool
|
||||
"""
|
||||
@@ -278,7 +280,7 @@ def path_is_pythoncore(path):
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def ensure_path(path):
|
||||
# type: (Union[vistir.compat.Path, str]) -> vistir.compat.Path
|
||||
# type: (Union[Path, str]) -> Path
|
||||
"""
|
||||
Given a path (either a string or a Path object), expand variables and return a Path object.
|
||||
|
||||
@@ -288,9 +290,9 @@ def ensure_path(path):
|
||||
:rtype: :class:`~pathlib.Path`
|
||||
"""
|
||||
|
||||
if isinstance(path, vistir.compat.Path):
|
||||
if isinstance(path, Path):
|
||||
return path
|
||||
path = vistir.compat.Path(os.path.expandvars(path))
|
||||
path = Path(os.path.expandvars(path))
|
||||
return path.absolute()
|
||||
|
||||
|
||||
@@ -313,10 +315,10 @@ def normalize_path(path):
|
||||
|
||||
@lru_cache(maxsize=1024)
|
||||
def filter_pythons(path):
|
||||
# type: (Union[str, vistir.compat.Path]) -> Iterable
|
||||
# type: (Union[str, Path]) -> Iterable
|
||||
"""Return all valid pythons in a given path"""
|
||||
if not isinstance(path, vistir.compat.Path):
|
||||
path = vistir.compat.Path(str(path))
|
||||
if not isinstance(path, Path):
|
||||
path = Path(str(path))
|
||||
if not path.is_dir():
|
||||
return path if path_is_python(path) else None
|
||||
return filter(path_is_python, path.iterdir())
|
||||
@@ -377,7 +379,7 @@ def split_version_and_name(
|
||||
patch=None, # type: Optional[Union[str, int]]
|
||||
name=None, # type: Optional[str]
|
||||
):
|
||||
# type: (...) -> Tuple[Optional[Union[str, int]], Optional[Union[str, int]], Optional[Union[str, int]], Optional[str]]
|
||||
# type: (...) -> Tuple[Optional[Union[str, int]], Optional[Union[str, int]], Optional[Union[str, int]], Optional[str]] # noqa
|
||||
if isinstance(major, six.string_types) and not minor and not patch:
|
||||
# Only proceed if this is in the format "x.y.z" or similar
|
||||
if major.isdigit() or (major.count(".") > 0 and major[0].isdigit()):
|
||||
@@ -437,3 +439,11 @@ def expand_paths(path, only_python=True):
|
||||
else:
|
||||
if path is not None and path.is_python and path.as_python is not None:
|
||||
yield path
|
||||
|
||||
|
||||
def dedup(iterable):
|
||||
# type: (Iterable) -> Iterable
|
||||
"""Deduplicate an iterable object like iter(set(iterable)) but
|
||||
order-reserved.
|
||||
"""
|
||||
return iter(OrderedDict.fromkeys(iterable))
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ from .models.lockfile import Lockfile
|
||||
from .models.pipfile import Pipfile
|
||||
from .models.requirements import Requirement
|
||||
|
||||
__version__ = "1.5.4.dev0"
|
||||
__version__ = "1.5.4"
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+21
-12
@@ -32,6 +32,11 @@ from .utils import (
|
||||
version_from_ireq,
|
||||
)
|
||||
|
||||
try:
|
||||
from contextlib import ExitStack
|
||||
except ImportError:
|
||||
from contextlib2 import ExitStack
|
||||
|
||||
if MYPY_RUNNING:
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -575,18 +580,22 @@ def start_resolver(finder=None, session=None, wheel_cache=None):
|
||||
_build_dir = create_tracked_tempdir(fs_str("build"))
|
||||
_source_dir = create_tracked_tempdir(fs_str("source"))
|
||||
try:
|
||||
with pip_shims.shims.make_preparer(
|
||||
options=pip_options,
|
||||
finder=finder,
|
||||
session=session,
|
||||
build_dir=_build_dir,
|
||||
src_dir=_source_dir,
|
||||
download_dir=download_dir,
|
||||
wheel_download_dir=WHEEL_DOWNLOAD_DIR,
|
||||
progress_bar="off",
|
||||
build_isolation=False,
|
||||
install_cmd=pip_command,
|
||||
) as preparer:
|
||||
with ExitStack() as ctx:
|
||||
ctx.enter_context(pip_shims.shims.global_tempdir_manager())
|
||||
preparer = ctx.enter_context(
|
||||
pip_shims.shims.make_preparer(
|
||||
options=pip_options,
|
||||
finder=finder,
|
||||
session=session,
|
||||
build_dir=_build_dir,
|
||||
src_dir=_source_dir,
|
||||
download_dir=download_dir,
|
||||
wheel_download_dir=WHEEL_DOWNLOAD_DIR,
|
||||
progress_bar="off",
|
||||
build_isolation=False,
|
||||
install_cmd=pip_command,
|
||||
)
|
||||
)
|
||||
resolver = pip_shims.shims.get_resolver(
|
||||
finder=finder,
|
||||
ignore_dependencies=False,
|
||||
|
||||
-23
@@ -196,7 +196,6 @@ def _get_specs(specset):
|
||||
return sorted(result, key=operator.itemgetter(1))
|
||||
|
||||
|
||||
# TODO: Rename this to something meaningful
|
||||
def _group_by_op(specs):
|
||||
# type: (Union[Set[Specifier], SpecifierSet]) -> Iterator
|
||||
specs = [_get_specs(x) for x in list(specs)]
|
||||
@@ -206,7 +205,6 @@ def _group_by_op(specs):
|
||||
return grouping
|
||||
|
||||
|
||||
# TODO: rename this to something meaningful
|
||||
def normalize_specifier_set(specs):
|
||||
# type: (Union[str, SpecifierSet]) -> Optional[Set[Specifier]]
|
||||
"""Given a specifier set, a string, or an iterable, normalize the specifiers
|
||||
@@ -237,8 +235,6 @@ def normalize_specifier_set(specs):
|
||||
return normalize_specifier_set(SpecifierSet(",".join(spec_list)))
|
||||
|
||||
|
||||
# TODO: Check if this is used by anything public otherwise make it private
|
||||
# And rename it to something meaningful
|
||||
def get_sorted_version_string(version_set):
|
||||
# type: (Set[AnyStr]) -> AnyStr
|
||||
version_list = sorted(
|
||||
@@ -248,9 +244,6 @@ def get_sorted_version_string(version_set):
|
||||
return version
|
||||
|
||||
|
||||
# TODO: Rename this to something meaningful
|
||||
# TODO: Add a deprecation decorator and deprecate this -- i'm sure it's used
|
||||
# in other libraries
|
||||
@lru_cache(maxsize=1024)
|
||||
def cleanup_pyspecs(specs, joiner="or"):
|
||||
specs = normalize_specifier_set(specs)
|
||||
@@ -295,7 +288,6 @@ def cleanup_pyspecs(specs, joiner="or"):
|
||||
return sorted([(k, v) for k, v in results.items()], key=operator.itemgetter(1))
|
||||
|
||||
|
||||
# TODO: Rename this to something meaningful
|
||||
@lru_cache(maxsize=1024)
|
||||
def fix_version_tuple(version_tuple):
|
||||
# type: (Tuple[AnyStr, AnyStr]) -> Tuple[AnyStr, AnyStr]
|
||||
@@ -310,7 +302,6 @@ def fix_version_tuple(version_tuple):
|
||||
return (op, version)
|
||||
|
||||
|
||||
# TODO: Rename this to something meaningful, deprecate it (See prior function)
|
||||
@lru_cache(maxsize=128)
|
||||
def get_versions(specset, group_by_operator=True):
|
||||
# type: (Union[Set[Specifier], SpecifierSet], bool) -> List[Tuple[STRING_TYPE, STRING_TYPE]]
|
||||
@@ -599,7 +590,6 @@ def get_specset(marker_list):
|
||||
return specifiers
|
||||
|
||||
|
||||
# TODO: Refactor this (reduce complexity)
|
||||
def parse_marker_dict(marker_dict):
|
||||
op = marker_dict["op"]
|
||||
lhs = marker_dict["lhs"]
|
||||
@@ -709,16 +699,3 @@ def marker_from_specifier(spec):
|
||||
marker_segments.append(format_pyversion(marker_segment))
|
||||
marker_str = " and ".join(marker_segments).replace('"', "'")
|
||||
return Marker(marker_str)
|
||||
|
||||
|
||||
def merge_markers(m1, m2):
|
||||
# type: (Marker, Marker) -> Optional[Marker]
|
||||
if not all((m1, m2)):
|
||||
return next(iter(v for v in (m1, m2) if v), None)
|
||||
m1 = _ensure_marker(m1)
|
||||
m2 = _ensure_marker(m2)
|
||||
_markers = [] # type: List[Marker]
|
||||
for marker in (m1, m2):
|
||||
_markers.append(str(marker))
|
||||
marker_str = " and ".join([normalize_marker_str(m) for m in _markers if m])
|
||||
return _ensure_marker(normalize_marker_str(marker_str))
|
||||
|
||||
+128
-62
@@ -19,7 +19,6 @@ import packaging.utils
|
||||
import packaging.version
|
||||
import pep517.envbuild
|
||||
import pep517.wrappers
|
||||
import pkg_resources.extern.packaging.requirements as pkg_resources_requirements
|
||||
import six
|
||||
from appdirs import user_cache_dir
|
||||
from distlib.wheel import Wheel
|
||||
@@ -43,6 +42,11 @@ from .utils import (
|
||||
strip_extras_markers_from_requirement,
|
||||
)
|
||||
|
||||
try:
|
||||
import pkg_resources.extern.packaging.requirements as pkg_resources_requirements
|
||||
except ImportError:
|
||||
pkg_resources_requirements = None
|
||||
|
||||
try:
|
||||
from setuptools.dist import distutils, Distribution
|
||||
except ImportError:
|
||||
@@ -76,6 +80,7 @@ if MYPY_RUNNING:
|
||||
AnyStr,
|
||||
Sequence,
|
||||
)
|
||||
import requests
|
||||
from pip_shims.shims import InstallRequirement, PackageFinder
|
||||
from pkg_resources import (
|
||||
PathMetadata,
|
||||
@@ -200,7 +205,9 @@ def make_base_requirements(reqs):
|
||||
for req in reqs:
|
||||
if isinstance(req, BaseRequirement):
|
||||
requirements.add(req)
|
||||
elif isinstance(req, pkg_resources_requirements.Requirement):
|
||||
elif pkg_resources_requirements is not None and isinstance(
|
||||
req, pkg_resources_requirements.Requirement
|
||||
):
|
||||
requirements.add(BaseRequirement.from_req(req))
|
||||
elif req and isinstance(req, six.string_types) and not req.startswith("#"):
|
||||
requirements.add(BaseRequirement.from_string(req))
|
||||
@@ -287,8 +294,11 @@ def get_extras_from_setupcfg(parser):
|
||||
return extras
|
||||
|
||||
|
||||
def parse_setup_cfg(setup_cfg_contents, base_dir):
|
||||
# type: (S, S) -> Dict[S, Union[S, None, Set[BaseRequirement], List[S], Dict[STRING_TYPE, Tuple[BaseRequirement]]]]
|
||||
def parse_setup_cfg(
|
||||
setup_cfg_contents, # type: S
|
||||
base_dir, # type: S
|
||||
):
|
||||
# type: (...) -> Dict[S, Union[S, None, Set[BaseRequirement], List[S], Dict[STRING_TYPE, Tuple[BaseRequirement]]]]
|
||||
default_opts = {
|
||||
"metadata": {"name": "", "version": ""},
|
||||
"options": {
|
||||
@@ -639,21 +649,42 @@ def get_metadata_from_dist(dist):
|
||||
}
|
||||
|
||||
|
||||
class Analyzer(ast.NodeVisitor):
|
||||
OP_MAP = {
|
||||
ast.Add: operator.add,
|
||||
ast.Sub: operator.sub,
|
||||
ast.Mult: operator.mul,
|
||||
ast.Div: operator.floordiv,
|
||||
ast.Mod: operator.mod,
|
||||
ast.Pow: operator.pow,
|
||||
ast.LShift: operator.lshift,
|
||||
ast.RShift: operator.rshift,
|
||||
ast.BitAnd: operator.and_,
|
||||
ast.BitOr: operator.or_,
|
||||
ast.BitXor: operator.xor
|
||||
}
|
||||
AST_BINOP_MAP = dict(
|
||||
(
|
||||
(ast.Add, operator.add),
|
||||
(ast.Sub, operator.sub),
|
||||
(ast.Mult, operator.mul),
|
||||
(ast.Div, operator.floordiv),
|
||||
(ast.Mod, operator.mod),
|
||||
(ast.Pow, operator.pow),
|
||||
(ast.LShift, operator.lshift),
|
||||
(ast.RShift, operator.rshift),
|
||||
(ast.BitAnd, operator.and_),
|
||||
(ast.BitOr, operator.or_),
|
||||
(ast.BitXor, operator.xor),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
AST_COMPARATORS = dict(
|
||||
(
|
||||
(ast.Lt, operator.lt),
|
||||
(ast.LtE, operator.le),
|
||||
(ast.Eq, operator.eq),
|
||||
(ast.Gt, operator.gt),
|
||||
(ast.GtE, operator.ge),
|
||||
(ast.NotEq, operator.ne),
|
||||
(ast.Is, operator.is_),
|
||||
(ast.IsNot, operator.is_not),
|
||||
(ast.And, operator.and_),
|
||||
(ast.Or, operator.or_),
|
||||
(ast.Not, operator.not_),
|
||||
(ast.In, operator.contains),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class Analyzer(ast.NodeVisitor):
|
||||
def __init__(self):
|
||||
self.name_types = []
|
||||
self.function_map = {} # type: Dict[Any, Any]
|
||||
@@ -677,12 +708,7 @@ class Analyzer(ast.NodeVisitor):
|
||||
super(Analyzer, self).generic_visit(node)
|
||||
|
||||
def visit_BinOp(self, node):
|
||||
left = ast_unparse(node.left, initial_mapping=True)
|
||||
right = ast_unparse(node.right, initial_mapping=True)
|
||||
op = ast_unparse(node.op, initial_mapping=True)
|
||||
node.left = left
|
||||
node.right = right
|
||||
node.op = op
|
||||
node = ast_unparse(node, initial_mapping=True)
|
||||
self.binOps.append(node)
|
||||
|
||||
def unmap_binops(self):
|
||||
@@ -705,6 +731,11 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
|
||||
unparse = partial(
|
||||
ast_unparse, initial_mapping=initial_mapping, analyzer=analyzer, recurse=recurse
|
||||
)
|
||||
if getattr(ast, "Constant", None):
|
||||
constant = (ast.Constant, ast.Ellipsis)
|
||||
else:
|
||||
constant = ast.Ellipsis
|
||||
unparsed = item
|
||||
if isinstance(item, ast.Dict):
|
||||
unparsed = dict(zip(unparse(item.keys), unparse(item.values)))
|
||||
elif isinstance(item, ast.List):
|
||||
@@ -715,37 +746,27 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
|
||||
unparsed = item.s
|
||||
elif isinstance(item, ast.Subscript):
|
||||
unparsed = unparse(item.value)
|
||||
elif any(isinstance(item, k) for k in AST_BINOP_MAP.keys()):
|
||||
unparsed = AST_BINOP_MAP[type(item)]
|
||||
elif isinstance(item, ast.Num):
|
||||
unparsed = item.n
|
||||
elif isinstance(item, ast.BinOp):
|
||||
if analyzer and item in analyzer.binOps_map:
|
||||
unparsed = analyzer.binOps_map[item]
|
||||
else:
|
||||
right_item = unparse(item.right)
|
||||
left_item = unparse(item.left)
|
||||
if type(item.op) in Analyzer.OP_MAP:
|
||||
item.op = Analyzer.OP_MAP[type(item.op)]
|
||||
op = getattr(item, "op", None)
|
||||
op_func = unparse(op) if op is not None else op
|
||||
if not initial_mapping:
|
||||
if not all(
|
||||
isinstance(side, (six.string_types, int, float, list, tuple))
|
||||
for side in (left_item, right_item)
|
||||
):
|
||||
if type(item.op) in Analyzer.OP_MAP:
|
||||
item = Analyzer.OP_MAP[type(item.op)](left_item, right_item)
|
||||
else:
|
||||
item.left = left_item
|
||||
item.right = right_item
|
||||
item.op = unparse(item.op)
|
||||
try:
|
||||
unparsed = item.op(left_item, right_item)
|
||||
except Exception:
|
||||
unparsed = item
|
||||
else:
|
||||
if type(item.op) in Analyzer.OP_MAP:
|
||||
item.op = Analyzer.OP_MAP[type(item.op)]
|
||||
try:
|
||||
unparsed = item.op(left_item, right_item)
|
||||
except Exception:
|
||||
unparsed = item
|
||||
try:
|
||||
unparsed = op_func(left_item, right_item)
|
||||
except Exception:
|
||||
unparsed = (left_item, op_func, right_item)
|
||||
else:
|
||||
item.left = left_item
|
||||
item.right = right_item
|
||||
item.op = op_func
|
||||
unparsed = item
|
||||
elif isinstance(item, ast.Name):
|
||||
if not initial_mapping:
|
||||
@@ -763,6 +784,48 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
|
||||
unparsed = item
|
||||
elif six.PY3 and isinstance(item, ast.NameConstant):
|
||||
unparsed = item.value
|
||||
elif any(isinstance(item, k) for k in AST_COMPARATORS.keys()):
|
||||
unparsed = AST_COMPARATORS[type(item)]
|
||||
elif isinstance(item, constant):
|
||||
unparsed = item.value
|
||||
elif isinstance(item, ast.Compare):
|
||||
if isinstance(item.left, ast.Attribute):
|
||||
import importlib
|
||||
|
||||
left = unparse(item.left)
|
||||
if "." in left:
|
||||
name, _, val = left.rpartition(".")
|
||||
left = getattr(importlib.import_module(name), val, left)
|
||||
comparators = []
|
||||
for comparator in item.comparators:
|
||||
right = unparse(comparator)
|
||||
if isinstance(comparator, ast.Attribute) and "." in right:
|
||||
name, _, val = right.rpartition(".")
|
||||
right = getattr(importlib.import_module(name), val, right)
|
||||
comparators.append(right)
|
||||
unparsed = (left, unparse(item.ops), comparators)
|
||||
elif isinstance(item, ast.IfExp):
|
||||
if initial_mapping:
|
||||
unparsed = item
|
||||
else:
|
||||
ops, truth_vals = [], []
|
||||
if isinstance(item.test, ast.Compare):
|
||||
left, ops, right = unparse(item.test)
|
||||
else:
|
||||
result = ast_unparse(item.test)
|
||||
if isinstance(result, dict):
|
||||
k, v = result.popitem()
|
||||
if not v:
|
||||
truth_vals = [False]
|
||||
for i, op in enumerate(ops):
|
||||
if i == 0:
|
||||
truth_vals.append(op(left, right[i]))
|
||||
else:
|
||||
truth_vals.append(op(right[i - 1], right[i]))
|
||||
if all(truth_vals):
|
||||
unparsed = unparse(item.body)
|
||||
else:
|
||||
unparsed = unparse(item.orelse)
|
||||
elif isinstance(item, ast.Attribute):
|
||||
attr_name = getattr(item, "value", None)
|
||||
attr_attr = getattr(item, "attr", None)
|
||||
@@ -791,9 +854,14 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
|
||||
func_name = unparse(item.func)
|
||||
except Exception:
|
||||
func_name = None
|
||||
if func_name:
|
||||
if isinstance(func_name, dict):
|
||||
unparsed.update(func_name)
|
||||
func_name = next(iter(func_name.keys()))
|
||||
for keyword in getattr(item, "keywords", []):
|
||||
unparsed[func_name].update(unparse(keyword))
|
||||
elif func_name:
|
||||
unparsed[func_name] = {}
|
||||
for keyword in item.keywords:
|
||||
for keyword in getattr(item, "keywords", []):
|
||||
unparsed[func_name].update(unparse(keyword))
|
||||
elif isinstance(item, ast.keyword):
|
||||
unparsed = {unparse(item.arg): unparse(item.value)}
|
||||
@@ -822,8 +890,6 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no
|
||||
unparsed = type(item)([unparse(el) for el in item])
|
||||
elif isinstance(item, six.string_types):
|
||||
unparsed = item
|
||||
else:
|
||||
return item
|
||||
return unparsed
|
||||
|
||||
|
||||
@@ -1532,17 +1598,17 @@ build-backend = "{1}"
|
||||
build_location_func(kwargs["build_dir"])
|
||||
ireq.ensure_has_source_dir(kwargs["src_dir"])
|
||||
src_dir = ireq.source_dir
|
||||
|
||||
ireq.populate_link(finder, False, False)
|
||||
pip_shims.shims.shim_unpack(
|
||||
link=ireq.link,
|
||||
location=kwargs["src_dir"],
|
||||
download_dir=download_dir,
|
||||
only_download=only_download,
|
||||
session=session,
|
||||
hashes=ireq.hashes(False),
|
||||
progress_bar="off",
|
||||
)
|
||||
with pip_shims.shims.global_tempdir_manager():
|
||||
ireq.populate_link(finder, False, False)
|
||||
pip_shims.shims.shim_unpack(
|
||||
link=ireq.link,
|
||||
location=kwargs["src_dir"],
|
||||
download_dir=download_dir,
|
||||
only_download=only_download,
|
||||
session=session,
|
||||
hashes=ireq.hashes(False),
|
||||
progress_bar="off",
|
||||
)
|
||||
created = cls.create(src_dir, subdirectory=subdir, ireq=ireq, kwargs=kwargs)
|
||||
return created
|
||||
|
||||
|
||||
+1
-1
@@ -723,7 +723,7 @@ def get_pinned_version(ireq):
|
||||
except AttributeError:
|
||||
raise TypeError("Expected InstallRequirement, not {}".format(type(ireq).__name__))
|
||||
|
||||
if getattr(ireq, "editable", False):
|
||||
if ireq.editable:
|
||||
raise ValueError("InstallRequirement is editable")
|
||||
if not specifier:
|
||||
raise ValueError("InstallRequirement has no version specification")
|
||||
|
||||
+5
-3
@@ -61,15 +61,17 @@ class VCSRepository(object):
|
||||
|
||||
def obtain(self):
|
||||
# type: () -> None
|
||||
lte_pip_19 = (
|
||||
pip_shims.parsed_pip_version.parsed_version < pip_shims.parse_version("19.0")
|
||||
lt_pip_19_2 = (
|
||||
pip_shims.parsed_pip_version.parsed_version < pip_shims.parse_version("19.2")
|
||||
)
|
||||
if lt_pip_19_2:
|
||||
self.repo_backend = self.repo_backend(self.url)
|
||||
if os.path.exists(
|
||||
self.checkout_directory
|
||||
) and not self.repo_backend.is_repository_directory(self.checkout_directory):
|
||||
self.repo_backend.unpack(self.checkout_directory)
|
||||
elif not os.path.exists(self.checkout_directory):
|
||||
if lte_pip_19:
|
||||
if lt_pip_19_2:
|
||||
self.repo_backend.obtain(self.checkout_directory)
|
||||
else:
|
||||
self.repo_backend.obtain(self.checkout_directory, self.parsed_url)
|
||||
|
||||
Vendored
+18
-17
@@ -1,45 +1,45 @@
|
||||
appdirs==1.4.3
|
||||
backports.shutil_get_terminal_size==1.0.0
|
||||
backports.weakref==1.0.post1
|
||||
click==7.0
|
||||
click==7.1.1
|
||||
click-completion==0.5.2
|
||||
click-didyoumean==0.0.3
|
||||
colorama==0.4.1
|
||||
colorama==0.4.3
|
||||
delegator.py==0.1.1
|
||||
pexpect==4.7.0
|
||||
pexpect==4.8.0
|
||||
ptyprocess==0.6.0
|
||||
python-dotenv==0.10.3
|
||||
first==2.0.1
|
||||
iso8601==0.1.12
|
||||
jinja2==2.10.3
|
||||
jinja2==2.11.1
|
||||
markupsafe==1.1.1
|
||||
parse==1.13.0
|
||||
parse==1.15.0
|
||||
pathlib2==2.3.5
|
||||
scandir==1.10
|
||||
pipdeptree==0.13.2
|
||||
pipreqs==0.4.10
|
||||
docopt==0.6.2
|
||||
yarg==0.1.9
|
||||
pythonfinder==1.2.1
|
||||
requests==2.22.0
|
||||
pythonfinder==1.2.2
|
||||
requests==2.23.0
|
||||
chardet==3.0.4
|
||||
idna==2.8
|
||||
urllib3==1.25.7
|
||||
idna==2.9
|
||||
urllib3==1.25.8
|
||||
certifi==2019.11.28
|
||||
requirementslib==1.5.3
|
||||
requirementslib==1.5.4
|
||||
attrs==19.3.0
|
||||
distlib==0.3.0
|
||||
packaging==19.2
|
||||
pyparsing==2.4.5
|
||||
packaging==20.3
|
||||
pyparsing==2.4.6
|
||||
git+https://github.com/sarugaku/plette.git@master#egg=plette
|
||||
tomlkit==0.5.8
|
||||
shellingham==1.3.1
|
||||
six==1.13.0
|
||||
shellingham==1.3.2
|
||||
six==1.14.0
|
||||
semver==2.9.0
|
||||
toml==0.10.0
|
||||
cached-property==1.5.1
|
||||
vistir==0.4.3
|
||||
pip-shims==0.4.0
|
||||
vistir==0.5.0
|
||||
pip-shims==0.5.1
|
||||
contextlib2==0.6.0.post1
|
||||
funcsigs==1.0.2
|
||||
enum34==1.1.6
|
||||
@@ -50,7 +50,8 @@ resolvelib==0.2.2
|
||||
backports.functools_lru_cache==1.5
|
||||
pep517==0.8.1
|
||||
zipp==0.6.0
|
||||
importlib_metadata==1.3.0
|
||||
importlib_metadata==1.5.1
|
||||
importlib-resources==1.4.0
|
||||
more-itertools==5.0.0
|
||||
git+https://github.com/sarugaku/passa.git@master#egg=passa
|
||||
orderedmultidict==1.0.1
|
||||
|
||||
Vendored
+1
-1
@@ -36,7 +36,7 @@ from .misc import (
|
||||
from .path import create_tracked_tempdir, create_tracked_tempfile, mkdir_p, rmtree
|
||||
from .spin import create_spinner
|
||||
|
||||
__version__ = "0.4.3"
|
||||
__version__ = "0.5.1"
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This Module is taken in full from the click project
|
||||
# This Module is taken in part from the click project and expanded
|
||||
# see https://github.com/pallets/click/blob/6cafd32/click/_winconsole.py
|
||||
# Copyright © 2014 by the Pallets team.
|
||||
|
||||
|
||||
+21
-14
@@ -5,7 +5,7 @@ import io
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from contextlib import closing, contextmanager
|
||||
|
||||
import six
|
||||
|
||||
@@ -285,20 +285,27 @@ def open_file(link, session=None, stream=True):
|
||||
# Remote URL
|
||||
headers = {"Accept-Encoding": "identity"}
|
||||
if not session:
|
||||
from requests import Session
|
||||
|
||||
session = Session()
|
||||
with session.get(link, headers=headers, stream=stream) 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()
|
||||
from requests import Session
|
||||
except ImportError:
|
||||
session = None
|
||||
else:
|
||||
session = Session()
|
||||
if session is None:
|
||||
with closing(six.moves.urllib.request.urlopen(link)) as f:
|
||||
yield f
|
||||
else:
|
||||
with session.get(link, headers=headers, stream=stream) 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()
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
||||
Vendored
+23
-6
@@ -30,6 +30,14 @@ from .compat import (
|
||||
fs_encode,
|
||||
)
|
||||
|
||||
# fmt: off
|
||||
if six.PY3:
|
||||
from urllib.parse import quote_from_bytes as quote
|
||||
else:
|
||||
from urllib import quote
|
||||
# fmt: on
|
||||
|
||||
|
||||
if IS_TYPE_CHECKING:
|
||||
from typing import Optional, Callable, Text, ByteString, AnyStr
|
||||
|
||||
@@ -158,13 +166,23 @@ def path_to_url(path):
|
||||
>>> path_to_url("/home/user/code/myrepo/myfile.zip")
|
||||
'file:///home/user/code/myrepo/myfile.zip'
|
||||
"""
|
||||
from .misc import to_text, to_bytes
|
||||
from .misc import to_bytes
|
||||
|
||||
if not path:
|
||||
return path
|
||||
path = to_bytes(path, encoding="utf-8")
|
||||
normalized_path = to_text(normalize_drive(os.path.abspath(path)), encoding="utf-8")
|
||||
return to_text(Path(normalized_path).as_uri(), encoding="utf-8")
|
||||
normalized_path = Path(normalize_drive(os.path.abspath(path))).as_posix()
|
||||
if os.name == "nt" and normalized_path[1] == ":":
|
||||
drive, _, path = normalized_path.partition(":")
|
||||
# XXX: This enables us to handle half-surrogates that were never
|
||||
# XXX: actually part of a surrogate pair, but were just incidentally
|
||||
# XXX: passed in as a piece of a filename
|
||||
quoted_path = quote(fs_encode(path))
|
||||
return fs_decode("file:///{0}:{1}".format(drive, quoted_path))
|
||||
# XXX: This is also here to help deal with incidental dangling surrogates
|
||||
# XXX: on linux, by making sure they are preserved during encoding so that
|
||||
# XXX: we can urlencode the backslash correctly
|
||||
bytes_path = to_bytes(normalized_path, errors="backslashreplace")
|
||||
return fs_decode("file://{0}".format(quote(bytes_path)))
|
||||
|
||||
|
||||
def url_to_path(url):
|
||||
@@ -174,7 +192,6 @@ def url_to_path(url):
|
||||
|
||||
Follows logic taken from pip's equivalent function
|
||||
"""
|
||||
from .misc import to_bytes
|
||||
|
||||
assert is_file_url(url), "Only file: urls can be converted to local paths"
|
||||
_, netloc, path, _, _ = urllib_parse.urlsplit(url)
|
||||
@@ -183,7 +200,7 @@ def url_to_path(url):
|
||||
netloc = "\\\\" + netloc
|
||||
|
||||
path = urllib_request.url2pathname(netloc + path)
|
||||
return to_bytes(path, encoding="utf-8")
|
||||
return urllib_parse.unquote(path)
|
||||
|
||||
|
||||
def is_valid_url(url):
|
||||
|
||||
Vendored
+1
-4
@@ -11,10 +11,7 @@ import codecs
|
||||
import os
|
||||
from collections import namedtuple
|
||||
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
import json
|
||||
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -61,7 +61,8 @@ HARDCODED_LICENSE_URLS = {
|
||||
'distlib': 'https://github.com/vsajip/distlib/raw/master/LICENSE.txt',
|
||||
'pythonfinder': 'https://raw.githubusercontent.com/techalchemy/pythonfinder/master/LICENSE.txt',
|
||||
'pyparsing': 'https://raw.githubusercontent.com/pyparsing/pyparsing/master/LICENSE',
|
||||
'resolvelib': 'https://raw.githubusercontent.com/sarugaku/resolvelib/master/LICENSE'
|
||||
'resolvelib': 'https://raw.githubusercontent.com/sarugaku/resolvelib/master/LICENSE',
|
||||
'funcsigs': 'https://raw.githubusercontent.com/aliles/funcsigs/master/LICENSE'
|
||||
}
|
||||
|
||||
FILE_WHITE_LIST = (
|
||||
|
||||
+23
-1
@@ -2,7 +2,7 @@ diff --git a/pipenv/vendor/pip_shims/__init__.py b/pipenv/vendor/pip_shims/__ini
|
||||
index 2af4166e..598b9ad8 100644
|
||||
--- a/pipenv/vendor/pip_shims/__init__.py
|
||||
+++ b/pipenv/vendor/pip_shims/__init__.py
|
||||
@@ -11,10 +11,13 @@ __version__ = "0.4.1.dev0"
|
||||
@@ -11,10 +11,13 @@ __version__ = "0.5.1"
|
||||
if "pip_shims" in sys.modules:
|
||||
# mainly to keep a reference to the old module on hand so it doesn't get
|
||||
# weakref'd away
|
||||
@@ -18,3 +18,25 @@ index 2af4166e..598b9ad8 100644
|
||||
module.shims = shims
|
||||
module.__dict__.update(
|
||||
{
|
||||
diff --git a/pipenv/vendor/pip_shims/compat.py b/../pip-shims/src/pip_shims/compat.py
|
||||
index ed99d970..63061a6a 100644
|
||||
--- a/pipenv/vendor/pip_shims/compat.py
|
||||
+++ b/../pip-shims/src/pip_shims/compat.py
|
||||
@@ -25,14 +25,14 @@ from .utils import (
|
||||
)
|
||||
|
||||
if sys.version_info[:2] < (3, 5):
|
||||
- from backports.tempfile import TemporaryDirectory
|
||||
+ from pipenv.vendor.vistir.compat import TemporaryDirectory
|
||||
else:
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
if six.PY3:
|
||||
from contextlib import ExitStack
|
||||
else:
|
||||
- from contextlib2 import ExitStack
|
||||
+ from pipenv.vendor.contextlib2 import ExitStack
|
||||
|
||||
|
||||
if MYPY_RUNNING:
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/pipenv/vendor/pythonfinder/compat.py b/pipenv/vendor/pythonfinder/compat.py
|
||||
index 6fb4542f..d76c4efc 100644
|
||||
--- a/pipenv/vendor/pythonfinder/compat.py
|
||||
+++ b/pipenv/vendor/pythonfinder/compat.py
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
import six
|
||||
|
||||
if sys.version_info[:2] <= (3, 4):
|
||||
- from pathlib2 import Path # type: ignore # noqa
|
||||
+ from pipenv.vendor.pathlib2 import Path # type: ignore # noqa
|
||||
else:
|
||||
from pathlib import Path
|
||||
|
||||
@@ -60,3 +60,19 @@ index d01fb98e..06b8b621 100644
|
||||
def _clear_line():
|
||||
- sys.stdout.write("\033[K")
|
||||
+ sys.stdout.write(chr(27) + "[K")
|
||||
diff --git a/pipenv/vendor/yaspin/spinners.py b/pipenv/vendor/yaspin/spinners.py
|
||||
index 9c3fa7b8..60822a2c 100644
|
||||
--- a/pipenv/vendor/yaspin/spinners.py
|
||||
+++ b/pipenv/vendor/yaspin/spinners.py
|
||||
@@ -11,10 +11,7 @@ import codecs
|
||||
import os
|
||||
from collections import namedtuple
|
||||
|
||||
-try:
|
||||
- import simplejson as json
|
||||
-except ImportError:
|
||||
- import json
|
||||
+import json
|
||||
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
Reference in New Issue
Block a user