Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/direct_url.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/format_control.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/link.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/scheme.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/search_scope.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/target_python.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/format_control.py +78 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/search_scope.py +127 -0
- llava/lib/python3.10/site-packages/pip/_internal/models/wheel.py +118 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__init__.py +631 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/__main__.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/android.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/api.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/api.py +298 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/macos.py +144 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/unix.py +269 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/version.py +16 -0
- llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/windows.py +272 -0
- llava/lib/python3.10/site-packages/pip/_vendor/typing_extensions.py +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/__init__.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/autoscaling_requester.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/legacy_compat.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/resource_manager.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/streaming_executor.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/streaming_executor_state.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/util.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__init__.py +15 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/__init__.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/autoscaler.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/autoscaling_actor_pool.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/default_autoscaler.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/autoscaler.py +44 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/autoscaling_actor_pool.py +88 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/default_autoscaler.py +188 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/__init__.py +32 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/backpressure_policy.py +28 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/concurrency_cap_backpressure_policy.py +43 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/__init__.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/common.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/execution_options.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/executor.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/op_runtime_metrics.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/physical_operator.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/ref_bundle.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/task_context.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/transform_fn.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/common.py +2 -0
- minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/task_context.py +41 -0
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/direct_url.cpython-310.pyc
ADDED
|
Binary file (7.38 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/format_control.cpython-310.pyc
ADDED
|
Binary file (2.71 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/link.cpython-310.pyc
ADDED
|
Binary file (18.7 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/scheme.cpython-310.pyc
ADDED
|
Binary file (910 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/search_scope.cpython-310.pyc
ADDED
|
Binary file (3.45 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-310.pyc
ADDED
|
Binary file (1.67 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/__pycache__/target_python.cpython-310.pyc
ADDED
|
Binary file (3.79 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_internal/models/format_control.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import FrozenSet, Optional, Set
|
| 2 |
+
|
| 3 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 4 |
+
|
| 5 |
+
from pip._internal.exceptions import CommandError
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class FormatControl:
|
| 9 |
+
"""Helper for managing formats from which a package can be installed."""
|
| 10 |
+
|
| 11 |
+
__slots__ = ["no_binary", "only_binary"]
|
| 12 |
+
|
| 13 |
+
def __init__(
|
| 14 |
+
self,
|
| 15 |
+
no_binary: Optional[Set[str]] = None,
|
| 16 |
+
only_binary: Optional[Set[str]] = None,
|
| 17 |
+
) -> None:
|
| 18 |
+
if no_binary is None:
|
| 19 |
+
no_binary = set()
|
| 20 |
+
if only_binary is None:
|
| 21 |
+
only_binary = set()
|
| 22 |
+
|
| 23 |
+
self.no_binary = no_binary
|
| 24 |
+
self.only_binary = only_binary
|
| 25 |
+
|
| 26 |
+
def __eq__(self, other: object) -> bool:
|
| 27 |
+
if not isinstance(other, self.__class__):
|
| 28 |
+
return NotImplemented
|
| 29 |
+
|
| 30 |
+
if self.__slots__ != other.__slots__:
|
| 31 |
+
return False
|
| 32 |
+
|
| 33 |
+
return all(getattr(self, k) == getattr(other, k) for k in self.__slots__)
|
| 34 |
+
|
| 35 |
+
def __repr__(self) -> str:
|
| 36 |
+
return f"{self.__class__.__name__}({self.no_binary}, {self.only_binary})"
|
| 37 |
+
|
| 38 |
+
@staticmethod
|
| 39 |
+
def handle_mutual_excludes(value: str, target: Set[str], other: Set[str]) -> None:
|
| 40 |
+
if value.startswith("-"):
|
| 41 |
+
raise CommandError(
|
| 42 |
+
"--no-binary / --only-binary option requires 1 argument."
|
| 43 |
+
)
|
| 44 |
+
new = value.split(",")
|
| 45 |
+
while ":all:" in new:
|
| 46 |
+
other.clear()
|
| 47 |
+
target.clear()
|
| 48 |
+
target.add(":all:")
|
| 49 |
+
del new[: new.index(":all:") + 1]
|
| 50 |
+
# Without a none, we want to discard everything as :all: covers it
|
| 51 |
+
if ":none:" not in new:
|
| 52 |
+
return
|
| 53 |
+
for name in new:
|
| 54 |
+
if name == ":none:":
|
| 55 |
+
target.clear()
|
| 56 |
+
continue
|
| 57 |
+
name = canonicalize_name(name)
|
| 58 |
+
other.discard(name)
|
| 59 |
+
target.add(name)
|
| 60 |
+
|
| 61 |
+
def get_allowed_formats(self, canonical_name: str) -> FrozenSet[str]:
|
| 62 |
+
result = {"binary", "source"}
|
| 63 |
+
if canonical_name in self.only_binary:
|
| 64 |
+
result.discard("source")
|
| 65 |
+
elif canonical_name in self.no_binary:
|
| 66 |
+
result.discard("binary")
|
| 67 |
+
elif ":all:" in self.only_binary:
|
| 68 |
+
result.discard("source")
|
| 69 |
+
elif ":all:" in self.no_binary:
|
| 70 |
+
result.discard("binary")
|
| 71 |
+
return frozenset(result)
|
| 72 |
+
|
| 73 |
+
def disallow_binaries(self) -> None:
|
| 74 |
+
self.handle_mutual_excludes(
|
| 75 |
+
":all:",
|
| 76 |
+
self.no_binary,
|
| 77 |
+
self.only_binary,
|
| 78 |
+
)
|
llava/lib/python3.10/site-packages/pip/_internal/models/search_scope.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import itertools
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import posixpath
|
| 5 |
+
import urllib.parse
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
from typing import List
|
| 8 |
+
|
| 9 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 10 |
+
|
| 11 |
+
from pip._internal.models.index import PyPI
|
| 12 |
+
from pip._internal.utils.compat import has_tls
|
| 13 |
+
from pip._internal.utils.misc import normalize_path, redact_auth_from_url
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@dataclass(frozen=True)
|
| 19 |
+
class SearchScope:
|
| 20 |
+
"""
|
| 21 |
+
Encapsulates the locations that pip is configured to search.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
__slots__ = ["find_links", "index_urls", "no_index"]
|
| 25 |
+
|
| 26 |
+
find_links: List[str]
|
| 27 |
+
index_urls: List[str]
|
| 28 |
+
no_index: bool
|
| 29 |
+
|
| 30 |
+
@classmethod
|
| 31 |
+
def create(
|
| 32 |
+
cls,
|
| 33 |
+
find_links: List[str],
|
| 34 |
+
index_urls: List[str],
|
| 35 |
+
no_index: bool,
|
| 36 |
+
) -> "SearchScope":
|
| 37 |
+
"""
|
| 38 |
+
Create a SearchScope object after normalizing the `find_links`.
|
| 39 |
+
"""
|
| 40 |
+
# Build find_links. If an argument starts with ~, it may be
|
| 41 |
+
# a local file relative to a home directory. So try normalizing
|
| 42 |
+
# it and if it exists, use the normalized version.
|
| 43 |
+
# This is deliberately conservative - it might be fine just to
|
| 44 |
+
# blindly normalize anything starting with a ~...
|
| 45 |
+
built_find_links: List[str] = []
|
| 46 |
+
for link in find_links:
|
| 47 |
+
if link.startswith("~"):
|
| 48 |
+
new_link = normalize_path(link)
|
| 49 |
+
if os.path.exists(new_link):
|
| 50 |
+
link = new_link
|
| 51 |
+
built_find_links.append(link)
|
| 52 |
+
|
| 53 |
+
# If we don't have TLS enabled, then WARN if anyplace we're looking
|
| 54 |
+
# relies on TLS.
|
| 55 |
+
if not has_tls():
|
| 56 |
+
for link in itertools.chain(index_urls, built_find_links):
|
| 57 |
+
parsed = urllib.parse.urlparse(link)
|
| 58 |
+
if parsed.scheme == "https":
|
| 59 |
+
logger.warning(
|
| 60 |
+
"pip is configured with locations that require "
|
| 61 |
+
"TLS/SSL, however the ssl module in Python is not "
|
| 62 |
+
"available."
|
| 63 |
+
)
|
| 64 |
+
break
|
| 65 |
+
|
| 66 |
+
return cls(
|
| 67 |
+
find_links=built_find_links,
|
| 68 |
+
index_urls=index_urls,
|
| 69 |
+
no_index=no_index,
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
def get_formatted_locations(self) -> str:
|
| 73 |
+
lines = []
|
| 74 |
+
redacted_index_urls = []
|
| 75 |
+
if self.index_urls and self.index_urls != [PyPI.simple_url]:
|
| 76 |
+
for url in self.index_urls:
|
| 77 |
+
redacted_index_url = redact_auth_from_url(url)
|
| 78 |
+
|
| 79 |
+
# Parse the URL
|
| 80 |
+
purl = urllib.parse.urlsplit(redacted_index_url)
|
| 81 |
+
|
| 82 |
+
# URL is generally invalid if scheme and netloc is missing
|
| 83 |
+
# there are issues with Python and URL parsing, so this test
|
| 84 |
+
# is a bit crude. See bpo-20271, bpo-23505. Python doesn't
|
| 85 |
+
# always parse invalid URLs correctly - it should raise
|
| 86 |
+
# exceptions for malformed URLs
|
| 87 |
+
if not purl.scheme and not purl.netloc:
|
| 88 |
+
logger.warning(
|
| 89 |
+
'The index url "%s" seems invalid, please provide a scheme.',
|
| 90 |
+
redacted_index_url,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
redacted_index_urls.append(redacted_index_url)
|
| 94 |
+
|
| 95 |
+
lines.append(
|
| 96 |
+
"Looking in indexes: {}".format(", ".join(redacted_index_urls))
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
if self.find_links:
|
| 100 |
+
lines.append(
|
| 101 |
+
"Looking in links: {}".format(
|
| 102 |
+
", ".join(redact_auth_from_url(url) for url in self.find_links)
|
| 103 |
+
)
|
| 104 |
+
)
|
| 105 |
+
return "\n".join(lines)
|
| 106 |
+
|
| 107 |
+
def get_index_urls_locations(self, project_name: str) -> List[str]:
|
| 108 |
+
"""Returns the locations found via self.index_urls
|
| 109 |
+
|
| 110 |
+
Checks the url_name on the main (first in the list) index and
|
| 111 |
+
use this url_name to produce all locations
|
| 112 |
+
"""
|
| 113 |
+
|
| 114 |
+
def mkurl_pypi_url(url: str) -> str:
|
| 115 |
+
loc = posixpath.join(
|
| 116 |
+
url, urllib.parse.quote(canonicalize_name(project_name))
|
| 117 |
+
)
|
| 118 |
+
# For maximum compatibility with easy_install, ensure the path
|
| 119 |
+
# ends in a trailing slash. Although this isn't in the spec
|
| 120 |
+
# (and PyPI can handle it without the slash) some other index
|
| 121 |
+
# implementations might break if they relied on easy_install's
|
| 122 |
+
# behavior.
|
| 123 |
+
if not loc.endswith("/"):
|
| 124 |
+
loc = loc + "/"
|
| 125 |
+
return loc
|
| 126 |
+
|
| 127 |
+
return [mkurl_pypi_url(url) for url in self.index_urls]
|
llava/lib/python3.10/site-packages/pip/_internal/models/wheel.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Represents a wheel file and provides access to the various parts of the
|
| 2 |
+
name that have meaning.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import re
|
| 6 |
+
from typing import Dict, Iterable, List
|
| 7 |
+
|
| 8 |
+
from pip._vendor.packaging.tags import Tag
|
| 9 |
+
from pip._vendor.packaging.utils import (
|
| 10 |
+
InvalidWheelFilename as PackagingInvalidWheelName,
|
| 11 |
+
)
|
| 12 |
+
from pip._vendor.packaging.utils import parse_wheel_filename
|
| 13 |
+
|
| 14 |
+
from pip._internal.exceptions import InvalidWheelFilename
|
| 15 |
+
from pip._internal.utils.deprecation import deprecated
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class Wheel:
|
| 19 |
+
"""A wheel file"""
|
| 20 |
+
|
| 21 |
+
wheel_file_re = re.compile(
|
| 22 |
+
r"""^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
|
| 23 |
+
((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
|
| 24 |
+
\.whl|\.dist-info)$""",
|
| 25 |
+
re.VERBOSE,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
def __init__(self, filename: str) -> None:
|
| 29 |
+
"""
|
| 30 |
+
:raises InvalidWheelFilename: when the filename is invalid for a wheel
|
| 31 |
+
"""
|
| 32 |
+
wheel_info = self.wheel_file_re.match(filename)
|
| 33 |
+
if not wheel_info:
|
| 34 |
+
raise InvalidWheelFilename(f"{filename} is not a valid wheel filename.")
|
| 35 |
+
self.filename = filename
|
| 36 |
+
self.name = wheel_info.group("name").replace("_", "-")
|
| 37 |
+
_version = wheel_info.group("ver")
|
| 38 |
+
if "_" in _version:
|
| 39 |
+
try:
|
| 40 |
+
parse_wheel_filename(filename)
|
| 41 |
+
except PackagingInvalidWheelName as e:
|
| 42 |
+
deprecated(
|
| 43 |
+
reason=(
|
| 44 |
+
f"Wheel filename {filename!r} is not correctly normalised. "
|
| 45 |
+
"Future versions of pip will raise the following error:\n"
|
| 46 |
+
f"{e.args[0]}\n\n"
|
| 47 |
+
),
|
| 48 |
+
replacement=(
|
| 49 |
+
"to rename the wheel to use a correctly normalised "
|
| 50 |
+
"name (this may require updating the version in "
|
| 51 |
+
"the project metadata)"
|
| 52 |
+
),
|
| 53 |
+
gone_in="25.1",
|
| 54 |
+
issue=12938,
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
_version = _version.replace("_", "-")
|
| 58 |
+
|
| 59 |
+
self.version = _version
|
| 60 |
+
self.build_tag = wheel_info.group("build")
|
| 61 |
+
self.pyversions = wheel_info.group("pyver").split(".")
|
| 62 |
+
self.abis = wheel_info.group("abi").split(".")
|
| 63 |
+
self.plats = wheel_info.group("plat").split(".")
|
| 64 |
+
|
| 65 |
+
# All the tag combinations from this file
|
| 66 |
+
self.file_tags = {
|
| 67 |
+
Tag(x, y, z) for x in self.pyversions for y in self.abis for z in self.plats
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
def get_formatted_file_tags(self) -> List[str]:
|
| 71 |
+
"""Return the wheel's tags as a sorted list of strings."""
|
| 72 |
+
return sorted(str(tag) for tag in self.file_tags)
|
| 73 |
+
|
| 74 |
+
def support_index_min(self, tags: List[Tag]) -> int:
|
| 75 |
+
"""Return the lowest index that one of the wheel's file_tag combinations
|
| 76 |
+
achieves in the given list of supported tags.
|
| 77 |
+
|
| 78 |
+
For example, if there are 8 supported tags and one of the file tags
|
| 79 |
+
is first in the list, then return 0.
|
| 80 |
+
|
| 81 |
+
:param tags: the PEP 425 tags to check the wheel against, in order
|
| 82 |
+
with most preferred first.
|
| 83 |
+
|
| 84 |
+
:raises ValueError: If none of the wheel's file tags match one of
|
| 85 |
+
the supported tags.
|
| 86 |
+
"""
|
| 87 |
+
try:
|
| 88 |
+
return next(i for i, t in enumerate(tags) if t in self.file_tags)
|
| 89 |
+
except StopIteration:
|
| 90 |
+
raise ValueError()
|
| 91 |
+
|
| 92 |
+
def find_most_preferred_tag(
|
| 93 |
+
self, tags: List[Tag], tag_to_priority: Dict[Tag, int]
|
| 94 |
+
) -> int:
|
| 95 |
+
"""Return the priority of the most preferred tag that one of the wheel's file
|
| 96 |
+
tag combinations achieves in the given list of supported tags using the given
|
| 97 |
+
tag_to_priority mapping, where lower priorities are more-preferred.
|
| 98 |
+
|
| 99 |
+
This is used in place of support_index_min in some cases in order to avoid
|
| 100 |
+
an expensive linear scan of a large list of tags.
|
| 101 |
+
|
| 102 |
+
:param tags: the PEP 425 tags to check the wheel against.
|
| 103 |
+
:param tag_to_priority: a mapping from tag to priority of that tag, where
|
| 104 |
+
lower is more preferred.
|
| 105 |
+
|
| 106 |
+
:raises ValueError: If none of the wheel's file tags match one of
|
| 107 |
+
the supported tags.
|
| 108 |
+
"""
|
| 109 |
+
return min(
|
| 110 |
+
tag_to_priority[tag] for tag in self.file_tags if tag in tag_to_priority
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
def supported(self, tags: Iterable[Tag]) -> bool:
|
| 114 |
+
"""Return whether the wheel is compatible with one of the given tags.
|
| 115 |
+
|
| 116 |
+
:param tags: the PEP 425 tags to check the wheel against.
|
| 117 |
+
"""
|
| 118 |
+
return not self.file_tags.isdisjoint(tags)
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__init__.py
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Utilities for determining application-specific dirs.
|
| 3 |
+
|
| 4 |
+
See <https://github.com/platformdirs/platformdirs> for details and usage.
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import os
|
| 11 |
+
import sys
|
| 12 |
+
from typing import TYPE_CHECKING
|
| 13 |
+
|
| 14 |
+
from .api import PlatformDirsABC
|
| 15 |
+
from .version import __version__
|
| 16 |
+
from .version import __version_tuple__ as __version_info__
|
| 17 |
+
|
| 18 |
+
if TYPE_CHECKING:
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
from typing import Literal
|
| 21 |
+
|
| 22 |
+
if sys.platform == "win32":
|
| 23 |
+
from pip._vendor.platformdirs.windows import Windows as _Result
|
| 24 |
+
elif sys.platform == "darwin":
|
| 25 |
+
from pip._vendor.platformdirs.macos import MacOS as _Result
|
| 26 |
+
else:
|
| 27 |
+
from pip._vendor.platformdirs.unix import Unix as _Result
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _set_platform_dir_class() -> type[PlatformDirsABC]:
|
| 31 |
+
if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system":
|
| 32 |
+
if os.getenv("SHELL") or os.getenv("PREFIX"):
|
| 33 |
+
return _Result
|
| 34 |
+
|
| 35 |
+
from pip._vendor.platformdirs.android import _android_folder # noqa: PLC0415
|
| 36 |
+
|
| 37 |
+
if _android_folder() is not None:
|
| 38 |
+
from pip._vendor.platformdirs.android import Android # noqa: PLC0415
|
| 39 |
+
|
| 40 |
+
return Android # return to avoid redefinition of a result
|
| 41 |
+
|
| 42 |
+
return _Result
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if TYPE_CHECKING:
|
| 46 |
+
# Work around mypy issue: https://github.com/python/mypy/issues/10962
|
| 47 |
+
PlatformDirs = _Result
|
| 48 |
+
else:
|
| 49 |
+
PlatformDirs = _set_platform_dir_class() #: Currently active platform
|
| 50 |
+
AppDirs = PlatformDirs #: Backwards compatibility with appdirs
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def user_data_dir(
|
| 54 |
+
appname: str | None = None,
|
| 55 |
+
appauthor: str | None | Literal[False] = None,
|
| 56 |
+
version: str | None = None,
|
| 57 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 58 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 59 |
+
) -> str:
|
| 60 |
+
"""
|
| 61 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 62 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 63 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 64 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 65 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 66 |
+
:returns: data directory tied to the user
|
| 67 |
+
"""
|
| 68 |
+
return PlatformDirs(
|
| 69 |
+
appname=appname,
|
| 70 |
+
appauthor=appauthor,
|
| 71 |
+
version=version,
|
| 72 |
+
roaming=roaming,
|
| 73 |
+
ensure_exists=ensure_exists,
|
| 74 |
+
).user_data_dir
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def site_data_dir(
|
| 78 |
+
appname: str | None = None,
|
| 79 |
+
appauthor: str | None | Literal[False] = None,
|
| 80 |
+
version: str | None = None,
|
| 81 |
+
multipath: bool = False, # noqa: FBT001, FBT002
|
| 82 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 83 |
+
) -> str:
|
| 84 |
+
"""
|
| 85 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 86 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 87 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 88 |
+
:param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
|
| 89 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 90 |
+
:returns: data directory shared by users
|
| 91 |
+
"""
|
| 92 |
+
return PlatformDirs(
|
| 93 |
+
appname=appname,
|
| 94 |
+
appauthor=appauthor,
|
| 95 |
+
version=version,
|
| 96 |
+
multipath=multipath,
|
| 97 |
+
ensure_exists=ensure_exists,
|
| 98 |
+
).site_data_dir
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def user_config_dir(
|
| 102 |
+
appname: str | None = None,
|
| 103 |
+
appauthor: str | None | Literal[False] = None,
|
| 104 |
+
version: str | None = None,
|
| 105 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 106 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 107 |
+
) -> str:
|
| 108 |
+
"""
|
| 109 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 110 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 111 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 112 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 113 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 114 |
+
:returns: config directory tied to the user
|
| 115 |
+
"""
|
| 116 |
+
return PlatformDirs(
|
| 117 |
+
appname=appname,
|
| 118 |
+
appauthor=appauthor,
|
| 119 |
+
version=version,
|
| 120 |
+
roaming=roaming,
|
| 121 |
+
ensure_exists=ensure_exists,
|
| 122 |
+
).user_config_dir
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def site_config_dir(
|
| 126 |
+
appname: str | None = None,
|
| 127 |
+
appauthor: str | None | Literal[False] = None,
|
| 128 |
+
version: str | None = None,
|
| 129 |
+
multipath: bool = False, # noqa: FBT001, FBT002
|
| 130 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 131 |
+
) -> str:
|
| 132 |
+
"""
|
| 133 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 134 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 135 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 136 |
+
:param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
|
| 137 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 138 |
+
:returns: config directory shared by the users
|
| 139 |
+
"""
|
| 140 |
+
return PlatformDirs(
|
| 141 |
+
appname=appname,
|
| 142 |
+
appauthor=appauthor,
|
| 143 |
+
version=version,
|
| 144 |
+
multipath=multipath,
|
| 145 |
+
ensure_exists=ensure_exists,
|
| 146 |
+
).site_config_dir
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def user_cache_dir(
|
| 150 |
+
appname: str | None = None,
|
| 151 |
+
appauthor: str | None | Literal[False] = None,
|
| 152 |
+
version: str | None = None,
|
| 153 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 154 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 155 |
+
) -> str:
|
| 156 |
+
"""
|
| 157 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 158 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 159 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 160 |
+
:param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 161 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 162 |
+
:returns: cache directory tied to the user
|
| 163 |
+
"""
|
| 164 |
+
return PlatformDirs(
|
| 165 |
+
appname=appname,
|
| 166 |
+
appauthor=appauthor,
|
| 167 |
+
version=version,
|
| 168 |
+
opinion=opinion,
|
| 169 |
+
ensure_exists=ensure_exists,
|
| 170 |
+
).user_cache_dir
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def site_cache_dir(
|
| 174 |
+
appname: str | None = None,
|
| 175 |
+
appauthor: str | None | Literal[False] = None,
|
| 176 |
+
version: str | None = None,
|
| 177 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 178 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 179 |
+
) -> str:
|
| 180 |
+
"""
|
| 181 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 182 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 183 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 184 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 185 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 186 |
+
:returns: cache directory tied to the user
|
| 187 |
+
"""
|
| 188 |
+
return PlatformDirs(
|
| 189 |
+
appname=appname,
|
| 190 |
+
appauthor=appauthor,
|
| 191 |
+
version=version,
|
| 192 |
+
opinion=opinion,
|
| 193 |
+
ensure_exists=ensure_exists,
|
| 194 |
+
).site_cache_dir
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def user_state_dir(
|
| 198 |
+
appname: str | None = None,
|
| 199 |
+
appauthor: str | None | Literal[False] = None,
|
| 200 |
+
version: str | None = None,
|
| 201 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 202 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 203 |
+
) -> str:
|
| 204 |
+
"""
|
| 205 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 206 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 207 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 208 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 209 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 210 |
+
:returns: state directory tied to the user
|
| 211 |
+
"""
|
| 212 |
+
return PlatformDirs(
|
| 213 |
+
appname=appname,
|
| 214 |
+
appauthor=appauthor,
|
| 215 |
+
version=version,
|
| 216 |
+
roaming=roaming,
|
| 217 |
+
ensure_exists=ensure_exists,
|
| 218 |
+
).user_state_dir
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def user_log_dir(
|
| 222 |
+
appname: str | None = None,
|
| 223 |
+
appauthor: str | None | Literal[False] = None,
|
| 224 |
+
version: str | None = None,
|
| 225 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 226 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 227 |
+
) -> str:
|
| 228 |
+
"""
|
| 229 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 230 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 231 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 232 |
+
:param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 233 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 234 |
+
:returns: log directory tied to the user
|
| 235 |
+
"""
|
| 236 |
+
return PlatformDirs(
|
| 237 |
+
appname=appname,
|
| 238 |
+
appauthor=appauthor,
|
| 239 |
+
version=version,
|
| 240 |
+
opinion=opinion,
|
| 241 |
+
ensure_exists=ensure_exists,
|
| 242 |
+
).user_log_dir
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def user_documents_dir() -> str:
|
| 246 |
+
""":returns: documents directory tied to the user"""
|
| 247 |
+
return PlatformDirs().user_documents_dir
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def user_downloads_dir() -> str:
|
| 251 |
+
""":returns: downloads directory tied to the user"""
|
| 252 |
+
return PlatformDirs().user_downloads_dir
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def user_pictures_dir() -> str:
|
| 256 |
+
""":returns: pictures directory tied to the user"""
|
| 257 |
+
return PlatformDirs().user_pictures_dir
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def user_videos_dir() -> str:
|
| 261 |
+
""":returns: videos directory tied to the user"""
|
| 262 |
+
return PlatformDirs().user_videos_dir
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
def user_music_dir() -> str:
|
| 266 |
+
""":returns: music directory tied to the user"""
|
| 267 |
+
return PlatformDirs().user_music_dir
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def user_desktop_dir() -> str:
|
| 271 |
+
""":returns: desktop directory tied to the user"""
|
| 272 |
+
return PlatformDirs().user_desktop_dir
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def user_runtime_dir(
|
| 276 |
+
appname: str | None = None,
|
| 277 |
+
appauthor: str | None | Literal[False] = None,
|
| 278 |
+
version: str | None = None,
|
| 279 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 280 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 281 |
+
) -> str:
|
| 282 |
+
"""
|
| 283 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 284 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 285 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 286 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 287 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 288 |
+
:returns: runtime directory tied to the user
|
| 289 |
+
"""
|
| 290 |
+
return PlatformDirs(
|
| 291 |
+
appname=appname,
|
| 292 |
+
appauthor=appauthor,
|
| 293 |
+
version=version,
|
| 294 |
+
opinion=opinion,
|
| 295 |
+
ensure_exists=ensure_exists,
|
| 296 |
+
).user_runtime_dir
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
def site_runtime_dir(
|
| 300 |
+
appname: str | None = None,
|
| 301 |
+
appauthor: str | None | Literal[False] = None,
|
| 302 |
+
version: str | None = None,
|
| 303 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 304 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 305 |
+
) -> str:
|
| 306 |
+
"""
|
| 307 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 308 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 309 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 310 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 311 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 312 |
+
:returns: runtime directory shared by users
|
| 313 |
+
"""
|
| 314 |
+
return PlatformDirs(
|
| 315 |
+
appname=appname,
|
| 316 |
+
appauthor=appauthor,
|
| 317 |
+
version=version,
|
| 318 |
+
opinion=opinion,
|
| 319 |
+
ensure_exists=ensure_exists,
|
| 320 |
+
).site_runtime_dir
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def user_data_path(
|
| 324 |
+
appname: str | None = None,
|
| 325 |
+
appauthor: str | None | Literal[False] = None,
|
| 326 |
+
version: str | None = None,
|
| 327 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 328 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 329 |
+
) -> Path:
|
| 330 |
+
"""
|
| 331 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 332 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 333 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 334 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 335 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 336 |
+
:returns: data path tied to the user
|
| 337 |
+
"""
|
| 338 |
+
return PlatformDirs(
|
| 339 |
+
appname=appname,
|
| 340 |
+
appauthor=appauthor,
|
| 341 |
+
version=version,
|
| 342 |
+
roaming=roaming,
|
| 343 |
+
ensure_exists=ensure_exists,
|
| 344 |
+
).user_data_path
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def site_data_path(
|
| 348 |
+
appname: str | None = None,
|
| 349 |
+
appauthor: str | None | Literal[False] = None,
|
| 350 |
+
version: str | None = None,
|
| 351 |
+
multipath: bool = False, # noqa: FBT001, FBT002
|
| 352 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 353 |
+
) -> Path:
|
| 354 |
+
"""
|
| 355 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 356 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 357 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 358 |
+
:param multipath: See `multipath <platformdirs.api.PlatformDirsABC.multipath>`.
|
| 359 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 360 |
+
:returns: data path shared by users
|
| 361 |
+
"""
|
| 362 |
+
return PlatformDirs(
|
| 363 |
+
appname=appname,
|
| 364 |
+
appauthor=appauthor,
|
| 365 |
+
version=version,
|
| 366 |
+
multipath=multipath,
|
| 367 |
+
ensure_exists=ensure_exists,
|
| 368 |
+
).site_data_path
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
def user_config_path(
|
| 372 |
+
appname: str | None = None,
|
| 373 |
+
appauthor: str | None | Literal[False] = None,
|
| 374 |
+
version: str | None = None,
|
| 375 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 376 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 377 |
+
) -> Path:
|
| 378 |
+
"""
|
| 379 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 380 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 381 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 382 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 383 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 384 |
+
:returns: config path tied to the user
|
| 385 |
+
"""
|
| 386 |
+
return PlatformDirs(
|
| 387 |
+
appname=appname,
|
| 388 |
+
appauthor=appauthor,
|
| 389 |
+
version=version,
|
| 390 |
+
roaming=roaming,
|
| 391 |
+
ensure_exists=ensure_exists,
|
| 392 |
+
).user_config_path
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
def site_config_path(
|
| 396 |
+
appname: str | None = None,
|
| 397 |
+
appauthor: str | None | Literal[False] = None,
|
| 398 |
+
version: str | None = None,
|
| 399 |
+
multipath: bool = False, # noqa: FBT001, FBT002
|
| 400 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 401 |
+
) -> Path:
|
| 402 |
+
"""
|
| 403 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 404 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 405 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 406 |
+
:param multipath: See `roaming <platformdirs.api.PlatformDirsABC.multipath>`.
|
| 407 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 408 |
+
:returns: config path shared by the users
|
| 409 |
+
"""
|
| 410 |
+
return PlatformDirs(
|
| 411 |
+
appname=appname,
|
| 412 |
+
appauthor=appauthor,
|
| 413 |
+
version=version,
|
| 414 |
+
multipath=multipath,
|
| 415 |
+
ensure_exists=ensure_exists,
|
| 416 |
+
).site_config_path
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
def site_cache_path(
|
| 420 |
+
appname: str | None = None,
|
| 421 |
+
appauthor: str | None | Literal[False] = None,
|
| 422 |
+
version: str | None = None,
|
| 423 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 424 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 425 |
+
) -> Path:
|
| 426 |
+
"""
|
| 427 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 428 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 429 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 430 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 431 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 432 |
+
:returns: cache directory tied to the user
|
| 433 |
+
"""
|
| 434 |
+
return PlatformDirs(
|
| 435 |
+
appname=appname,
|
| 436 |
+
appauthor=appauthor,
|
| 437 |
+
version=version,
|
| 438 |
+
opinion=opinion,
|
| 439 |
+
ensure_exists=ensure_exists,
|
| 440 |
+
).site_cache_path
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
def user_cache_path(
|
| 444 |
+
appname: str | None = None,
|
| 445 |
+
appauthor: str | None | Literal[False] = None,
|
| 446 |
+
version: str | None = None,
|
| 447 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 448 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 449 |
+
) -> Path:
|
| 450 |
+
"""
|
| 451 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 452 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 453 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 454 |
+
:param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 455 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 456 |
+
:returns: cache path tied to the user
|
| 457 |
+
"""
|
| 458 |
+
return PlatformDirs(
|
| 459 |
+
appname=appname,
|
| 460 |
+
appauthor=appauthor,
|
| 461 |
+
version=version,
|
| 462 |
+
opinion=opinion,
|
| 463 |
+
ensure_exists=ensure_exists,
|
| 464 |
+
).user_cache_path
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
def user_state_path(
|
| 468 |
+
appname: str | None = None,
|
| 469 |
+
appauthor: str | None | Literal[False] = None,
|
| 470 |
+
version: str | None = None,
|
| 471 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 472 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 473 |
+
) -> Path:
|
| 474 |
+
"""
|
| 475 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 476 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 477 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 478 |
+
:param roaming: See `roaming <platformdirs.api.PlatformDirsABC.roaming>`.
|
| 479 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 480 |
+
:returns: state path tied to the user
|
| 481 |
+
"""
|
| 482 |
+
return PlatformDirs(
|
| 483 |
+
appname=appname,
|
| 484 |
+
appauthor=appauthor,
|
| 485 |
+
version=version,
|
| 486 |
+
roaming=roaming,
|
| 487 |
+
ensure_exists=ensure_exists,
|
| 488 |
+
).user_state_path
|
| 489 |
+
|
| 490 |
+
|
| 491 |
+
def user_log_path(
|
| 492 |
+
appname: str | None = None,
|
| 493 |
+
appauthor: str | None | Literal[False] = None,
|
| 494 |
+
version: str | None = None,
|
| 495 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 496 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 497 |
+
) -> Path:
|
| 498 |
+
"""
|
| 499 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 500 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 501 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 502 |
+
:param opinion: See `roaming <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 503 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 504 |
+
:returns: log path tied to the user
|
| 505 |
+
"""
|
| 506 |
+
return PlatformDirs(
|
| 507 |
+
appname=appname,
|
| 508 |
+
appauthor=appauthor,
|
| 509 |
+
version=version,
|
| 510 |
+
opinion=opinion,
|
| 511 |
+
ensure_exists=ensure_exists,
|
| 512 |
+
).user_log_path
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
def user_documents_path() -> Path:
|
| 516 |
+
""":returns: documents a path tied to the user"""
|
| 517 |
+
return PlatformDirs().user_documents_path
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
def user_downloads_path() -> Path:
|
| 521 |
+
""":returns: downloads path tied to the user"""
|
| 522 |
+
return PlatformDirs().user_downloads_path
|
| 523 |
+
|
| 524 |
+
|
| 525 |
+
def user_pictures_path() -> Path:
|
| 526 |
+
""":returns: pictures path tied to the user"""
|
| 527 |
+
return PlatformDirs().user_pictures_path
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
def user_videos_path() -> Path:
|
| 531 |
+
""":returns: videos path tied to the user"""
|
| 532 |
+
return PlatformDirs().user_videos_path
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
def user_music_path() -> Path:
|
| 536 |
+
""":returns: music path tied to the user"""
|
| 537 |
+
return PlatformDirs().user_music_path
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
def user_desktop_path() -> Path:
|
| 541 |
+
""":returns: desktop path tied to the user"""
|
| 542 |
+
return PlatformDirs().user_desktop_path
|
| 543 |
+
|
| 544 |
+
|
| 545 |
+
def user_runtime_path(
|
| 546 |
+
appname: str | None = None,
|
| 547 |
+
appauthor: str | None | Literal[False] = None,
|
| 548 |
+
version: str | None = None,
|
| 549 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 550 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 551 |
+
) -> Path:
|
| 552 |
+
"""
|
| 553 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 554 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 555 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 556 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 557 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 558 |
+
:returns: runtime path tied to the user
|
| 559 |
+
"""
|
| 560 |
+
return PlatformDirs(
|
| 561 |
+
appname=appname,
|
| 562 |
+
appauthor=appauthor,
|
| 563 |
+
version=version,
|
| 564 |
+
opinion=opinion,
|
| 565 |
+
ensure_exists=ensure_exists,
|
| 566 |
+
).user_runtime_path
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
def site_runtime_path(
|
| 570 |
+
appname: str | None = None,
|
| 571 |
+
appauthor: str | None | Literal[False] = None,
|
| 572 |
+
version: str | None = None,
|
| 573 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 574 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 575 |
+
) -> Path:
|
| 576 |
+
"""
|
| 577 |
+
:param appname: See `appname <platformdirs.api.PlatformDirsABC.appname>`.
|
| 578 |
+
:param appauthor: See `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`.
|
| 579 |
+
:param version: See `version <platformdirs.api.PlatformDirsABC.version>`.
|
| 580 |
+
:param opinion: See `opinion <platformdirs.api.PlatformDirsABC.opinion>`.
|
| 581 |
+
:param ensure_exists: See `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 582 |
+
:returns: runtime path shared by users
|
| 583 |
+
"""
|
| 584 |
+
return PlatformDirs(
|
| 585 |
+
appname=appname,
|
| 586 |
+
appauthor=appauthor,
|
| 587 |
+
version=version,
|
| 588 |
+
opinion=opinion,
|
| 589 |
+
ensure_exists=ensure_exists,
|
| 590 |
+
).site_runtime_path
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
__all__ = [
|
| 594 |
+
"AppDirs",
|
| 595 |
+
"PlatformDirs",
|
| 596 |
+
"PlatformDirsABC",
|
| 597 |
+
"__version__",
|
| 598 |
+
"__version_info__",
|
| 599 |
+
"site_cache_dir",
|
| 600 |
+
"site_cache_path",
|
| 601 |
+
"site_config_dir",
|
| 602 |
+
"site_config_path",
|
| 603 |
+
"site_data_dir",
|
| 604 |
+
"site_data_path",
|
| 605 |
+
"site_runtime_dir",
|
| 606 |
+
"site_runtime_path",
|
| 607 |
+
"user_cache_dir",
|
| 608 |
+
"user_cache_path",
|
| 609 |
+
"user_config_dir",
|
| 610 |
+
"user_config_path",
|
| 611 |
+
"user_data_dir",
|
| 612 |
+
"user_data_path",
|
| 613 |
+
"user_desktop_dir",
|
| 614 |
+
"user_desktop_path",
|
| 615 |
+
"user_documents_dir",
|
| 616 |
+
"user_documents_path",
|
| 617 |
+
"user_downloads_dir",
|
| 618 |
+
"user_downloads_path",
|
| 619 |
+
"user_log_dir",
|
| 620 |
+
"user_log_path",
|
| 621 |
+
"user_music_dir",
|
| 622 |
+
"user_music_path",
|
| 623 |
+
"user_pictures_dir",
|
| 624 |
+
"user_pictures_path",
|
| 625 |
+
"user_runtime_dir",
|
| 626 |
+
"user_runtime_path",
|
| 627 |
+
"user_state_dir",
|
| 628 |
+
"user_state_path",
|
| 629 |
+
"user_videos_dir",
|
| 630 |
+
"user_videos_path",
|
| 631 |
+
]
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/__main__.cpython-310.pyc
ADDED
|
Binary file (1.38 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/android.cpython-310.pyc
ADDED
|
Binary file (7.39 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/__pycache__/api.cpython-310.pyc
ADDED
|
Binary file (10.2 kB). View file
|
|
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/api.py
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Base API."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
from abc import ABC, abstractmethod
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from typing import TYPE_CHECKING
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
from typing import Iterator, Literal
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class PlatformDirsABC(ABC): # noqa: PLR0904
|
| 15 |
+
"""Abstract base class for platform directories."""
|
| 16 |
+
|
| 17 |
+
def __init__( # noqa: PLR0913, PLR0917
|
| 18 |
+
self,
|
| 19 |
+
appname: str | None = None,
|
| 20 |
+
appauthor: str | None | Literal[False] = None,
|
| 21 |
+
version: str | None = None,
|
| 22 |
+
roaming: bool = False, # noqa: FBT001, FBT002
|
| 23 |
+
multipath: bool = False, # noqa: FBT001, FBT002
|
| 24 |
+
opinion: bool = True, # noqa: FBT001, FBT002
|
| 25 |
+
ensure_exists: bool = False, # noqa: FBT001, FBT002
|
| 26 |
+
) -> None:
|
| 27 |
+
"""
|
| 28 |
+
Create a new platform directory.
|
| 29 |
+
|
| 30 |
+
:param appname: See `appname`.
|
| 31 |
+
:param appauthor: See `appauthor`.
|
| 32 |
+
:param version: See `version`.
|
| 33 |
+
:param roaming: See `roaming`.
|
| 34 |
+
:param multipath: See `multipath`.
|
| 35 |
+
:param opinion: See `opinion`.
|
| 36 |
+
:param ensure_exists: See `ensure_exists`.
|
| 37 |
+
|
| 38 |
+
"""
|
| 39 |
+
self.appname = appname #: The name of application.
|
| 40 |
+
self.appauthor = appauthor
|
| 41 |
+
"""
|
| 42 |
+
The name of the app author or distributing body for this application.
|
| 43 |
+
|
| 44 |
+
Typically, it is the owning company name. Defaults to `appname`. You may pass ``False`` to disable it.
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
+
self.version = version
|
| 48 |
+
"""
|
| 49 |
+
An optional version path element to append to the path.
|
| 50 |
+
|
| 51 |
+
You might want to use this if you want multiple versions of your app to be able to run independently. If used,
|
| 52 |
+
this would typically be ``<major>.<minor>``.
|
| 53 |
+
|
| 54 |
+
"""
|
| 55 |
+
self.roaming = roaming
|
| 56 |
+
"""
|
| 57 |
+
Whether to use the roaming appdata directory on Windows.
|
| 58 |
+
|
| 59 |
+
That means that for users on a Windows network setup for roaming profiles, this user data will be synced on
|
| 60 |
+
login (see
|
| 61 |
+
`here <https://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>`_).
|
| 62 |
+
|
| 63 |
+
"""
|
| 64 |
+
self.multipath = multipath
|
| 65 |
+
"""
|
| 66 |
+
An optional parameter which indicates that the entire list of data dirs should be returned.
|
| 67 |
+
|
| 68 |
+
By default, the first item would only be returned.
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
self.opinion = opinion #: A flag to indicating to use opinionated values.
|
| 72 |
+
self.ensure_exists = ensure_exists
|
| 73 |
+
"""
|
| 74 |
+
Optionally create the directory (and any missing parents) upon access if it does not exist.
|
| 75 |
+
|
| 76 |
+
By default, no directories are created.
|
| 77 |
+
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
def _append_app_name_and_version(self, *base: str) -> str:
|
| 81 |
+
params = list(base[1:])
|
| 82 |
+
if self.appname:
|
| 83 |
+
params.append(self.appname)
|
| 84 |
+
if self.version:
|
| 85 |
+
params.append(self.version)
|
| 86 |
+
path = os.path.join(base[0], *params) # noqa: PTH118
|
| 87 |
+
self._optionally_create_directory(path)
|
| 88 |
+
return path
|
| 89 |
+
|
| 90 |
+
def _optionally_create_directory(self, path: str) -> None:
|
| 91 |
+
if self.ensure_exists:
|
| 92 |
+
Path(path).mkdir(parents=True, exist_ok=True)
|
| 93 |
+
|
| 94 |
+
def _first_item_as_path_if_multipath(self, directory: str) -> Path:
|
| 95 |
+
if self.multipath:
|
| 96 |
+
# If multipath is True, the first path is returned.
|
| 97 |
+
directory = directory.split(os.pathsep)[0]
|
| 98 |
+
return Path(directory)
|
| 99 |
+
|
| 100 |
+
@property
|
| 101 |
+
@abstractmethod
|
| 102 |
+
def user_data_dir(self) -> str:
|
| 103 |
+
""":return: data directory tied to the user"""
|
| 104 |
+
|
| 105 |
+
@property
|
| 106 |
+
@abstractmethod
|
| 107 |
+
def site_data_dir(self) -> str:
|
| 108 |
+
""":return: data directory shared by users"""
|
| 109 |
+
|
| 110 |
+
@property
|
| 111 |
+
@abstractmethod
|
| 112 |
+
def user_config_dir(self) -> str:
|
| 113 |
+
""":return: config directory tied to the user"""
|
| 114 |
+
|
| 115 |
+
@property
|
| 116 |
+
@abstractmethod
|
| 117 |
+
def site_config_dir(self) -> str:
|
| 118 |
+
""":return: config directory shared by the users"""
|
| 119 |
+
|
| 120 |
+
@property
|
| 121 |
+
@abstractmethod
|
| 122 |
+
def user_cache_dir(self) -> str:
|
| 123 |
+
""":return: cache directory tied to the user"""
|
| 124 |
+
|
| 125 |
+
@property
|
| 126 |
+
@abstractmethod
|
| 127 |
+
def site_cache_dir(self) -> str:
|
| 128 |
+
""":return: cache directory shared by users"""
|
| 129 |
+
|
| 130 |
+
@property
|
| 131 |
+
@abstractmethod
|
| 132 |
+
def user_state_dir(self) -> str:
|
| 133 |
+
""":return: state directory tied to the user"""
|
| 134 |
+
|
| 135 |
+
@property
|
| 136 |
+
@abstractmethod
|
| 137 |
+
def user_log_dir(self) -> str:
|
| 138 |
+
""":return: log directory tied to the user"""
|
| 139 |
+
|
| 140 |
+
@property
|
| 141 |
+
@abstractmethod
|
| 142 |
+
def user_documents_dir(self) -> str:
|
| 143 |
+
""":return: documents directory tied to the user"""
|
| 144 |
+
|
| 145 |
+
@property
|
| 146 |
+
@abstractmethod
|
| 147 |
+
def user_downloads_dir(self) -> str:
|
| 148 |
+
""":return: downloads directory tied to the user"""
|
| 149 |
+
|
| 150 |
+
@property
|
| 151 |
+
@abstractmethod
|
| 152 |
+
def user_pictures_dir(self) -> str:
|
| 153 |
+
""":return: pictures directory tied to the user"""
|
| 154 |
+
|
| 155 |
+
@property
|
| 156 |
+
@abstractmethod
|
| 157 |
+
def user_videos_dir(self) -> str:
|
| 158 |
+
""":return: videos directory tied to the user"""
|
| 159 |
+
|
| 160 |
+
@property
|
| 161 |
+
@abstractmethod
|
| 162 |
+
def user_music_dir(self) -> str:
|
| 163 |
+
""":return: music directory tied to the user"""
|
| 164 |
+
|
| 165 |
+
@property
|
| 166 |
+
@abstractmethod
|
| 167 |
+
def user_desktop_dir(self) -> str:
|
| 168 |
+
""":return: desktop directory tied to the user"""
|
| 169 |
+
|
| 170 |
+
@property
|
| 171 |
+
@abstractmethod
|
| 172 |
+
def user_runtime_dir(self) -> str:
|
| 173 |
+
""":return: runtime directory tied to the user"""
|
| 174 |
+
|
| 175 |
+
@property
|
| 176 |
+
@abstractmethod
|
| 177 |
+
def site_runtime_dir(self) -> str:
|
| 178 |
+
""":return: runtime directory shared by users"""
|
| 179 |
+
|
| 180 |
+
@property
|
| 181 |
+
def user_data_path(self) -> Path:
|
| 182 |
+
""":return: data path tied to the user"""
|
| 183 |
+
return Path(self.user_data_dir)
|
| 184 |
+
|
| 185 |
+
@property
|
| 186 |
+
def site_data_path(self) -> Path:
|
| 187 |
+
""":return: data path shared by users"""
|
| 188 |
+
return Path(self.site_data_dir)
|
| 189 |
+
|
| 190 |
+
@property
|
| 191 |
+
def user_config_path(self) -> Path:
|
| 192 |
+
""":return: config path tied to the user"""
|
| 193 |
+
return Path(self.user_config_dir)
|
| 194 |
+
|
| 195 |
+
@property
|
| 196 |
+
def site_config_path(self) -> Path:
|
| 197 |
+
""":return: config path shared by the users"""
|
| 198 |
+
return Path(self.site_config_dir)
|
| 199 |
+
|
| 200 |
+
@property
|
| 201 |
+
def user_cache_path(self) -> Path:
|
| 202 |
+
""":return: cache path tied to the user"""
|
| 203 |
+
return Path(self.user_cache_dir)
|
| 204 |
+
|
| 205 |
+
@property
|
| 206 |
+
def site_cache_path(self) -> Path:
|
| 207 |
+
""":return: cache path shared by users"""
|
| 208 |
+
return Path(self.site_cache_dir)
|
| 209 |
+
|
| 210 |
+
@property
|
| 211 |
+
def user_state_path(self) -> Path:
|
| 212 |
+
""":return: state path tied to the user"""
|
| 213 |
+
return Path(self.user_state_dir)
|
| 214 |
+
|
| 215 |
+
@property
|
| 216 |
+
def user_log_path(self) -> Path:
|
| 217 |
+
""":return: log path tied to the user"""
|
| 218 |
+
return Path(self.user_log_dir)
|
| 219 |
+
|
| 220 |
+
@property
|
| 221 |
+
def user_documents_path(self) -> Path:
|
| 222 |
+
""":return: documents a path tied to the user"""
|
| 223 |
+
return Path(self.user_documents_dir)
|
| 224 |
+
|
| 225 |
+
@property
|
| 226 |
+
def user_downloads_path(self) -> Path:
|
| 227 |
+
""":return: downloads path tied to the user"""
|
| 228 |
+
return Path(self.user_downloads_dir)
|
| 229 |
+
|
| 230 |
+
@property
|
| 231 |
+
def user_pictures_path(self) -> Path:
|
| 232 |
+
""":return: pictures path tied to the user"""
|
| 233 |
+
return Path(self.user_pictures_dir)
|
| 234 |
+
|
| 235 |
+
@property
|
| 236 |
+
def user_videos_path(self) -> Path:
|
| 237 |
+
""":return: videos path tied to the user"""
|
| 238 |
+
return Path(self.user_videos_dir)
|
| 239 |
+
|
| 240 |
+
@property
|
| 241 |
+
def user_music_path(self) -> Path:
|
| 242 |
+
""":return: music path tied to the user"""
|
| 243 |
+
return Path(self.user_music_dir)
|
| 244 |
+
|
| 245 |
+
@property
|
| 246 |
+
def user_desktop_path(self) -> Path:
|
| 247 |
+
""":return: desktop path tied to the user"""
|
| 248 |
+
return Path(self.user_desktop_dir)
|
| 249 |
+
|
| 250 |
+
@property
|
| 251 |
+
def user_runtime_path(self) -> Path:
|
| 252 |
+
""":return: runtime path tied to the user"""
|
| 253 |
+
return Path(self.user_runtime_dir)
|
| 254 |
+
|
| 255 |
+
@property
|
| 256 |
+
def site_runtime_path(self) -> Path:
|
| 257 |
+
""":return: runtime path shared by users"""
|
| 258 |
+
return Path(self.site_runtime_dir)
|
| 259 |
+
|
| 260 |
+
def iter_config_dirs(self) -> Iterator[str]:
|
| 261 |
+
""":yield: all user and site configuration directories."""
|
| 262 |
+
yield self.user_config_dir
|
| 263 |
+
yield self.site_config_dir
|
| 264 |
+
|
| 265 |
+
def iter_data_dirs(self) -> Iterator[str]:
|
| 266 |
+
""":yield: all user and site data directories."""
|
| 267 |
+
yield self.user_data_dir
|
| 268 |
+
yield self.site_data_dir
|
| 269 |
+
|
| 270 |
+
def iter_cache_dirs(self) -> Iterator[str]:
|
| 271 |
+
""":yield: all user and site cache directories."""
|
| 272 |
+
yield self.user_cache_dir
|
| 273 |
+
yield self.site_cache_dir
|
| 274 |
+
|
| 275 |
+
def iter_runtime_dirs(self) -> Iterator[str]:
|
| 276 |
+
""":yield: all user and site runtime directories."""
|
| 277 |
+
yield self.user_runtime_dir
|
| 278 |
+
yield self.site_runtime_dir
|
| 279 |
+
|
| 280 |
+
def iter_config_paths(self) -> Iterator[Path]:
|
| 281 |
+
""":yield: all user and site configuration paths."""
|
| 282 |
+
for path in self.iter_config_dirs():
|
| 283 |
+
yield Path(path)
|
| 284 |
+
|
| 285 |
+
def iter_data_paths(self) -> Iterator[Path]:
|
| 286 |
+
""":yield: all user and site data paths."""
|
| 287 |
+
for path in self.iter_data_dirs():
|
| 288 |
+
yield Path(path)
|
| 289 |
+
|
| 290 |
+
def iter_cache_paths(self) -> Iterator[Path]:
|
| 291 |
+
""":yield: all user and site cache paths."""
|
| 292 |
+
for path in self.iter_cache_dirs():
|
| 293 |
+
yield Path(path)
|
| 294 |
+
|
| 295 |
+
def iter_runtime_paths(self) -> Iterator[Path]:
|
| 296 |
+
""":yield: all user and site runtime paths."""
|
| 297 |
+
for path in self.iter_runtime_dirs():
|
| 298 |
+
yield Path(path)
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/macos.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""macOS."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import os.path
|
| 6 |
+
import sys
|
| 7 |
+
from typing import TYPE_CHECKING
|
| 8 |
+
|
| 9 |
+
from .api import PlatformDirsABC
|
| 10 |
+
|
| 11 |
+
if TYPE_CHECKING:
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class MacOS(PlatformDirsABC):
|
| 16 |
+
"""
|
| 17 |
+
Platform directories for the macOS operating system.
|
| 18 |
+
|
| 19 |
+
Follows the guidance from
|
| 20 |
+
`Apple documentation <https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.
|
| 21 |
+
Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`,
|
| 22 |
+
`version <platformdirs.api.PlatformDirsABC.version>`,
|
| 23 |
+
`ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 24 |
+
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
@property
|
| 28 |
+
def user_data_dir(self) -> str:
|
| 29 |
+
""":return: data directory tied to the user, e.g. ``~/Library/Application Support/$appname/$version``"""
|
| 30 |
+
return self._append_app_name_and_version(os.path.expanduser("~/Library/Application Support")) # noqa: PTH111
|
| 31 |
+
|
| 32 |
+
@property
|
| 33 |
+
def site_data_dir(self) -> str:
|
| 34 |
+
"""
|
| 35 |
+
:return: data directory shared by users, e.g. ``/Library/Application Support/$appname/$version``.
|
| 36 |
+
If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
|
| 37 |
+
will be under the Homebrew prefix, e.g. ``/opt/homebrew/share/$appname/$version``.
|
| 38 |
+
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
|
| 39 |
+
the response is a multi-path string separated by ":", e.g.
|
| 40 |
+
``/opt/homebrew/share/$appname/$version:/Library/Application Support/$appname/$version``
|
| 41 |
+
"""
|
| 42 |
+
is_homebrew = sys.prefix.startswith("/opt/homebrew")
|
| 43 |
+
path_list = [self._append_app_name_and_version("/opt/homebrew/share")] if is_homebrew else []
|
| 44 |
+
path_list.append(self._append_app_name_and_version("/Library/Application Support"))
|
| 45 |
+
if self.multipath:
|
| 46 |
+
return os.pathsep.join(path_list)
|
| 47 |
+
return path_list[0]
|
| 48 |
+
|
| 49 |
+
@property
|
| 50 |
+
def site_data_path(self) -> Path:
|
| 51 |
+
""":return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
|
| 52 |
+
return self._first_item_as_path_if_multipath(self.site_data_dir)
|
| 53 |
+
|
| 54 |
+
@property
|
| 55 |
+
def user_config_dir(self) -> str:
|
| 56 |
+
""":return: config directory tied to the user, same as `user_data_dir`"""
|
| 57 |
+
return self.user_data_dir
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def site_config_dir(self) -> str:
|
| 61 |
+
""":return: config directory shared by the users, same as `site_data_dir`"""
|
| 62 |
+
return self.site_data_dir
|
| 63 |
+
|
| 64 |
+
@property
|
| 65 |
+
def user_cache_dir(self) -> str:
|
| 66 |
+
""":return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``"""
|
| 67 |
+
return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches")) # noqa: PTH111
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def site_cache_dir(self) -> str:
|
| 71 |
+
"""
|
| 72 |
+
:return: cache directory shared by users, e.g. ``/Library/Caches/$appname/$version``.
|
| 73 |
+
If we're using a Python binary managed by `Homebrew <https://brew.sh>`_, the directory
|
| 74 |
+
will be under the Homebrew prefix, e.g. ``/opt/homebrew/var/cache/$appname/$version``.
|
| 75 |
+
If `multipath <platformdirs.api.PlatformDirsABC.multipath>` is enabled, and we're in Homebrew,
|
| 76 |
+
the response is a multi-path string separated by ":", e.g.
|
| 77 |
+
``/opt/homebrew/var/cache/$appname/$version:/Library/Caches/$appname/$version``
|
| 78 |
+
"""
|
| 79 |
+
is_homebrew = sys.prefix.startswith("/opt/homebrew")
|
| 80 |
+
path_list = [self._append_app_name_and_version("/opt/homebrew/var/cache")] if is_homebrew else []
|
| 81 |
+
path_list.append(self._append_app_name_and_version("/Library/Caches"))
|
| 82 |
+
if self.multipath:
|
| 83 |
+
return os.pathsep.join(path_list)
|
| 84 |
+
return path_list[0]
|
| 85 |
+
|
| 86 |
+
@property
|
| 87 |
+
def site_cache_path(self) -> Path:
|
| 88 |
+
""":return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
|
| 89 |
+
return self._first_item_as_path_if_multipath(self.site_cache_dir)
|
| 90 |
+
|
| 91 |
+
@property
|
| 92 |
+
def user_state_dir(self) -> str:
|
| 93 |
+
""":return: state directory tied to the user, same as `user_data_dir`"""
|
| 94 |
+
return self.user_data_dir
|
| 95 |
+
|
| 96 |
+
@property
|
| 97 |
+
def user_log_dir(self) -> str:
|
| 98 |
+
""":return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``"""
|
| 99 |
+
return self._append_app_name_and_version(os.path.expanduser("~/Library/Logs")) # noqa: PTH111
|
| 100 |
+
|
| 101 |
+
@property
|
| 102 |
+
def user_documents_dir(self) -> str:
|
| 103 |
+
""":return: documents directory tied to the user, e.g. ``~/Documents``"""
|
| 104 |
+
return os.path.expanduser("~/Documents") # noqa: PTH111
|
| 105 |
+
|
| 106 |
+
@property
|
| 107 |
+
def user_downloads_dir(self) -> str:
|
| 108 |
+
""":return: downloads directory tied to the user, e.g. ``~/Downloads``"""
|
| 109 |
+
return os.path.expanduser("~/Downloads") # noqa: PTH111
|
| 110 |
+
|
| 111 |
+
@property
|
| 112 |
+
def user_pictures_dir(self) -> str:
|
| 113 |
+
""":return: pictures directory tied to the user, e.g. ``~/Pictures``"""
|
| 114 |
+
return os.path.expanduser("~/Pictures") # noqa: PTH111
|
| 115 |
+
|
| 116 |
+
@property
|
| 117 |
+
def user_videos_dir(self) -> str:
|
| 118 |
+
""":return: videos directory tied to the user, e.g. ``~/Movies``"""
|
| 119 |
+
return os.path.expanduser("~/Movies") # noqa: PTH111
|
| 120 |
+
|
| 121 |
+
@property
|
| 122 |
+
def user_music_dir(self) -> str:
|
| 123 |
+
""":return: music directory tied to the user, e.g. ``~/Music``"""
|
| 124 |
+
return os.path.expanduser("~/Music") # noqa: PTH111
|
| 125 |
+
|
| 126 |
+
@property
|
| 127 |
+
def user_desktop_dir(self) -> str:
|
| 128 |
+
""":return: desktop directory tied to the user, e.g. ``~/Desktop``"""
|
| 129 |
+
return os.path.expanduser("~/Desktop") # noqa: PTH111
|
| 130 |
+
|
| 131 |
+
@property
|
| 132 |
+
def user_runtime_dir(self) -> str:
|
| 133 |
+
""":return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``"""
|
| 134 |
+
return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches/TemporaryItems")) # noqa: PTH111
|
| 135 |
+
|
| 136 |
+
@property
|
| 137 |
+
def site_runtime_dir(self) -> str:
|
| 138 |
+
""":return: runtime directory shared by users, same as `user_runtime_dir`"""
|
| 139 |
+
return self.user_runtime_dir
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
__all__ = [
|
| 143 |
+
"MacOS",
|
| 144 |
+
]
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/py.typed
ADDED
|
File without changes
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/unix.py
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Unix."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
from configparser import ConfigParser
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from typing import Iterator, NoReturn
|
| 10 |
+
|
| 11 |
+
from .api import PlatformDirsABC
|
| 12 |
+
|
| 13 |
+
if sys.platform == "win32":
|
| 14 |
+
|
| 15 |
+
def getuid() -> NoReturn:
|
| 16 |
+
msg = "should only be used on Unix"
|
| 17 |
+
raise RuntimeError(msg)
|
| 18 |
+
|
| 19 |
+
else:
|
| 20 |
+
from os import getuid
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Unix(PlatformDirsABC): # noqa: PLR0904
|
| 24 |
+
"""
|
| 25 |
+
On Unix/Linux, we follow the `XDG Basedir Spec <https://specifications.freedesktop.org/basedir-spec/basedir-spec-
|
| 26 |
+
latest.html>`_.
|
| 27 |
+
|
| 28 |
+
The spec allows overriding directories with environment variables. The examples shown are the default values,
|
| 29 |
+
alongside the name of the environment variable that overrides them. Makes use of the `appname
|
| 30 |
+
<platformdirs.api.PlatformDirsABC.appname>`, `version <platformdirs.api.PlatformDirsABC.version>`, `multipath
|
| 31 |
+
<platformdirs.api.PlatformDirsABC.multipath>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
|
| 32 |
+
<platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 33 |
+
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def user_data_dir(self) -> str:
|
| 38 |
+
"""
|
| 39 |
+
:return: data directory tied to the user, e.g. ``~/.local/share/$appname/$version`` or
|
| 40 |
+
``$XDG_DATA_HOME/$appname/$version``
|
| 41 |
+
"""
|
| 42 |
+
path = os.environ.get("XDG_DATA_HOME", "")
|
| 43 |
+
if not path.strip():
|
| 44 |
+
path = os.path.expanduser("~/.local/share") # noqa: PTH111
|
| 45 |
+
return self._append_app_name_and_version(path)
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def _site_data_dirs(self) -> list[str]:
|
| 49 |
+
path = os.environ.get("XDG_DATA_DIRS", "")
|
| 50 |
+
if not path.strip():
|
| 51 |
+
path = f"/usr/local/share{os.pathsep}/usr/share"
|
| 52 |
+
return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
|
| 53 |
+
|
| 54 |
+
@property
|
| 55 |
+
def site_data_dir(self) -> str:
|
| 56 |
+
"""
|
| 57 |
+
:return: data directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>` is
|
| 58 |
+
enabled and ``XDG_DATA_DIRS`` is set and a multi path the response is also a multi path separated by the
|
| 59 |
+
OS path separator), e.g. ``/usr/local/share/$appname/$version`` or ``/usr/share/$appname/$version``
|
| 60 |
+
"""
|
| 61 |
+
# XDG default for $XDG_DATA_DIRS; only first, if multipath is False
|
| 62 |
+
dirs = self._site_data_dirs
|
| 63 |
+
if not self.multipath:
|
| 64 |
+
return dirs[0]
|
| 65 |
+
return os.pathsep.join(dirs)
|
| 66 |
+
|
| 67 |
+
@property
|
| 68 |
+
def user_config_dir(self) -> str:
|
| 69 |
+
"""
|
| 70 |
+
:return: config directory tied to the user, e.g. ``~/.config/$appname/$version`` or
|
| 71 |
+
``$XDG_CONFIG_HOME/$appname/$version``
|
| 72 |
+
"""
|
| 73 |
+
path = os.environ.get("XDG_CONFIG_HOME", "")
|
| 74 |
+
if not path.strip():
|
| 75 |
+
path = os.path.expanduser("~/.config") # noqa: PTH111
|
| 76 |
+
return self._append_app_name_and_version(path)
|
| 77 |
+
|
| 78 |
+
@property
|
| 79 |
+
def _site_config_dirs(self) -> list[str]:
|
| 80 |
+
path = os.environ.get("XDG_CONFIG_DIRS", "")
|
| 81 |
+
if not path.strip():
|
| 82 |
+
path = "/etc/xdg"
|
| 83 |
+
return [self._append_app_name_and_version(p) for p in path.split(os.pathsep)]
|
| 84 |
+
|
| 85 |
+
@property
|
| 86 |
+
def site_config_dir(self) -> str:
|
| 87 |
+
"""
|
| 88 |
+
:return: config directories shared by users (if `multipath <platformdirs.api.PlatformDirsABC.multipath>`
|
| 89 |
+
is enabled and ``XDG_CONFIG_DIRS`` is set and a multi path the response is also a multi path separated by
|
| 90 |
+
the OS path separator), e.g. ``/etc/xdg/$appname/$version``
|
| 91 |
+
"""
|
| 92 |
+
# XDG default for $XDG_CONFIG_DIRS only first, if multipath is False
|
| 93 |
+
dirs = self._site_config_dirs
|
| 94 |
+
if not self.multipath:
|
| 95 |
+
return dirs[0]
|
| 96 |
+
return os.pathsep.join(dirs)
|
| 97 |
+
|
| 98 |
+
@property
|
| 99 |
+
def user_cache_dir(self) -> str:
|
| 100 |
+
"""
|
| 101 |
+
:return: cache directory tied to the user, e.g. ``~/.cache/$appname/$version`` or
|
| 102 |
+
``~/$XDG_CACHE_HOME/$appname/$version``
|
| 103 |
+
"""
|
| 104 |
+
path = os.environ.get("XDG_CACHE_HOME", "")
|
| 105 |
+
if not path.strip():
|
| 106 |
+
path = os.path.expanduser("~/.cache") # noqa: PTH111
|
| 107 |
+
return self._append_app_name_and_version(path)
|
| 108 |
+
|
| 109 |
+
@property
|
| 110 |
+
def site_cache_dir(self) -> str:
|
| 111 |
+
""":return: cache directory shared by users, e.g. ``/var/cache/$appname/$version``"""
|
| 112 |
+
return self._append_app_name_and_version("/var/cache")
|
| 113 |
+
|
| 114 |
+
@property
|
| 115 |
+
def user_state_dir(self) -> str:
|
| 116 |
+
"""
|
| 117 |
+
:return: state directory tied to the user, e.g. ``~/.local/state/$appname/$version`` or
|
| 118 |
+
``$XDG_STATE_HOME/$appname/$version``
|
| 119 |
+
"""
|
| 120 |
+
path = os.environ.get("XDG_STATE_HOME", "")
|
| 121 |
+
if not path.strip():
|
| 122 |
+
path = os.path.expanduser("~/.local/state") # noqa: PTH111
|
| 123 |
+
return self._append_app_name_and_version(path)
|
| 124 |
+
|
| 125 |
+
@property
|
| 126 |
+
def user_log_dir(self) -> str:
|
| 127 |
+
""":return: log directory tied to the user, same as `user_state_dir` if not opinionated else ``log`` in it"""
|
| 128 |
+
path = self.user_state_dir
|
| 129 |
+
if self.opinion:
|
| 130 |
+
path = os.path.join(path, "log") # noqa: PTH118
|
| 131 |
+
self._optionally_create_directory(path)
|
| 132 |
+
return path
|
| 133 |
+
|
| 134 |
+
@property
|
| 135 |
+
def user_documents_dir(self) -> str:
|
| 136 |
+
""":return: documents directory tied to the user, e.g. ``~/Documents``"""
|
| 137 |
+
return _get_user_media_dir("XDG_DOCUMENTS_DIR", "~/Documents")
|
| 138 |
+
|
| 139 |
+
@property
|
| 140 |
+
def user_downloads_dir(self) -> str:
|
| 141 |
+
""":return: downloads directory tied to the user, e.g. ``~/Downloads``"""
|
| 142 |
+
return _get_user_media_dir("XDG_DOWNLOAD_DIR", "~/Downloads")
|
| 143 |
+
|
| 144 |
+
@property
|
| 145 |
+
def user_pictures_dir(self) -> str:
|
| 146 |
+
""":return: pictures directory tied to the user, e.g. ``~/Pictures``"""
|
| 147 |
+
return _get_user_media_dir("XDG_PICTURES_DIR", "~/Pictures")
|
| 148 |
+
|
| 149 |
+
@property
|
| 150 |
+
def user_videos_dir(self) -> str:
|
| 151 |
+
""":return: videos directory tied to the user, e.g. ``~/Videos``"""
|
| 152 |
+
return _get_user_media_dir("XDG_VIDEOS_DIR", "~/Videos")
|
| 153 |
+
|
| 154 |
+
@property
|
| 155 |
+
def user_music_dir(self) -> str:
|
| 156 |
+
""":return: music directory tied to the user, e.g. ``~/Music``"""
|
| 157 |
+
return _get_user_media_dir("XDG_MUSIC_DIR", "~/Music")
|
| 158 |
+
|
| 159 |
+
@property
|
| 160 |
+
def user_desktop_dir(self) -> str:
|
| 161 |
+
""":return: desktop directory tied to the user, e.g. ``~/Desktop``"""
|
| 162 |
+
return _get_user_media_dir("XDG_DESKTOP_DIR", "~/Desktop")
|
| 163 |
+
|
| 164 |
+
@property
|
| 165 |
+
def user_runtime_dir(self) -> str:
|
| 166 |
+
"""
|
| 167 |
+
:return: runtime directory tied to the user, e.g. ``/run/user/$(id -u)/$appname/$version`` or
|
| 168 |
+
``$XDG_RUNTIME_DIR/$appname/$version``.
|
| 169 |
+
|
| 170 |
+
For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/user/$(id -u)/$appname/$version`` if
|
| 171 |
+
exists, otherwise ``/tmp/runtime-$(id -u)/$appname/$version``, if``$XDG_RUNTIME_DIR``
|
| 172 |
+
is not set.
|
| 173 |
+
"""
|
| 174 |
+
path = os.environ.get("XDG_RUNTIME_DIR", "")
|
| 175 |
+
if not path.strip():
|
| 176 |
+
if sys.platform.startswith(("freebsd", "openbsd", "netbsd")):
|
| 177 |
+
path = f"/var/run/user/{getuid()}"
|
| 178 |
+
if not Path(path).exists():
|
| 179 |
+
path = f"/tmp/runtime-{getuid()}" # noqa: S108
|
| 180 |
+
else:
|
| 181 |
+
path = f"/run/user/{getuid()}"
|
| 182 |
+
return self._append_app_name_and_version(path)
|
| 183 |
+
|
| 184 |
+
@property
|
| 185 |
+
def site_runtime_dir(self) -> str:
|
| 186 |
+
"""
|
| 187 |
+
:return: runtime directory shared by users, e.g. ``/run/$appname/$version`` or \
|
| 188 |
+
``$XDG_RUNTIME_DIR/$appname/$version``.
|
| 189 |
+
|
| 190 |
+
Note that this behaves almost exactly like `user_runtime_dir` if ``$XDG_RUNTIME_DIR`` is set, but will
|
| 191 |
+
fall back to paths associated to the root user instead of a regular logged-in user if it's not set.
|
| 192 |
+
|
| 193 |
+
If you wish to ensure that a logged-in root user path is returned e.g. ``/run/user/0``, use `user_runtime_dir`
|
| 194 |
+
instead.
|
| 195 |
+
|
| 196 |
+
For FreeBSD/OpenBSD/NetBSD, it would return ``/var/run/$appname/$version`` if ``$XDG_RUNTIME_DIR`` is not set.
|
| 197 |
+
"""
|
| 198 |
+
path = os.environ.get("XDG_RUNTIME_DIR", "")
|
| 199 |
+
if not path.strip():
|
| 200 |
+
if sys.platform.startswith(("freebsd", "openbsd", "netbsd")):
|
| 201 |
+
path = "/var/run"
|
| 202 |
+
else:
|
| 203 |
+
path = "/run"
|
| 204 |
+
return self._append_app_name_and_version(path)
|
| 205 |
+
|
| 206 |
+
@property
|
| 207 |
+
def site_data_path(self) -> Path:
|
| 208 |
+
""":return: data path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
|
| 209 |
+
return self._first_item_as_path_if_multipath(self.site_data_dir)
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def site_config_path(self) -> Path:
|
| 213 |
+
""":return: config path shared by the users, returns the first item, even if ``multipath`` is set to ``True``"""
|
| 214 |
+
return self._first_item_as_path_if_multipath(self.site_config_dir)
|
| 215 |
+
|
| 216 |
+
@property
|
| 217 |
+
def site_cache_path(self) -> Path:
|
| 218 |
+
""":return: cache path shared by users. Only return the first item, even if ``multipath`` is set to ``True``"""
|
| 219 |
+
return self._first_item_as_path_if_multipath(self.site_cache_dir)
|
| 220 |
+
|
| 221 |
+
def iter_config_dirs(self) -> Iterator[str]:
|
| 222 |
+
""":yield: all user and site configuration directories."""
|
| 223 |
+
yield self.user_config_dir
|
| 224 |
+
yield from self._site_config_dirs
|
| 225 |
+
|
| 226 |
+
def iter_data_dirs(self) -> Iterator[str]:
|
| 227 |
+
""":yield: all user and site data directories."""
|
| 228 |
+
yield self.user_data_dir
|
| 229 |
+
yield from self._site_data_dirs
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def _get_user_media_dir(env_var: str, fallback_tilde_path: str) -> str:
|
| 233 |
+
media_dir = _get_user_dirs_folder(env_var)
|
| 234 |
+
if media_dir is None:
|
| 235 |
+
media_dir = os.environ.get(env_var, "").strip()
|
| 236 |
+
if not media_dir:
|
| 237 |
+
media_dir = os.path.expanduser(fallback_tilde_path) # noqa: PTH111
|
| 238 |
+
|
| 239 |
+
return media_dir
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def _get_user_dirs_folder(key: str) -> str | None:
|
| 243 |
+
"""
|
| 244 |
+
Return directory from user-dirs.dirs config file.
|
| 245 |
+
|
| 246 |
+
See https://freedesktop.org/wiki/Software/xdg-user-dirs/.
|
| 247 |
+
|
| 248 |
+
"""
|
| 249 |
+
user_dirs_config_path = Path(Unix().user_config_dir) / "user-dirs.dirs"
|
| 250 |
+
if user_dirs_config_path.exists():
|
| 251 |
+
parser = ConfigParser()
|
| 252 |
+
|
| 253 |
+
with user_dirs_config_path.open() as stream:
|
| 254 |
+
# Add fake section header, so ConfigParser doesn't complain
|
| 255 |
+
parser.read_string(f"[top]\n{stream.read()}")
|
| 256 |
+
|
| 257 |
+
if key not in parser["top"]:
|
| 258 |
+
return None
|
| 259 |
+
|
| 260 |
+
path = parser["top"][key].strip('"')
|
| 261 |
+
# Handle relative home paths
|
| 262 |
+
return path.replace("$HOME", os.path.expanduser("~")) # noqa: PTH111
|
| 263 |
+
|
| 264 |
+
return None
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
__all__ = [
|
| 268 |
+
"Unix",
|
| 269 |
+
]
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/version.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# file generated by setuptools_scm
|
| 2 |
+
# don't change, don't track in version control
|
| 3 |
+
TYPE_CHECKING = False
|
| 4 |
+
if TYPE_CHECKING:
|
| 5 |
+
from typing import Tuple, Union
|
| 6 |
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
| 7 |
+
else:
|
| 8 |
+
VERSION_TUPLE = object
|
| 9 |
+
|
| 10 |
+
version: str
|
| 11 |
+
__version__: str
|
| 12 |
+
__version_tuple__: VERSION_TUPLE
|
| 13 |
+
version_tuple: VERSION_TUPLE
|
| 14 |
+
|
| 15 |
+
__version__ = version = '4.3.6'
|
| 16 |
+
__version_tuple__ = version_tuple = (4, 3, 6)
|
llava/lib/python3.10/site-packages/pip/_vendor/platformdirs/windows.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Windows."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
from functools import lru_cache
|
| 8 |
+
from typing import TYPE_CHECKING
|
| 9 |
+
|
| 10 |
+
from .api import PlatformDirsABC
|
| 11 |
+
|
| 12 |
+
if TYPE_CHECKING:
|
| 13 |
+
from collections.abc import Callable
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class Windows(PlatformDirsABC):
|
| 17 |
+
"""
|
| 18 |
+
`MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.
|
| 19 |
+
|
| 20 |
+
Makes use of the `appname <platformdirs.api.PlatformDirsABC.appname>`, `appauthor
|
| 21 |
+
<platformdirs.api.PlatformDirsABC.appauthor>`, `version <platformdirs.api.PlatformDirsABC.version>`, `roaming
|
| 22 |
+
<platformdirs.api.PlatformDirsABC.roaming>`, `opinion <platformdirs.api.PlatformDirsABC.opinion>`, `ensure_exists
|
| 23 |
+
<platformdirs.api.PlatformDirsABC.ensure_exists>`.
|
| 24 |
+
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
@property
|
| 28 |
+
def user_data_dir(self) -> str:
|
| 29 |
+
"""
|
| 30 |
+
:return: data directory tied to the user, e.g.
|
| 31 |
+
``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname`` (not roaming) or
|
| 32 |
+
``%USERPROFILE%\\AppData\\Roaming\\$appauthor\\$appname`` (roaming)
|
| 33 |
+
"""
|
| 34 |
+
const = "CSIDL_APPDATA" if self.roaming else "CSIDL_LOCAL_APPDATA"
|
| 35 |
+
path = os.path.normpath(get_win_folder(const))
|
| 36 |
+
return self._append_parts(path)
|
| 37 |
+
|
| 38 |
+
def _append_parts(self, path: str, *, opinion_value: str | None = None) -> str:
|
| 39 |
+
params = []
|
| 40 |
+
if self.appname:
|
| 41 |
+
if self.appauthor is not False:
|
| 42 |
+
author = self.appauthor or self.appname
|
| 43 |
+
params.append(author)
|
| 44 |
+
params.append(self.appname)
|
| 45 |
+
if opinion_value is not None and self.opinion:
|
| 46 |
+
params.append(opinion_value)
|
| 47 |
+
if self.version:
|
| 48 |
+
params.append(self.version)
|
| 49 |
+
path = os.path.join(path, *params) # noqa: PTH118
|
| 50 |
+
self._optionally_create_directory(path)
|
| 51 |
+
return path
|
| 52 |
+
|
| 53 |
+
@property
|
| 54 |
+
def site_data_dir(self) -> str:
|
| 55 |
+
""":return: data directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname``"""
|
| 56 |
+
path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA"))
|
| 57 |
+
return self._append_parts(path)
|
| 58 |
+
|
| 59 |
+
@property
|
| 60 |
+
def user_config_dir(self) -> str:
|
| 61 |
+
""":return: config directory tied to the user, same as `user_data_dir`"""
|
| 62 |
+
return self.user_data_dir
|
| 63 |
+
|
| 64 |
+
@property
|
| 65 |
+
def site_config_dir(self) -> str:
|
| 66 |
+
""":return: config directory shared by the users, same as `site_data_dir`"""
|
| 67 |
+
return self.site_data_dir
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def user_cache_dir(self) -> str:
|
| 71 |
+
"""
|
| 72 |
+
:return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g.
|
| 73 |
+
``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname\\Cache\\$version``
|
| 74 |
+
"""
|
| 75 |
+
path = os.path.normpath(get_win_folder("CSIDL_LOCAL_APPDATA"))
|
| 76 |
+
return self._append_parts(path, opinion_value="Cache")
|
| 77 |
+
|
| 78 |
+
@property
|
| 79 |
+
def site_cache_dir(self) -> str:
|
| 80 |
+
""":return: cache directory shared by users, e.g. ``C:\\ProgramData\\$appauthor\\$appname\\Cache\\$version``"""
|
| 81 |
+
path = os.path.normpath(get_win_folder("CSIDL_COMMON_APPDATA"))
|
| 82 |
+
return self._append_parts(path, opinion_value="Cache")
|
| 83 |
+
|
| 84 |
+
@property
|
| 85 |
+
def user_state_dir(self) -> str:
|
| 86 |
+
""":return: state directory tied to the user, same as `user_data_dir`"""
|
| 87 |
+
return self.user_data_dir
|
| 88 |
+
|
| 89 |
+
@property
|
| 90 |
+
def user_log_dir(self) -> str:
|
| 91 |
+
""":return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in it"""
|
| 92 |
+
path = self.user_data_dir
|
| 93 |
+
if self.opinion:
|
| 94 |
+
path = os.path.join(path, "Logs") # noqa: PTH118
|
| 95 |
+
self._optionally_create_directory(path)
|
| 96 |
+
return path
|
| 97 |
+
|
| 98 |
+
@property
|
| 99 |
+
def user_documents_dir(self) -> str:
|
| 100 |
+
""":return: documents directory tied to the user e.g. ``%USERPROFILE%\\Documents``"""
|
| 101 |
+
return os.path.normpath(get_win_folder("CSIDL_PERSONAL"))
|
| 102 |
+
|
| 103 |
+
@property
|
| 104 |
+
def user_downloads_dir(self) -> str:
|
| 105 |
+
""":return: downloads directory tied to the user e.g. ``%USERPROFILE%\\Downloads``"""
|
| 106 |
+
return os.path.normpath(get_win_folder("CSIDL_DOWNLOADS"))
|
| 107 |
+
|
| 108 |
+
@property
|
| 109 |
+
def user_pictures_dir(self) -> str:
|
| 110 |
+
""":return: pictures directory tied to the user e.g. ``%USERPROFILE%\\Pictures``"""
|
| 111 |
+
return os.path.normpath(get_win_folder("CSIDL_MYPICTURES"))
|
| 112 |
+
|
| 113 |
+
@property
|
| 114 |
+
def user_videos_dir(self) -> str:
|
| 115 |
+
""":return: videos directory tied to the user e.g. ``%USERPROFILE%\\Videos``"""
|
| 116 |
+
return os.path.normpath(get_win_folder("CSIDL_MYVIDEO"))
|
| 117 |
+
|
| 118 |
+
@property
|
| 119 |
+
def user_music_dir(self) -> str:
|
| 120 |
+
""":return: music directory tied to the user e.g. ``%USERPROFILE%\\Music``"""
|
| 121 |
+
return os.path.normpath(get_win_folder("CSIDL_MYMUSIC"))
|
| 122 |
+
|
| 123 |
+
@property
|
| 124 |
+
def user_desktop_dir(self) -> str:
|
| 125 |
+
""":return: desktop directory tied to the user, e.g. ``%USERPROFILE%\\Desktop``"""
|
| 126 |
+
return os.path.normpath(get_win_folder("CSIDL_DESKTOPDIRECTORY"))
|
| 127 |
+
|
| 128 |
+
@property
|
| 129 |
+
def user_runtime_dir(self) -> str:
|
| 130 |
+
"""
|
| 131 |
+
:return: runtime directory tied to the user, e.g.
|
| 132 |
+
``%USERPROFILE%\\AppData\\Local\\Temp\\$appauthor\\$appname``
|
| 133 |
+
"""
|
| 134 |
+
path = os.path.normpath(os.path.join(get_win_folder("CSIDL_LOCAL_APPDATA"), "Temp")) # noqa: PTH118
|
| 135 |
+
return self._append_parts(path)
|
| 136 |
+
|
| 137 |
+
@property
|
| 138 |
+
def site_runtime_dir(self) -> str:
|
| 139 |
+
""":return: runtime directory shared by users, same as `user_runtime_dir`"""
|
| 140 |
+
return self.user_runtime_dir
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def get_win_folder_from_env_vars(csidl_name: str) -> str:
|
| 144 |
+
"""Get folder from environment variables."""
|
| 145 |
+
result = get_win_folder_if_csidl_name_not_env_var(csidl_name)
|
| 146 |
+
if result is not None:
|
| 147 |
+
return result
|
| 148 |
+
|
| 149 |
+
env_var_name = {
|
| 150 |
+
"CSIDL_APPDATA": "APPDATA",
|
| 151 |
+
"CSIDL_COMMON_APPDATA": "ALLUSERSPROFILE",
|
| 152 |
+
"CSIDL_LOCAL_APPDATA": "LOCALAPPDATA",
|
| 153 |
+
}.get(csidl_name)
|
| 154 |
+
if env_var_name is None:
|
| 155 |
+
msg = f"Unknown CSIDL name: {csidl_name}"
|
| 156 |
+
raise ValueError(msg)
|
| 157 |
+
result = os.environ.get(env_var_name)
|
| 158 |
+
if result is None:
|
| 159 |
+
msg = f"Unset environment variable: {env_var_name}"
|
| 160 |
+
raise ValueError(msg)
|
| 161 |
+
return result
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def get_win_folder_if_csidl_name_not_env_var(csidl_name: str) -> str | None:
|
| 165 |
+
"""Get a folder for a CSIDL name that does not exist as an environment variable."""
|
| 166 |
+
if csidl_name == "CSIDL_PERSONAL":
|
| 167 |
+
return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Documents") # noqa: PTH118
|
| 168 |
+
|
| 169 |
+
if csidl_name == "CSIDL_DOWNLOADS":
|
| 170 |
+
return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Downloads") # noqa: PTH118
|
| 171 |
+
|
| 172 |
+
if csidl_name == "CSIDL_MYPICTURES":
|
| 173 |
+
return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Pictures") # noqa: PTH118
|
| 174 |
+
|
| 175 |
+
if csidl_name == "CSIDL_MYVIDEO":
|
| 176 |
+
return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Videos") # noqa: PTH118
|
| 177 |
+
|
| 178 |
+
if csidl_name == "CSIDL_MYMUSIC":
|
| 179 |
+
return os.path.join(os.path.normpath(os.environ["USERPROFILE"]), "Music") # noqa: PTH118
|
| 180 |
+
return None
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def get_win_folder_from_registry(csidl_name: str) -> str:
|
| 184 |
+
"""
|
| 185 |
+
Get folder from the registry.
|
| 186 |
+
|
| 187 |
+
This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer
|
| 188 |
+
for all CSIDL_* names.
|
| 189 |
+
|
| 190 |
+
"""
|
| 191 |
+
shell_folder_name = {
|
| 192 |
+
"CSIDL_APPDATA": "AppData",
|
| 193 |
+
"CSIDL_COMMON_APPDATA": "Common AppData",
|
| 194 |
+
"CSIDL_LOCAL_APPDATA": "Local AppData",
|
| 195 |
+
"CSIDL_PERSONAL": "Personal",
|
| 196 |
+
"CSIDL_DOWNLOADS": "{374DE290-123F-4565-9164-39C4925E467B}",
|
| 197 |
+
"CSIDL_MYPICTURES": "My Pictures",
|
| 198 |
+
"CSIDL_MYVIDEO": "My Video",
|
| 199 |
+
"CSIDL_MYMUSIC": "My Music",
|
| 200 |
+
}.get(csidl_name)
|
| 201 |
+
if shell_folder_name is None:
|
| 202 |
+
msg = f"Unknown CSIDL name: {csidl_name}"
|
| 203 |
+
raise ValueError(msg)
|
| 204 |
+
if sys.platform != "win32": # only needed for mypy type checker to know that this code runs only on Windows
|
| 205 |
+
raise NotImplementedError
|
| 206 |
+
import winreg # noqa: PLC0415
|
| 207 |
+
|
| 208 |
+
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
|
| 209 |
+
directory, _ = winreg.QueryValueEx(key, shell_folder_name)
|
| 210 |
+
return str(directory)
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def get_win_folder_via_ctypes(csidl_name: str) -> str:
|
| 214 |
+
"""Get folder with ctypes."""
|
| 215 |
+
# There is no 'CSIDL_DOWNLOADS'.
|
| 216 |
+
# Use 'CSIDL_PROFILE' (40) and append the default folder 'Downloads' instead.
|
| 217 |
+
# https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid
|
| 218 |
+
|
| 219 |
+
import ctypes # noqa: PLC0415
|
| 220 |
+
|
| 221 |
+
csidl_const = {
|
| 222 |
+
"CSIDL_APPDATA": 26,
|
| 223 |
+
"CSIDL_COMMON_APPDATA": 35,
|
| 224 |
+
"CSIDL_LOCAL_APPDATA": 28,
|
| 225 |
+
"CSIDL_PERSONAL": 5,
|
| 226 |
+
"CSIDL_MYPICTURES": 39,
|
| 227 |
+
"CSIDL_MYVIDEO": 14,
|
| 228 |
+
"CSIDL_MYMUSIC": 13,
|
| 229 |
+
"CSIDL_DOWNLOADS": 40,
|
| 230 |
+
"CSIDL_DESKTOPDIRECTORY": 16,
|
| 231 |
+
}.get(csidl_name)
|
| 232 |
+
if csidl_const is None:
|
| 233 |
+
msg = f"Unknown CSIDL name: {csidl_name}"
|
| 234 |
+
raise ValueError(msg)
|
| 235 |
+
|
| 236 |
+
buf = ctypes.create_unicode_buffer(1024)
|
| 237 |
+
windll = getattr(ctypes, "windll") # noqa: B009 # using getattr to avoid false positive with mypy type checker
|
| 238 |
+
windll.shell32.SHGetFolderPathW(None, csidl_const, None, 0, buf)
|
| 239 |
+
|
| 240 |
+
# Downgrade to short path name if it has high-bit chars.
|
| 241 |
+
if any(ord(c) > 255 for c in buf): # noqa: PLR2004
|
| 242 |
+
buf2 = ctypes.create_unicode_buffer(1024)
|
| 243 |
+
if windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
|
| 244 |
+
buf = buf2
|
| 245 |
+
|
| 246 |
+
if csidl_name == "CSIDL_DOWNLOADS":
|
| 247 |
+
return os.path.join(buf.value, "Downloads") # noqa: PTH118
|
| 248 |
+
|
| 249 |
+
return buf.value
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def _pick_get_win_folder() -> Callable[[str], str]:
|
| 253 |
+
try:
|
| 254 |
+
import ctypes # noqa: PLC0415
|
| 255 |
+
except ImportError:
|
| 256 |
+
pass
|
| 257 |
+
else:
|
| 258 |
+
if hasattr(ctypes, "windll"):
|
| 259 |
+
return get_win_folder_via_ctypes
|
| 260 |
+
try:
|
| 261 |
+
import winreg # noqa: PLC0415, F401
|
| 262 |
+
except ImportError:
|
| 263 |
+
return get_win_folder_from_env_vars
|
| 264 |
+
else:
|
| 265 |
+
return get_win_folder_from_registry
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
get_win_folder = lru_cache(maxsize=None)(_pick_get_win_folder())
|
| 269 |
+
|
| 270 |
+
__all__ = [
|
| 271 |
+
"Windows",
|
| 272 |
+
]
|
llava/lib/python3.10/site-packages/pip/_vendor/typing_extensions.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (182 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/autoscaling_requester.cpython-310.pyc
ADDED
|
Binary file (3.92 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/legacy_compat.cpython-310.pyc
ADDED
|
Binary file (5.62 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/resource_manager.cpython-310.pyc
ADDED
|
Binary file (18.9 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/streaming_executor.cpython-310.pyc
ADDED
|
Binary file (14.6 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/streaming_executor_state.cpython-310.pyc
ADDED
|
Binary file (20 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/__pycache__/util.cpython-310.pyc
ADDED
|
Binary file (3.06 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .autoscaler import Autoscaler
|
| 2 |
+
from .autoscaling_actor_pool import AutoscalingActorPool
|
| 3 |
+
from .default_autoscaler import DefaultAutoscaler
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def create_autoscaler(topology, resource_manager, execution_id):
|
| 7 |
+
return DefaultAutoscaler(topology, resource_manager, execution_id)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
__all__ = [
|
| 11 |
+
"Autoscaler",
|
| 12 |
+
"DefaultAutoscaler",
|
| 13 |
+
"create_autoscaler",
|
| 14 |
+
"AutoscalingActorPool",
|
| 15 |
+
]
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (565 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/autoscaler.cpython-310.pyc
ADDED
|
Binary file (1.99 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/autoscaling_actor_pool.cpython-310.pyc
ADDED
|
Binary file (3.46 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/__pycache__/default_autoscaler.cpython-310.pyc
ADDED
|
Binary file (6.23 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/autoscaler.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
from typing import TYPE_CHECKING
|
| 3 |
+
|
| 4 |
+
from ray.data._internal.execution.interfaces.execution_options import ExecutionResources
|
| 5 |
+
from ray.util.annotations import DeveloperAPI
|
| 6 |
+
|
| 7 |
+
if TYPE_CHECKING:
|
| 8 |
+
from ray.data._internal.execution.resource_manager import ResourceManager
|
| 9 |
+
from ray.data._internal.execution.streaming_executor_state import Topology
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@DeveloperAPI
|
| 13 |
+
class Autoscaler(ABC):
|
| 14 |
+
"""Abstract interface for Ray Data autoscaler."""
|
| 15 |
+
|
| 16 |
+
def __init__(
|
| 17 |
+
self,
|
| 18 |
+
topology: "Topology",
|
| 19 |
+
resource_manager: "ResourceManager",
|
| 20 |
+
execution_id: str,
|
| 21 |
+
):
|
| 22 |
+
self._topology = topology
|
| 23 |
+
self._resource_manager = resource_manager
|
| 24 |
+
self._execution_id = execution_id
|
| 25 |
+
|
| 26 |
+
@abstractmethod
|
| 27 |
+
def try_trigger_scaling(self):
|
| 28 |
+
"""Try trigger autoscaling.
|
| 29 |
+
|
| 30 |
+
This method will be called each time when StreamingExecutor makes
|
| 31 |
+
a scheduling decision. A subclass should override this method to
|
| 32 |
+
handle the autoscaling of both the cluster and `AutoscalingActorPool`s.
|
| 33 |
+
"""
|
| 34 |
+
...
|
| 35 |
+
|
| 36 |
+
@abstractmethod
|
| 37 |
+
def on_executor_shutdown(self):
|
| 38 |
+
"""Callback when the StreamingExecutor is shutting down."""
|
| 39 |
+
...
|
| 40 |
+
|
| 41 |
+
@abstractmethod
|
| 42 |
+
def get_total_resources(self) -> ExecutionResources:
|
| 43 |
+
"""Get the total resources that are available to this data execution."""
|
| 44 |
+
...
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/autoscaling_actor_pool.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
|
| 3 |
+
from ray.util.annotations import DeveloperAPI
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@DeveloperAPI
|
| 7 |
+
class AutoscalingActorPool(ABC):
|
| 8 |
+
"""Abstract interface of an autoscaling actor pool.
|
| 9 |
+
|
| 10 |
+
A `PhysicalOperator` can manage one or more `AutoscalingActorPool`s.
|
| 11 |
+
`Autoscaler` is responsible for deciding autoscaling of these actor
|
| 12 |
+
pools.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
@abstractmethod
|
| 16 |
+
def min_size(self) -> int:
|
| 17 |
+
"""Min size of the actor pool."""
|
| 18 |
+
...
|
| 19 |
+
|
| 20 |
+
@abstractmethod
|
| 21 |
+
def max_size(self) -> int:
|
| 22 |
+
"""Max size of the actor pool."""
|
| 23 |
+
...
|
| 24 |
+
|
| 25 |
+
@abstractmethod
|
| 26 |
+
def current_size(self) -> int:
|
| 27 |
+
"""Current size of the actor pool."""
|
| 28 |
+
...
|
| 29 |
+
|
| 30 |
+
@abstractmethod
|
| 31 |
+
def num_running_actors(self) -> int:
|
| 32 |
+
"""Number of running actors."""
|
| 33 |
+
...
|
| 34 |
+
|
| 35 |
+
@abstractmethod
|
| 36 |
+
def num_active_actors(self) -> int:
|
| 37 |
+
"""Number of actors with at least one active task."""
|
| 38 |
+
...
|
| 39 |
+
|
| 40 |
+
@abstractmethod
|
| 41 |
+
def num_pending_actors(self) -> int:
|
| 42 |
+
"""Number of actors pending creation."""
|
| 43 |
+
...
|
| 44 |
+
|
| 45 |
+
@abstractmethod
|
| 46 |
+
def max_tasks_in_flight_per_actor(self) -> int:
|
| 47 |
+
"""Max number of in-flight tasks per actor."""
|
| 48 |
+
...
|
| 49 |
+
|
| 50 |
+
@abstractmethod
|
| 51 |
+
def current_in_flight_tasks(self) -> int:
|
| 52 |
+
"""Number of current in-flight tasks."""
|
| 53 |
+
...
|
| 54 |
+
|
| 55 |
+
def num_total_task_slots(self) -> int:
|
| 56 |
+
"""Total number of task slots."""
|
| 57 |
+
return self.max_tasks_in_flight_per_actor() * self.current_size()
|
| 58 |
+
|
| 59 |
+
def num_free_task_slots(self) -> int:
|
| 60 |
+
"""Number of free slots to run tasks."""
|
| 61 |
+
return (
|
| 62 |
+
self.max_tasks_in_flight_per_actor() * self.current_size()
|
| 63 |
+
- self.current_in_flight_tasks()
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
@abstractmethod
|
| 67 |
+
def scale_up(self, num_actors: int) -> int:
|
| 68 |
+
"""Request the actor pool to scale up by the given number of actors.
|
| 69 |
+
|
| 70 |
+
The number of actually added actors may be less than the requested
|
| 71 |
+
number.
|
| 72 |
+
|
| 73 |
+
Returns:
|
| 74 |
+
The number of actors actually added.
|
| 75 |
+
"""
|
| 76 |
+
...
|
| 77 |
+
|
| 78 |
+
@abstractmethod
|
| 79 |
+
def scale_down(self, num_actors: int) -> int:
|
| 80 |
+
"""Request actor pool to scale down by the given number of actors.
|
| 81 |
+
|
| 82 |
+
The number of actually removed actors may be less than the requested
|
| 83 |
+
number.
|
| 84 |
+
|
| 85 |
+
Returns:
|
| 86 |
+
The number of actors actually removed.
|
| 87 |
+
"""
|
| 88 |
+
...
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/autoscaler/default_autoscaler.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import time
|
| 3 |
+
from typing import TYPE_CHECKING, Dict
|
| 4 |
+
|
| 5 |
+
import ray
|
| 6 |
+
from .autoscaler import Autoscaler
|
| 7 |
+
from .autoscaling_actor_pool import AutoscalingActorPool
|
| 8 |
+
from ray.data._internal.execution.autoscaling_requester import (
|
| 9 |
+
get_or_create_autoscaling_requester_actor,
|
| 10 |
+
)
|
| 11 |
+
from ray.data._internal.execution.interfaces.execution_options import ExecutionResources
|
| 12 |
+
|
| 13 |
+
if TYPE_CHECKING:
|
| 14 |
+
from ray.data._internal.execution.interfaces import PhysicalOperator
|
| 15 |
+
from ray.data._internal.execution.resource_manager import ResourceManager
|
| 16 |
+
from ray.data._internal.execution.streaming_executor_state import OpState, Topology
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class DefaultAutoscaler(Autoscaler):
|
| 20 |
+
|
| 21 |
+
# Default threshold of actor pool utilization to trigger scaling up.
|
| 22 |
+
DEFAULT_ACTOR_POOL_SCALING_UP_THRESHOLD: float = 0.8
|
| 23 |
+
# Default threshold of actor pool utilization to trigger scaling down.
|
| 24 |
+
DEFAULT_ACTOR_POOL_SCALING_DOWN_THRESHOLD: float = 0.5
|
| 25 |
+
|
| 26 |
+
# Min number of seconds between two autoscaling requests.
|
| 27 |
+
MIN_GAP_BETWEEN_AUTOSCALING_REQUESTS = 20
|
| 28 |
+
|
| 29 |
+
def __init__(
|
| 30 |
+
self,
|
| 31 |
+
topology: "Topology",
|
| 32 |
+
resource_manager: "ResourceManager",
|
| 33 |
+
execution_id: str,
|
| 34 |
+
actor_pool_scaling_up_threshold: float = DEFAULT_ACTOR_POOL_SCALING_UP_THRESHOLD, # noqa: E501
|
| 35 |
+
actor_pool_scaling_down_threshold: float = DEFAULT_ACTOR_POOL_SCALING_DOWN_THRESHOLD, # noqa: E501
|
| 36 |
+
):
|
| 37 |
+
self._actor_pool_scaling_up_threshold = actor_pool_scaling_up_threshold
|
| 38 |
+
self._actor_pool_scaling_down_threshold = actor_pool_scaling_down_threshold
|
| 39 |
+
# Last time when a request was sent to Ray's autoscaler.
|
| 40 |
+
self._last_request_time = 0
|
| 41 |
+
super().__init__(topology, resource_manager, execution_id)
|
| 42 |
+
|
| 43 |
+
def try_trigger_scaling(self):
|
| 44 |
+
self._try_scale_up_cluster()
|
| 45 |
+
self._try_scale_up_or_down_actor_pool()
|
| 46 |
+
|
| 47 |
+
def _calculate_actor_pool_util(self, actor_pool: AutoscalingActorPool):
|
| 48 |
+
"""Calculate the utilization of the given actor pool."""
|
| 49 |
+
if actor_pool.current_size() == 0:
|
| 50 |
+
return 0
|
| 51 |
+
else:
|
| 52 |
+
return actor_pool.num_active_actors() / actor_pool.current_size()
|
| 53 |
+
|
| 54 |
+
def _actor_pool_should_scale_up(
|
| 55 |
+
self,
|
| 56 |
+
actor_pool: AutoscalingActorPool,
|
| 57 |
+
op: "PhysicalOperator",
|
| 58 |
+
op_state: "OpState",
|
| 59 |
+
):
|
| 60 |
+
# Do not scale up, if the op is completed or no more inputs are coming.
|
| 61 |
+
if op.completed() or (op._inputs_complete and op.internal_queue_size() == 0):
|
| 62 |
+
return False
|
| 63 |
+
if actor_pool.current_size() < actor_pool.min_size():
|
| 64 |
+
# Scale up, if the actor pool is below min size.
|
| 65 |
+
return True
|
| 66 |
+
elif actor_pool.current_size() >= actor_pool.max_size():
|
| 67 |
+
# Do not scale up, if the actor pool is already at max size.
|
| 68 |
+
return False
|
| 69 |
+
# Do not scale up, if the op does not have more resources.
|
| 70 |
+
if not op_state._scheduling_status.under_resource_limits:
|
| 71 |
+
return False
|
| 72 |
+
# Do not scale up, if the op has enough free slots for the existing inputs.
|
| 73 |
+
if op_state.num_queued() <= actor_pool.num_free_task_slots():
|
| 74 |
+
return False
|
| 75 |
+
# Determine whether to scale up based on the actor pool utilization.
|
| 76 |
+
util = self._calculate_actor_pool_util(actor_pool)
|
| 77 |
+
return util > self._actor_pool_scaling_up_threshold
|
| 78 |
+
|
| 79 |
+
def _actor_pool_should_scale_down(
|
| 80 |
+
self,
|
| 81 |
+
actor_pool: AutoscalingActorPool,
|
| 82 |
+
op: "PhysicalOperator",
|
| 83 |
+
):
|
| 84 |
+
# Scale down, if the op is completed or no more inputs are coming.
|
| 85 |
+
if op.completed() or (op._inputs_complete and op.internal_queue_size() == 0):
|
| 86 |
+
return True
|
| 87 |
+
if actor_pool.current_size() > actor_pool.max_size():
|
| 88 |
+
# Scale down, if the actor pool is above max size.
|
| 89 |
+
return True
|
| 90 |
+
elif actor_pool.current_size() <= actor_pool.min_size():
|
| 91 |
+
# Do not scale down, if the actor pool is already at min size.
|
| 92 |
+
return False
|
| 93 |
+
# Determine whether to scale down based on the actor pool utilization.
|
| 94 |
+
util = self._calculate_actor_pool_util(actor_pool)
|
| 95 |
+
return util < self._actor_pool_scaling_down_threshold
|
| 96 |
+
|
| 97 |
+
def _try_scale_up_or_down_actor_pool(self):
|
| 98 |
+
for op, state in self._topology.items():
|
| 99 |
+
actor_pools = op.get_autoscaling_actor_pools()
|
| 100 |
+
for actor_pool in actor_pools:
|
| 101 |
+
while True:
|
| 102 |
+
# Try to scale up or down the actor pool.
|
| 103 |
+
should_scale_up = self._actor_pool_should_scale_up(
|
| 104 |
+
actor_pool,
|
| 105 |
+
op,
|
| 106 |
+
state,
|
| 107 |
+
)
|
| 108 |
+
should_scale_down = self._actor_pool_should_scale_down(
|
| 109 |
+
actor_pool, op
|
| 110 |
+
)
|
| 111 |
+
if should_scale_up and not should_scale_down:
|
| 112 |
+
if actor_pool.scale_up(1) == 0:
|
| 113 |
+
break
|
| 114 |
+
elif should_scale_down and not should_scale_up:
|
| 115 |
+
if actor_pool.scale_down(1) == 0:
|
| 116 |
+
break
|
| 117 |
+
else:
|
| 118 |
+
break
|
| 119 |
+
|
| 120 |
+
def _try_scale_up_cluster(self):
|
| 121 |
+
"""Try to scale up the cluster to accomodate the provided in-progress workload.
|
| 122 |
+
|
| 123 |
+
This makes a resource request to Ray's autoscaler consisting of the current,
|
| 124 |
+
aggregate usage of all operators in the DAG + the incremental usage of all
|
| 125 |
+
operators that are ready for dispatch (i.e. that have inputs queued). If the
|
| 126 |
+
autoscaler were to grant this resource request, it would allow us to dispatch
|
| 127 |
+
one task for every ready operator.
|
| 128 |
+
|
| 129 |
+
Note that this resource request does not take the global resource limits or the
|
| 130 |
+
liveness policy into account; it only tries to make the existing resource usage
|
| 131 |
+
+ one more task per ready operator feasible in the cluster.
|
| 132 |
+
"""
|
| 133 |
+
# Limit the frequency of autoscaling requests.
|
| 134 |
+
now = time.time()
|
| 135 |
+
if now - self._last_request_time < self.MIN_GAP_BETWEEN_AUTOSCALING_REQUESTS:
|
| 136 |
+
return
|
| 137 |
+
|
| 138 |
+
# Scale up the cluster, if no ops are allowed to run, but there are still data
|
| 139 |
+
# in the input queues.
|
| 140 |
+
no_runnable_op = all(
|
| 141 |
+
op_state._scheduling_status.runnable is False
|
| 142 |
+
for _, op_state in self._topology.items()
|
| 143 |
+
)
|
| 144 |
+
any_has_input = any(
|
| 145 |
+
op_state.num_queued() > 0 for _, op_state in self._topology.items()
|
| 146 |
+
)
|
| 147 |
+
if not (no_runnable_op and any_has_input):
|
| 148 |
+
return
|
| 149 |
+
|
| 150 |
+
self._last_request_time = now
|
| 151 |
+
|
| 152 |
+
# Get resource usage for all ops + additional resources needed to launch one
|
| 153 |
+
# more task for each ready op.
|
| 154 |
+
resource_request = []
|
| 155 |
+
|
| 156 |
+
def to_bundle(resource: ExecutionResources) -> Dict:
|
| 157 |
+
req = {}
|
| 158 |
+
if resource.cpu:
|
| 159 |
+
req["CPU"] = math.ceil(resource.cpu)
|
| 160 |
+
if resource.gpu:
|
| 161 |
+
req["GPU"] = math.ceil(resource.gpu)
|
| 162 |
+
return req
|
| 163 |
+
|
| 164 |
+
for op, state in self._topology.items():
|
| 165 |
+
per_task_resource = op.incremental_resource_usage()
|
| 166 |
+
task_bundle = to_bundle(per_task_resource)
|
| 167 |
+
resource_request.extend([task_bundle] * op.num_active_tasks())
|
| 168 |
+
# Only include incremental resource usage for ops that are ready for
|
| 169 |
+
# dispatch.
|
| 170 |
+
if state.num_queued() > 0:
|
| 171 |
+
# TODO(Clark): Scale up more aggressively by adding incremental resource
|
| 172 |
+
# usage for more than one bundle in the queue for this op?
|
| 173 |
+
resource_request.append(task_bundle)
|
| 174 |
+
|
| 175 |
+
self._send_resource_request(resource_request)
|
| 176 |
+
|
| 177 |
+
def _send_resource_request(self, resource_request):
|
| 178 |
+
# Make autoscaler resource request.
|
| 179 |
+
actor = get_or_create_autoscaling_requester_actor()
|
| 180 |
+
actor.request_resources.remote(resource_request, self._execution_id)
|
| 181 |
+
|
| 182 |
+
def on_executor_shutdown(self):
|
| 183 |
+
# Make request for zero resources to autoscaler for this execution.
|
| 184 |
+
actor = get_or_create_autoscaling_requester_actor()
|
| 185 |
+
actor.request_resources.remote({}, self._execution_id)
|
| 186 |
+
|
| 187 |
+
def get_total_resources(self) -> ExecutionResources:
|
| 188 |
+
return ExecutionResources.from_resource_dict(ray.cluster_resources())
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/__init__.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING
|
| 2 |
+
|
| 3 |
+
import ray
|
| 4 |
+
from .backpressure_policy import BackpressurePolicy
|
| 5 |
+
from .concurrency_cap_backpressure_policy import ConcurrencyCapBackpressurePolicy
|
| 6 |
+
|
| 7 |
+
if TYPE_CHECKING:
|
| 8 |
+
from ray.data._internal.execution.streaming_executor_state import Topology
|
| 9 |
+
|
| 10 |
+
# Default enabled backpressure policies and its config key.
|
| 11 |
+
# Use `DataContext.set_config` to config it.
|
| 12 |
+
ENABLED_BACKPRESSURE_POLICIES = [
|
| 13 |
+
ConcurrencyCapBackpressurePolicy,
|
| 14 |
+
]
|
| 15 |
+
ENABLED_BACKPRESSURE_POLICIES_CONFIG_KEY = "backpressure_policies.enabled"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def get_backpressure_policies(topology: "Topology"):
|
| 19 |
+
data_context = ray.data.DataContext.get_current()
|
| 20 |
+
policies = data_context.get_config(
|
| 21 |
+
ENABLED_BACKPRESSURE_POLICIES_CONFIG_KEY, ENABLED_BACKPRESSURE_POLICIES
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
return [policy(topology) for policy in policies]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
__all__ = [
|
| 28 |
+
"BackpressurePolicy",
|
| 29 |
+
"ConcurrencyCapBackpressurePolicy",
|
| 30 |
+
"ENABLED_BACKPRESSURE_POLICIES_CONFIG_KEY",
|
| 31 |
+
"get_backpressure_policies",
|
| 32 |
+
]
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/backpressure_policy.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
from typing import TYPE_CHECKING
|
| 3 |
+
|
| 4 |
+
if TYPE_CHECKING:
|
| 5 |
+
from ray.data._internal.execution.interfaces.physical_operator import (
|
| 6 |
+
PhysicalOperator,
|
| 7 |
+
)
|
| 8 |
+
from ray.data._internal.execution.streaming_executor_state import Topology
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class BackpressurePolicy(ABC):
|
| 12 |
+
"""Interface for back pressure policies."""
|
| 13 |
+
|
| 14 |
+
@abstractmethod
|
| 15 |
+
def __init__(self, topology: "Topology"):
|
| 16 |
+
...
|
| 17 |
+
|
| 18 |
+
def can_add_input(self, op: "PhysicalOperator") -> bool:
|
| 19 |
+
"""Determine if we can add a new input to the operator. If returns False, the
|
| 20 |
+
operator will be backpressured and will not be able to run new tasks.
|
| 21 |
+
Used in `streaming_executor_state.py::select_operator_to_run()`.
|
| 22 |
+
|
| 23 |
+
Returns: True if we can add a new input to the operator, False otherwise.
|
| 24 |
+
|
| 25 |
+
Note, if multiple backpressure policies are enabled, the operator will be
|
| 26 |
+
backpressured if any of the policies returns False.
|
| 27 |
+
"""
|
| 28 |
+
return True
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/backpressure_policy/concurrency_cap_backpressure_policy.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
from typing import TYPE_CHECKING
|
| 3 |
+
|
| 4 |
+
from .backpressure_policy import BackpressurePolicy
|
| 5 |
+
from ray.data._internal.execution.operators.task_pool_map_operator import (
|
| 6 |
+
TaskPoolMapOperator,
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
if TYPE_CHECKING:
|
| 10 |
+
from ray.data._internal.execution.interfaces.physical_operator import (
|
| 11 |
+
PhysicalOperator,
|
| 12 |
+
)
|
| 13 |
+
from ray.data._internal.execution.streaming_executor_state import Topology
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class ConcurrencyCapBackpressurePolicy(BackpressurePolicy):
|
| 19 |
+
"""A backpressure policy that caps the concurrency of each operator.
|
| 20 |
+
|
| 21 |
+
The policy will limit the number of concurrently running tasks based on its
|
| 22 |
+
concurrency cap parameter.
|
| 23 |
+
|
| 24 |
+
NOTE: Only support setting concurrency cap for `TaskPoolMapOperator` for now.
|
| 25 |
+
TODO(chengsu): Consolidate with actor scaling logic of `ActorPoolMapOperator`.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
def __init__(self, topology: "Topology"):
|
| 29 |
+
self._concurrency_caps: dict["PhysicalOperator", float] = {}
|
| 30 |
+
|
| 31 |
+
for op, _ in topology.items():
|
| 32 |
+
if isinstance(op, TaskPoolMapOperator) and op.get_concurrency() is not None:
|
| 33 |
+
self._concurrency_caps[op] = op.get_concurrency()
|
| 34 |
+
else:
|
| 35 |
+
self._concurrency_caps[op] = float("inf")
|
| 36 |
+
|
| 37 |
+
logger.debug(
|
| 38 |
+
"ConcurrencyCapBackpressurePolicy initialized with: "
|
| 39 |
+
f"{self._concurrency_caps}"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
def can_add_input(self, op: "PhysicalOperator") -> bool:
|
| 43 |
+
return op.metrics.num_tasks_running < self._concurrency_caps[op]
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (658 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/common.cpython-310.pyc
ADDED
|
Binary file (208 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/execution_options.cpython-310.pyc
ADDED
|
Binary file (10.4 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/executor.cpython-310.pyc
ADDED
|
Binary file (3.45 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/op_runtime_metrics.cpython-310.pyc
ADDED
|
Binary file (15.6 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/physical_operator.cpython-310.pyc
ADDED
|
Binary file (21.6 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/ref_bundle.cpython-310.pyc
ADDED
|
Binary file (5.55 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/task_context.cpython-310.pyc
ADDED
|
Binary file (1.03 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/__pycache__/transform_fn.cpython-310.pyc
ADDED
|
Binary file (481 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/common.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Node id string returned by `ray.get_runtime_context().get_node_id()`.
|
| 2 |
+
NodeIdStr = str
|
minigpt2/lib/python3.10/site-packages/ray/data/_internal/execution/interfaces/task_context.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
from typing import TYPE_CHECKING, Any, Dict, Optional
|
| 3 |
+
|
| 4 |
+
from ray.data._internal.progress_bar import ProgressBar
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from ray.data._internal.execution.operators.map_transformer import MapTransformer
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@dataclass
|
| 11 |
+
class TaskContext:
|
| 12 |
+
"""This describes the information of a task running block transform."""
|
| 13 |
+
|
| 14 |
+
# The index of task. Each task has a unique task index within the same
|
| 15 |
+
# operator.
|
| 16 |
+
task_idx: int
|
| 17 |
+
|
| 18 |
+
# The dictionary of sub progress bar to update. The key is name of sub progress
|
| 19 |
+
# bar. Note this is only used on driver side.
|
| 20 |
+
# TODO(chengsu): clean it up from TaskContext with new optimizer framework.
|
| 21 |
+
sub_progress_bar_dict: Optional[Dict[str, ProgressBar]] = None
|
| 22 |
+
|
| 23 |
+
# NOTE(hchen): `upstream_map_transformer` and `upstream_map_ray_remote_args`
|
| 24 |
+
# are only used for `RandomShuffle`. DO NOT use them for other operators.
|
| 25 |
+
# Ideally, they should be handled by the optimizer, and should be transparent
|
| 26 |
+
# to the specific operators.
|
| 27 |
+
# But for `RandomShuffle`, the AllToAllOperator doesn't do the shuffle itself.
|
| 28 |
+
# It uses `ExchangeTaskScheduler` to launch new tasks to do the shuffle.
|
| 29 |
+
# That's why we need to pass them to `ExchangeTaskScheduler`.
|
| 30 |
+
# TODO(hchen): Use a physical operator to do the shuffle directly.
|
| 31 |
+
|
| 32 |
+
# The underlying function called in a MapOperator; this is used when fusing
|
| 33 |
+
# an AllToAllOperator with an upstream MapOperator.
|
| 34 |
+
upstream_map_transformer: Optional["MapTransformer"] = None
|
| 35 |
+
|
| 36 |
+
# The Ray remote arguments of the fused upstream MapOperator.
|
| 37 |
+
# This should be set if upstream_map_transformer is set.
|
| 38 |
+
upstream_map_ray_remote_args: Optional[Dict[str, Any]] = None
|
| 39 |
+
|
| 40 |
+
# The target maximum number of bytes to include in the task's output block.
|
| 41 |
+
target_max_block_size: Optional[int] = None
|