初始化分支,生成完整依赖安装文件,main添加索引现在可以使用vscode打开了
This commit is contained in:
parent
1d8b78593e
commit
b4a4d8a478
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
venv/
|
BIN
requirements.txt
Normal file
BIN
requirements.txt
Normal file
Binary file not shown.
BIN
src/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/constants.cpython-310.pyc
Normal file
BIN
src/__pycache__/constants.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/exceptions.cpython-310.pyc
Normal file
BIN
src/__pycache__/exceptions.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/main.cpython-310.pyc
Normal file
BIN
src/__pycache__/main.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/responses.cpython-310.pyc
Normal file
BIN
src/__pycache__/responses.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/tortoises.cpython-310.pyc
Normal file
BIN
src/__pycache__/tortoises.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/tortoises_orm_config.cpython-310.pyc
Normal file
BIN
src/__pycache__/tortoises_orm_config.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/backtest/__pycache__/bollinger_bands.cpython-310.pyc
Normal file
BIN
src/backtest/__pycache__/bollinger_bands.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/backtest/__pycache__/dual_moving_average.cpython-310.pyc
Normal file
BIN
src/backtest/__pycache__/dual_moving_average.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/backtest/__pycache__/router.cpython-310.pyc
Normal file
BIN
src/backtest/__pycache__/router.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/backtest/__pycache__/rsi_strategy.cpython-310.pyc
Normal file
BIN
src/backtest/__pycache__/rsi_strategy.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/backtest/__pycache__/service.cpython-310.pyc
Normal file
BIN
src/backtest/__pycache__/service.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/combination/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/combination/__pycache__/bollinger_bands.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/bollinger_bands.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/combination/__pycache__/dual_moving_average.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/dual_moving_average.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/combination/__pycache__/router.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/router.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/combination/__pycache__/rsi_strategy.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/rsi_strategy.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/combination/__pycache__/service.cpython-310.pyc
Normal file
BIN
src/combination/__pycache__/service.cpython-310.pyc
Normal file
Binary file not shown.
@ -1,3 +1,9 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
# 添加项目的根目录到 sys.path
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||||
|
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
BIN
src/models/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/back_observed_data.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/back_observed_data.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/back_observed_data_detail.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/back_observed_data_detail.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/back_position.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/back_position.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/back_result_indicator.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/back_result_indicator.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/back_trand_info.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/back_trand_info.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/backtest.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/backtest.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/order.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/order.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/position.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/position.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/security_account.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/security_account.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/snowball.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/snowball.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/stock.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/stock.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/stock_bt_history.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/stock_bt_history.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/stock_data_processing.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/stock_data_processing.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/stock_details.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/stock_details.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/stock_history.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/stock_history.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/strategy.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/strategy.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/test_table.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/test_table.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/tran_observer_data.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/tran_observer_data.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/tran_orders.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/tran_orders.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/tran_position.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/tran_position.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/tran_return.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/tran_return.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/tran_trade_info.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/tran_trade_info.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/trand_info.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/trand_info.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/transaction.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/transaction.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/user_combination_history.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/user_combination_history.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/models/__pycache__/wance_data_stock.cpython-310.pyc
Normal file
BIN
src/models/__pycache__/wance_data_stock.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/pydantic/__pycache__/backtest_request.cpython-310.pyc
Normal file
BIN
src/pydantic/__pycache__/backtest_request.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/pydantic/__pycache__/codelistrequest.cpython-310.pyc
Normal file
BIN
src/pydantic/__pycache__/codelistrequest.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/pydantic/__pycache__/factor_request.cpython-310.pyc
Normal file
BIN
src/pydantic/__pycache__/factor_request.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/pydantic/__pycache__/request_data.cpython-310.pyc
Normal file
BIN
src/pydantic/__pycache__/request_data.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/settings/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/settings/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/settings/__pycache__/config.cpython-310.pyc
Normal file
BIN
src/settings/__pycache__/config.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/backtest_until.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/backtest_until.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/combination_until.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/combination_until.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/helpers.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/helpers.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/utils/__pycache__/models.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/paginations.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/paginations.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/utils/__pycache__/redis.cpython-310.pyc
Normal file
BIN
src/utils/__pycache__/redis.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/xtdata/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
src/xtdata/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/xtdata/__pycache__/router.cpython-310.pyc
Normal file
BIN
src/xtdata/__pycache__/router.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/xtdata/__pycache__/service.cpython-310.pyc
Normal file
BIN
src/xtdata/__pycache__/service.cpython-310.pyc
Normal file
Binary file not shown.
220
venv/Lib/site-packages/_distutils_hack/__init__.py
Normal file
220
venv/Lib/site-packages/_distutils_hack/__init__.py
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
# don't import any costly modules
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def warn_distutils_present():
|
||||||
|
if 'distutils' not in sys.modules:
|
||||||
|
return
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
warnings.warn(
|
||||||
|
"Distutils was imported before Setuptools, but importing Setuptools "
|
||||||
|
"also replaces the `distutils` module in `sys.modules`. This may lead "
|
||||||
|
"to undesirable behaviors or errors. To avoid these issues, avoid "
|
||||||
|
"using distutils directly, ensure that setuptools is installed in the "
|
||||||
|
"traditional way (e.g. not an editable install), and/or make sure "
|
||||||
|
"that setuptools is always imported before distutils."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def clear_distutils():
|
||||||
|
if 'distutils' not in sys.modules:
|
||||||
|
return
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
warnings.warn("Setuptools is replacing distutils.")
|
||||||
|
mods = [
|
||||||
|
name
|
||||||
|
for name in sys.modules
|
||||||
|
if name == "distutils" or name.startswith("distutils.")
|
||||||
|
]
|
||||||
|
for name in mods:
|
||||||
|
del sys.modules[name]
|
||||||
|
|
||||||
|
|
||||||
|
def enabled():
|
||||||
|
"""
|
||||||
|
Allow selection of distutils by environment variable.
|
||||||
|
"""
|
||||||
|
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
|
||||||
|
return which == 'local'
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_local_distutils():
|
||||||
|
import importlib
|
||||||
|
|
||||||
|
clear_distutils()
|
||||||
|
|
||||||
|
# With the DistutilsMetaFinder in place,
|
||||||
|
# perform an import to cause distutils to be
|
||||||
|
# loaded from setuptools._distutils. Ref #2906.
|
||||||
|
with shim():
|
||||||
|
importlib.import_module('distutils')
|
||||||
|
|
||||||
|
# check that submodules load as expected
|
||||||
|
core = importlib.import_module('distutils.core')
|
||||||
|
assert '_distutils' in core.__file__, core.__file__
|
||||||
|
assert 'setuptools._distutils.log' not in sys.modules
|
||||||
|
|
||||||
|
|
||||||
|
def do_override():
|
||||||
|
"""
|
||||||
|
Ensure that the local copy of distutils is preferred over stdlib.
|
||||||
|
|
||||||
|
See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401
|
||||||
|
for more motivation.
|
||||||
|
"""
|
||||||
|
if enabled():
|
||||||
|
warn_distutils_present()
|
||||||
|
ensure_local_distutils()
|
||||||
|
|
||||||
|
|
||||||
|
class _TrivialRe:
|
||||||
|
def __init__(self, *patterns):
|
||||||
|
self._patterns = patterns
|
||||||
|
|
||||||
|
def match(self, string):
|
||||||
|
return all(pat in string for pat in self._patterns)
|
||||||
|
|
||||||
|
|
||||||
|
class DistutilsMetaFinder:
|
||||||
|
def find_spec(self, fullname, path, target=None):
|
||||||
|
# optimization: only consider top level modules and those
|
||||||
|
# found in the CPython test suite.
|
||||||
|
if path is not None and not fullname.startswith('test.'):
|
||||||
|
return None
|
||||||
|
|
||||||
|
method_name = 'spec_for_{fullname}'.format(**locals())
|
||||||
|
method = getattr(self, method_name, lambda: None)
|
||||||
|
return method()
|
||||||
|
|
||||||
|
def spec_for_distutils(self):
|
||||||
|
if self.is_cpython():
|
||||||
|
return None
|
||||||
|
|
||||||
|
import importlib
|
||||||
|
import importlib.abc
|
||||||
|
import importlib.util
|
||||||
|
|
||||||
|
try:
|
||||||
|
mod = importlib.import_module('setuptools._distutils')
|
||||||
|
except Exception:
|
||||||
|
# There are a couple of cases where setuptools._distutils
|
||||||
|
# may not be present:
|
||||||
|
# - An older Setuptools without a local distutils is
|
||||||
|
# taking precedence. Ref #2957.
|
||||||
|
# - Path manipulation during sitecustomize removes
|
||||||
|
# setuptools from the path but only after the hook
|
||||||
|
# has been loaded. Ref #2980.
|
||||||
|
# In either case, fall back to stdlib behavior.
|
||||||
|
return None
|
||||||
|
|
||||||
|
class DistutilsLoader(importlib.abc.Loader):
|
||||||
|
def create_module(self, spec):
|
||||||
|
mod.__name__ = 'distutils'
|
||||||
|
return mod
|
||||||
|
|
||||||
|
def exec_module(self, module):
|
||||||
|
pass
|
||||||
|
|
||||||
|
return importlib.util.spec_from_loader(
|
||||||
|
'distutils', DistutilsLoader(), origin=mod.__file__
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_cpython():
|
||||||
|
"""
|
||||||
|
Suppress supplying distutils for CPython (build and tests).
|
||||||
|
Ref #2965 and #3007.
|
||||||
|
"""
|
||||||
|
return os.path.isfile('pybuilddir.txt')
|
||||||
|
|
||||||
|
def spec_for_pip(self):
|
||||||
|
"""
|
||||||
|
Ensure stdlib distutils when running under pip.
|
||||||
|
See pypa/pip#8761 for rationale.
|
||||||
|
"""
|
||||||
|
if sys.version_info >= (3, 12) or self.pip_imported_during_build():
|
||||||
|
return
|
||||||
|
clear_distutils()
|
||||||
|
self.spec_for_distutils = lambda: None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def pip_imported_during_build(cls):
|
||||||
|
"""
|
||||||
|
Detect if pip is being imported in a build script. Ref #2355.
|
||||||
|
"""
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
return any(
|
||||||
|
cls.frame_file_is_setup(frame) for frame, line in traceback.walk_stack(None)
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def frame_file_is_setup(frame):
|
||||||
|
"""
|
||||||
|
Return True if the indicated frame suggests a setup.py file.
|
||||||
|
"""
|
||||||
|
# some frames may not have __file__ (#2940)
|
||||||
|
return frame.f_globals.get('__file__', '').endswith('setup.py')
|
||||||
|
|
||||||
|
def spec_for_sensitive_tests(self):
|
||||||
|
"""
|
||||||
|
Ensure stdlib distutils when running select tests under CPython.
|
||||||
|
|
||||||
|
python/cpython#91169
|
||||||
|
"""
|
||||||
|
clear_distutils()
|
||||||
|
self.spec_for_distutils = lambda: None
|
||||||
|
|
||||||
|
sensitive_tests = (
|
||||||
|
[
|
||||||
|
'test.test_distutils',
|
||||||
|
'test.test_peg_generator',
|
||||||
|
'test.test_importlib',
|
||||||
|
]
|
||||||
|
if sys.version_info < (3, 10)
|
||||||
|
else [
|
||||||
|
'test.test_distutils',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
for name in DistutilsMetaFinder.sensitive_tests:
|
||||||
|
setattr(
|
||||||
|
DistutilsMetaFinder,
|
||||||
|
f'spec_for_{name}',
|
||||||
|
DistutilsMetaFinder.spec_for_sensitive_tests,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
DISTUTILS_FINDER = DistutilsMetaFinder()
|
||||||
|
|
||||||
|
|
||||||
|
def add_shim():
|
||||||
|
DISTUTILS_FINDER in sys.meta_path or insert_shim()
|
||||||
|
|
||||||
|
|
||||||
|
class shim:
|
||||||
|
def __enter__(self):
|
||||||
|
insert_shim()
|
||||||
|
|
||||||
|
def __exit__(self, exc, value, tb):
|
||||||
|
_remove_shim()
|
||||||
|
|
||||||
|
|
||||||
|
def insert_shim():
|
||||||
|
sys.meta_path.insert(0, DISTUTILS_FINDER)
|
||||||
|
|
||||||
|
|
||||||
|
def _remove_shim():
|
||||||
|
try:
|
||||||
|
sys.meta_path.remove(DISTUTILS_FINDER)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (3, 12):
|
||||||
|
# DistutilsMetaFinder can only be disabled in Python < 3.12 (PEP 632)
|
||||||
|
remove_shim = _remove_shim
|
Binary file not shown.
Binary file not shown.
1
venv/Lib/site-packages/_distutils_hack/override.py
Normal file
1
venv/Lib/site-packages/_distutils_hack/override.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__import__('_distutils_hack').do_override()
|
1
venv/Lib/site-packages/distutils-precedence.pth
Normal file
1
venv/Lib/site-packages/distutils-precedence.pth
Normal file
@ -0,0 +1 @@
|
|||||||
|
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
|
13
venv/Lib/site-packages/pip/__init__.py
Normal file
13
venv/Lib/site-packages/pip/__init__.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
__version__ = "24.1.2"
|
||||||
|
|
||||||
|
|
||||||
|
def main(args: Optional[List[str]] = None) -> int:
|
||||||
|
"""This is an internal API only meant for use by pip's own console scripts.
|
||||||
|
|
||||||
|
For additional details, see https://github.com/pypa/pip/issues/7498.
|
||||||
|
"""
|
||||||
|
from pip._internal.utils.entrypoints import _wrapper
|
||||||
|
|
||||||
|
return _wrapper(args)
|
24
venv/Lib/site-packages/pip/__main__.py
Normal file
24
venv/Lib/site-packages/pip/__main__.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Remove '' and current working directory from the first entry
|
||||||
|
# of sys.path, if present to avoid using current directory
|
||||||
|
# in pip commands check, freeze, install, list and show,
|
||||||
|
# when invoked as python -m pip <command>
|
||||||
|
if sys.path[0] in ("", os.getcwd()):
|
||||||
|
sys.path.pop(0)
|
||||||
|
|
||||||
|
# If we are running from a wheel, add the wheel to sys.path
|
||||||
|
# This allows the usage python pip-*.whl/pip install pip-*.whl
|
||||||
|
if __package__ == "":
|
||||||
|
# __file__ is pip-*.whl/pip/__main__.py
|
||||||
|
# first dirname call strips of '/__main__.py', second strips off '/pip'
|
||||||
|
# Resulting path is the name of the wheel itself
|
||||||
|
# Add that to sys.path so we can import pip
|
||||||
|
path = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
sys.path.insert(0, path)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from pip._internal.cli.main import main as _main
|
||||||
|
|
||||||
|
sys.exit(_main())
|
BIN
venv/Lib/site-packages/pip/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
venv/Lib/site-packages/pip/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
venv/Lib/site-packages/pip/__pycache__/__main__.cpython-310.pyc
Normal file
BIN
venv/Lib/site-packages/pip/__pycache__/__main__.cpython-310.pyc
Normal file
Binary file not shown.
18
venv/Lib/site-packages/pip/_internal/__init__.py
Normal file
18
venv/Lib/site-packages/pip/_internal/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
from pip._internal.utils import _log
|
||||||
|
|
||||||
|
# init_logging() must be called before any call to logging.getLogger()
|
||||||
|
# which happens at import of most modules.
|
||||||
|
_log.init_logging()
|
||||||
|
|
||||||
|
|
||||||
|
def main(args: Optional[List[str]] = None) -> int:
|
||||||
|
"""This is preserved for old console scripts that may still be referencing
|
||||||
|
it.
|
||||||
|
|
||||||
|
For additional details, see https://github.com/pypa/pip/issues/7498.
|
||||||
|
"""
|
||||||
|
from pip._internal.utils.entrypoints import _wrapper
|
||||||
|
|
||||||
|
return _wrapper(args)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
venv/Lib/site-packages/pip/_internal/__pycache__/self_outdated_check.cpython-310.pyc
Normal file
BIN
venv/Lib/site-packages/pip/_internal/__pycache__/self_outdated_check.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
314
venv/Lib/site-packages/pip/_internal/build_env.py
Normal file
314
venv/Lib/site-packages/pip/_internal/build_env.py
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
"""Build Environment used for isolation during sdist building
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import site
|
||||||
|
import sys
|
||||||
|
import textwrap
|
||||||
|
from collections import OrderedDict
|
||||||
|
from types import TracebackType
|
||||||
|
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union
|
||||||
|
|
||||||
|
from pip._vendor.certifi import where
|
||||||
|
from pip._vendor.packaging.requirements import Requirement
|
||||||
|
from pip._vendor.packaging.version import Version
|
||||||
|
|
||||||
|
from pip import __file__ as pip_location
|
||||||
|
from pip._internal.cli.spinners import open_spinner
|
||||||
|
from pip._internal.locations import get_platlib, get_purelib, get_scheme
|
||||||
|
from pip._internal.metadata import get_default_environment, get_environment
|
||||||
|
from pip._internal.utils.logging import VERBOSE
|
||||||
|
from pip._internal.utils.subprocess import call_subprocess
|
||||||
|
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pip._internal.index.package_finder import PackageFinder
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _dedup(a: str, b: str) -> Union[Tuple[str], Tuple[str, str]]:
|
||||||
|
return (a, b) if a != b else (a,)
|
||||||
|
|
||||||
|
|
||||||
|
class _Prefix:
|
||||||
|
def __init__(self, path: str) -> None:
|
||||||
|
self.path = path
|
||||||
|
self.setup = False
|
||||||
|
scheme = get_scheme("", prefix=path)
|
||||||
|
self.bin_dir = scheme.scripts
|
||||||
|
self.lib_dirs = _dedup(scheme.purelib, scheme.platlib)
|
||||||
|
|
||||||
|
|
||||||
|
def get_runnable_pip() -> str:
|
||||||
|
"""Get a file to pass to a Python executable, to run the currently-running pip.
|
||||||
|
|
||||||
|
This is used to run a pip subprocess, for installing requirements into the build
|
||||||
|
environment.
|
||||||
|
"""
|
||||||
|
source = pathlib.Path(pip_location).resolve().parent
|
||||||
|
|
||||||
|
if not source.is_dir():
|
||||||
|
# This would happen if someone is using pip from inside a zip file. In that
|
||||||
|
# case, we can use that directly.
|
||||||
|
return str(source)
|
||||||
|
|
||||||
|
return os.fsdecode(source / "__pip-runner__.py")
|
||||||
|
|
||||||
|
|
||||||
|
def _get_system_sitepackages() -> Set[str]:
|
||||||
|
"""Get system site packages
|
||||||
|
|
||||||
|
Usually from site.getsitepackages,
|
||||||
|
but fallback on `get_purelib()/get_platlib()` if unavailable
|
||||||
|
(e.g. in a virtualenv created by virtualenv<20)
|
||||||
|
|
||||||
|
Returns normalized set of strings.
|
||||||
|
"""
|
||||||
|
if hasattr(site, "getsitepackages"):
|
||||||
|
system_sites = site.getsitepackages()
|
||||||
|
else:
|
||||||
|
# virtualenv < 20 overwrites site.py without getsitepackages
|
||||||
|
# fallback on get_purelib/get_platlib.
|
||||||
|
# this is known to miss things, but shouldn't in the cases
|
||||||
|
# where getsitepackages() has been removed (inside a virtualenv)
|
||||||
|
system_sites = [get_purelib(), get_platlib()]
|
||||||
|
return {os.path.normcase(path) for path in system_sites}
|
||||||
|
|
||||||
|
|
||||||
|
class BuildEnvironment:
|
||||||
|
"""Creates and manages an isolated environment to install build deps"""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
temp_dir = TempDirectory(kind=tempdir_kinds.BUILD_ENV, globally_managed=True)
|
||||||
|
|
||||||
|
self._prefixes = OrderedDict(
|
||||||
|
(name, _Prefix(os.path.join(temp_dir.path, name)))
|
||||||
|
for name in ("normal", "overlay")
|
||||||
|
)
|
||||||
|
|
||||||
|
self._bin_dirs: List[str] = []
|
||||||
|
self._lib_dirs: List[str] = []
|
||||||
|
for prefix in reversed(list(self._prefixes.values())):
|
||||||
|
self._bin_dirs.append(prefix.bin_dir)
|
||||||
|
self._lib_dirs.extend(prefix.lib_dirs)
|
||||||
|
|
||||||
|
# Customize site to:
|
||||||
|
# - ensure .pth files are honored
|
||||||
|
# - prevent access to system site packages
|
||||||
|
system_sites = _get_system_sitepackages()
|
||||||
|
|
||||||
|
self._site_dir = os.path.join(temp_dir.path, "site")
|
||||||
|
if not os.path.exists(self._site_dir):
|
||||||
|
os.mkdir(self._site_dir)
|
||||||
|
with open(
|
||||||
|
os.path.join(self._site_dir, "sitecustomize.py"), "w", encoding="utf-8"
|
||||||
|
) as fp:
|
||||||
|
fp.write(
|
||||||
|
textwrap.dedent(
|
||||||
|
"""
|
||||||
|
import os, site, sys
|
||||||
|
|
||||||
|
# First, drop system-sites related paths.
|
||||||
|
original_sys_path = sys.path[:]
|
||||||
|
known_paths = set()
|
||||||
|
for path in {system_sites!r}:
|
||||||
|
site.addsitedir(path, known_paths=known_paths)
|
||||||
|
system_paths = set(
|
||||||
|
os.path.normcase(path)
|
||||||
|
for path in sys.path[len(original_sys_path):]
|
||||||
|
)
|
||||||
|
original_sys_path = [
|
||||||
|
path for path in original_sys_path
|
||||||
|
if os.path.normcase(path) not in system_paths
|
||||||
|
]
|
||||||
|
sys.path = original_sys_path
|
||||||
|
|
||||||
|
# Second, add lib directories.
|
||||||
|
# ensuring .pth file are processed.
|
||||||
|
for path in {lib_dirs!r}:
|
||||||
|
assert not path in sys.path
|
||||||
|
site.addsitedir(path)
|
||||||
|
"""
|
||||||
|
).format(system_sites=system_sites, lib_dirs=self._lib_dirs)
|
||||||
|
)
|
||||||
|
|
||||||
|
def __enter__(self) -> None:
|
||||||
|
self._save_env = {
|
||||||
|
name: os.environ.get(name, None)
|
||||||
|
for name in ("PATH", "PYTHONNOUSERSITE", "PYTHONPATH")
|
||||||
|
}
|
||||||
|
|
||||||
|
path = self._bin_dirs[:]
|
||||||
|
old_path = self._save_env["PATH"]
|
||||||
|
if old_path:
|
||||||
|
path.extend(old_path.split(os.pathsep))
|
||||||
|
|
||||||
|
pythonpath = [self._site_dir]
|
||||||
|
|
||||||
|
os.environ.update(
|
||||||
|
{
|
||||||
|
"PATH": os.pathsep.join(path),
|
||||||
|
"PYTHONNOUSERSITE": "1",
|
||||||
|
"PYTHONPATH": os.pathsep.join(pythonpath),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_val: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None:
|
||||||
|
for varname, old_value in self._save_env.items():
|
||||||
|
if old_value is None:
|
||||||
|
os.environ.pop(varname, None)
|
||||||
|
else:
|
||||||
|
os.environ[varname] = old_value
|
||||||
|
|
||||||
|
def check_requirements(
|
||||||
|
self, reqs: Iterable[str]
|
||||||
|
) -> Tuple[Set[Tuple[str, str]], Set[str]]:
|
||||||
|
"""Return 2 sets:
|
||||||
|
- conflicting requirements: set of (installed, wanted) reqs tuples
|
||||||
|
- missing requirements: set of reqs
|
||||||
|
"""
|
||||||
|
missing = set()
|
||||||
|
conflicting = set()
|
||||||
|
if reqs:
|
||||||
|
env = (
|
||||||
|
get_environment(self._lib_dirs)
|
||||||
|
if hasattr(self, "_lib_dirs")
|
||||||
|
else get_default_environment()
|
||||||
|
)
|
||||||
|
for req_str in reqs:
|
||||||
|
req = Requirement(req_str)
|
||||||
|
# We're explicitly evaluating with an empty extra value, since build
|
||||||
|
# environments are not provided any mechanism to select specific extras.
|
||||||
|
if req.marker is not None and not req.marker.evaluate({"extra": ""}):
|
||||||
|
continue
|
||||||
|
dist = env.get_distribution(req.name)
|
||||||
|
if not dist:
|
||||||
|
missing.add(req_str)
|
||||||
|
continue
|
||||||
|
if isinstance(dist.version, Version):
|
||||||
|
installed_req_str = f"{req.name}=={dist.version}"
|
||||||
|
else:
|
||||||
|
installed_req_str = f"{req.name}==={dist.version}"
|
||||||
|
if not req.specifier.contains(dist.version, prereleases=True):
|
||||||
|
conflicting.add((installed_req_str, req_str))
|
||||||
|
# FIXME: Consider direct URL?
|
||||||
|
return conflicting, missing
|
||||||
|
|
||||||
|
def install_requirements(
|
||||||
|
self,
|
||||||
|
finder: "PackageFinder",
|
||||||
|
requirements: Iterable[str],
|
||||||
|
prefix_as_string: str,
|
||||||
|
*,
|
||||||
|
kind: str,
|
||||||
|
) -> None:
|
||||||
|
prefix = self._prefixes[prefix_as_string]
|
||||||
|
assert not prefix.setup
|
||||||
|
prefix.setup = True
|
||||||
|
if not requirements:
|
||||||
|
return
|
||||||
|
self._install_requirements(
|
||||||
|
get_runnable_pip(),
|
||||||
|
finder,
|
||||||
|
requirements,
|
||||||
|
prefix,
|
||||||
|
kind=kind,
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _install_requirements(
|
||||||
|
pip_runnable: str,
|
||||||
|
finder: "PackageFinder",
|
||||||
|
requirements: Iterable[str],
|
||||||
|
prefix: _Prefix,
|
||||||
|
*,
|
||||||
|
kind: str,
|
||||||
|
) -> None:
|
||||||
|
args: List[str] = [
|
||||||
|
sys.executable,
|
||||||
|
pip_runnable,
|
||||||
|
"install",
|
||||||
|
"--ignore-installed",
|
||||||
|
"--no-user",
|
||||||
|
"--prefix",
|
||||||
|
prefix.path,
|
||||||
|
"--no-warn-script-location",
|
||||||
|
]
|
||||||
|
if logger.getEffectiveLevel() <= logging.DEBUG:
|
||||||
|
args.append("-vv")
|
||||||
|
elif logger.getEffectiveLevel() <= VERBOSE:
|
||||||
|
args.append("-v")
|
||||||
|
for format_control in ("no_binary", "only_binary"):
|
||||||
|
formats = getattr(finder.format_control, format_control)
|
||||||
|
args.extend(
|
||||||
|
(
|
||||||
|
"--" + format_control.replace("_", "-"),
|
||||||
|
",".join(sorted(formats or {":none:"})),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
index_urls = finder.index_urls
|
||||||
|
if index_urls:
|
||||||
|
args.extend(["-i", index_urls[0]])
|
||||||
|
for extra_index in index_urls[1:]:
|
||||||
|
args.extend(["--extra-index-url", extra_index])
|
||||||
|
else:
|
||||||
|
args.append("--no-index")
|
||||||
|
for link in finder.find_links:
|
||||||
|
args.extend(["--find-links", link])
|
||||||
|
|
||||||
|
for host in finder.trusted_hosts:
|
||||||
|
args.extend(["--trusted-host", host])
|
||||||
|
if finder.allow_all_prereleases:
|
||||||
|
args.append("--pre")
|
||||||
|
if finder.prefer_binary:
|
||||||
|
args.append("--prefer-binary")
|
||||||
|
args.append("--")
|
||||||
|
args.extend(requirements)
|
||||||
|
extra_environ = {"_PIP_STANDALONE_CERT": where()}
|
||||||
|
with open_spinner(f"Installing {kind}") as spinner:
|
||||||
|
call_subprocess(
|
||||||
|
args,
|
||||||
|
command_desc=f"pip subprocess to install {kind}",
|
||||||
|
spinner=spinner,
|
||||||
|
extra_environ=extra_environ,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class NoOpBuildEnvironment(BuildEnvironment):
|
||||||
|
"""A no-op drop-in replacement for BuildEnvironment"""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __enter__(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_val: Optional[BaseException],
|
||||||
|
exc_tb: Optional[TracebackType],
|
||||||
|
) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cleanup(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def install_requirements(
|
||||||
|
self,
|
||||||
|
finder: "PackageFinder",
|
||||||
|
requirements: Iterable[str],
|
||||||
|
prefix_as_string: str,
|
||||||
|
*,
|
||||||
|
kind: str,
|
||||||
|
) -> None:
|
||||||
|
raise NotImplementedError()
|
290
venv/Lib/site-packages/pip/_internal/cache.py
Normal file
290
venv/Lib/site-packages/pip/_internal/cache.py
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
"""Cache Management
|
||||||
|
"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
|
from pip._vendor.packaging.tags import Tag, interpreter_name, interpreter_version
|
||||||
|
from pip._vendor.packaging.utils import canonicalize_name
|
||||||
|
|
||||||
|
from pip._internal.exceptions import InvalidWheelFilename
|
||||||
|
from pip._internal.models.direct_url import DirectUrl
|
||||||
|
from pip._internal.models.link import Link
|
||||||
|
from pip._internal.models.wheel import Wheel
|
||||||
|
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
|
||||||
|
from pip._internal.utils.urls import path_to_url
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ORIGIN_JSON_NAME = "origin.json"
|
||||||
|
|
||||||
|
|
||||||
|
def _hash_dict(d: Dict[str, str]) -> str:
|
||||||
|
"""Return a stable sha224 of a dictionary."""
|
||||||
|
s = json.dumps(d, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
|
||||||
|
return hashlib.sha224(s.encode("ascii")).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
class Cache:
|
||||||
|
"""An abstract class - provides cache directories for data from links
|
||||||
|
|
||||||
|
:param cache_dir: The root of the cache.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, cache_dir: str) -> None:
|
||||||
|
super().__init__()
|
||||||
|
assert not cache_dir or os.path.isabs(cache_dir)
|
||||||
|
self.cache_dir = cache_dir or None
|
||||||
|
|
||||||
|
def _get_cache_path_parts(self, link: Link) -> List[str]:
|
||||||
|
"""Get parts of part that must be os.path.joined with cache_dir"""
|
||||||
|
|
||||||
|
# We want to generate an url to use as our cache key, we don't want to
|
||||||
|
# just reuse the URL because it might have other items in the fragment
|
||||||
|
# and we don't care about those.
|
||||||
|
key_parts = {"url": link.url_without_fragment}
|
||||||
|
if link.hash_name is not None and link.hash is not None:
|
||||||
|
key_parts[link.hash_name] = link.hash
|
||||||
|
if link.subdirectory_fragment:
|
||||||
|
key_parts["subdirectory"] = link.subdirectory_fragment
|
||||||
|
|
||||||
|
# Include interpreter name, major and minor version in cache key
|
||||||
|
# to cope with ill-behaved sdists that build a different wheel
|
||||||
|
# depending on the python version their setup.py is being run on,
|
||||||
|
# and don't encode the difference in compatibility tags.
|
||||||
|
# https://github.com/pypa/pip/issues/7296
|
||||||
|
key_parts["interpreter_name"] = interpreter_name()
|
||||||
|
key_parts["interpreter_version"] = interpreter_version()
|
||||||
|
|
||||||
|
# Encode our key url with sha224, we'll use this because it has similar
|
||||||
|
# security properties to sha256, but with a shorter total output (and
|
||||||
|
# thus less secure). However the differences don't make a lot of
|
||||||
|
# difference for our use case here.
|
||||||
|
hashed = _hash_dict(key_parts)
|
||||||
|
|
||||||
|
# We want to nest the directories some to prevent having a ton of top
|
||||||
|
# level directories where we might run out of sub directories on some
|
||||||
|
# FS.
|
||||||
|
parts = [hashed[:2], hashed[2:4], hashed[4:6], hashed[6:]]
|
||||||
|
|
||||||
|
return parts
|
||||||
|
|
||||||
|
def _get_candidates(self, link: Link, canonical_package_name: str) -> List[Any]:
|
||||||
|
can_not_cache = not self.cache_dir or not canonical_package_name or not link
|
||||||
|
if can_not_cache:
|
||||||
|
return []
|
||||||
|
|
||||||
|
path = self.get_path_for_link(link)
|
||||||
|
if os.path.isdir(path):
|
||||||
|
return [(candidate, path) for candidate in os.listdir(path)]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_path_for_link(self, link: Link) -> str:
|
||||||
|
"""Return a directory to store cached items in for link."""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def get(
|
||||||
|
self,
|
||||||
|
link: Link,
|
||||||
|
package_name: Optional[str],
|
||||||
|
supported_tags: List[Tag],
|
||||||
|
) -> Link:
|
||||||
|
"""Returns a link to a cached item if it exists, otherwise returns the
|
||||||
|
passed link.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleWheelCache(Cache):
|
||||||
|
"""A cache of wheels for future installs."""
|
||||||
|
|
||||||
|
def __init__(self, cache_dir: str) -> None:
|
||||||
|
super().__init__(cache_dir)
|
||||||
|
|
||||||
|
def get_path_for_link(self, link: Link) -> str:
|
||||||
|
"""Return a directory to store cached wheels for link
|
||||||
|
|
||||||
|
Because there are M wheels for any one sdist, we provide a directory
|
||||||
|
to cache them in, and then consult that directory when looking up
|
||||||
|
cache hits.
|
||||||
|
|
||||||
|
We only insert things into the cache if they have plausible version
|
||||||
|
numbers, so that we don't contaminate the cache with things that were
|
||||||
|
not unique. E.g. ./package might have dozens of installs done for it
|
||||||
|
and build a version of 0.0...and if we built and cached a wheel, we'd
|
||||||
|
end up using the same wheel even if the source has been edited.
|
||||||
|
|
||||||
|
:param link: The link of the sdist for which this will cache wheels.
|
||||||
|
"""
|
||||||
|
parts = self._get_cache_path_parts(link)
|
||||||
|
assert self.cache_dir
|
||||||
|
# Store wheels within the root cache_dir
|
||||||
|
return os.path.join(self.cache_dir, "wheels", *parts)
|
||||||
|
|
||||||
|
def get(
|
||||||
|
self,
|
||||||
|
link: Link,
|
||||||
|
package_name: Optional[str],
|
||||||
|
supported_tags: List[Tag],
|
||||||
|
) -> Link:
|
||||||
|
candidates = []
|
||||||
|
|
||||||
|
if not package_name:
|
||||||
|
return link
|
||||||
|
|
||||||
|
canonical_package_name = canonicalize_name(package_name)
|
||||||
|
for wheel_name, wheel_dir in self._get_candidates(link, canonical_package_name):
|
||||||
|
try:
|
||||||
|
wheel = Wheel(wheel_name)
|
||||||
|
except InvalidWheelFilename:
|
||||||
|
continue
|
||||||
|
if canonicalize_name(wheel.name) != canonical_package_name:
|
||||||
|
logger.debug(
|
||||||
|
"Ignoring cached wheel %s for %s as it "
|
||||||
|
"does not match the expected distribution name %s.",
|
||||||
|
wheel_name,
|
||||||
|
link,
|
||||||
|
package_name,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
if not wheel.supported(supported_tags):
|
||||||
|
# Built for a different python/arch/etc
|
||||||
|
continue
|
||||||
|
candidates.append(
|
||||||
|
(
|
||||||
|
wheel.support_index_min(supported_tags),
|
||||||
|
wheel_name,
|
||||||
|
wheel_dir,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not candidates:
|
||||||
|
return link
|
||||||
|
|
||||||
|
_, wheel_name, wheel_dir = min(candidates)
|
||||||
|
return Link(path_to_url(os.path.join(wheel_dir, wheel_name)))
|
||||||
|
|
||||||
|
|
||||||
|
class EphemWheelCache(SimpleWheelCache):
|
||||||
|
"""A SimpleWheelCache that creates it's own temporary cache directory"""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._temp_dir = TempDirectory(
|
||||||
|
kind=tempdir_kinds.EPHEM_WHEEL_CACHE,
|
||||||
|
globally_managed=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
super().__init__(self._temp_dir.path)
|
||||||
|
|
||||||
|
|
||||||
|
class CacheEntry:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
link: Link,
|
||||||
|
persistent: bool,
|
||||||
|
):
|
||||||
|
self.link = link
|
||||||
|
self.persistent = persistent
|
||||||
|
self.origin: Optional[DirectUrl] = None
|
||||||
|
origin_direct_url_path = Path(self.link.file_path).parent / ORIGIN_JSON_NAME
|
||||||
|
if origin_direct_url_path.exists():
|
||||||
|
try:
|
||||||
|
self.origin = DirectUrl.from_json(
|
||||||
|
origin_direct_url_path.read_text(encoding="utf-8")
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
"Ignoring invalid cache entry origin file %s for %s (%s)",
|
||||||
|
origin_direct_url_path,
|
||||||
|
link.filename,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class WheelCache(Cache):
|
||||||
|
"""Wraps EphemWheelCache and SimpleWheelCache into a single Cache
|
||||||
|
|
||||||
|
This Cache allows for gracefully degradation, using the ephem wheel cache
|
||||||
|
when a certain link is not found in the simple wheel cache first.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, cache_dir: str) -> None:
|
||||||
|
super().__init__(cache_dir)
|
||||||
|
self._wheel_cache = SimpleWheelCache(cache_dir)
|
||||||
|
self._ephem_cache = EphemWheelCache()
|
||||||
|
|
||||||
|
def get_path_for_link(self, link: Link) -> str:
|
||||||
|
return self._wheel_cache.get_path_for_link(link)
|
||||||
|
|
||||||
|
def get_ephem_path_for_link(self, link: Link) -> str:
|
||||||
|
return self._ephem_cache.get_path_for_link(link)
|
||||||
|
|
||||||
|
def get(
|
||||||
|
self,
|
||||||
|
link: Link,
|
||||||
|
package_name: Optional[str],
|
||||||
|
supported_tags: List[Tag],
|
||||||
|
) -> Link:
|
||||||
|
cache_entry = self.get_cache_entry(link, package_name, supported_tags)
|
||||||
|
if cache_entry is None:
|
||||||
|
return link
|
||||||
|
return cache_entry.link
|
||||||
|
|
||||||
|
def get_cache_entry(
|
||||||
|
self,
|
||||||
|
link: Link,
|
||||||
|
package_name: Optional[str],
|
||||||
|
supported_tags: List[Tag],
|
||||||
|
) -> Optional[CacheEntry]:
|
||||||
|
"""Returns a CacheEntry with a link to a cached item if it exists or
|
||||||
|
None. The cache entry indicates if the item was found in the persistent
|
||||||
|
or ephemeral cache.
|
||||||
|
"""
|
||||||
|
retval = self._wheel_cache.get(
|
||||||
|
link=link,
|
||||||
|
package_name=package_name,
|
||||||
|
supported_tags=supported_tags,
|
||||||
|
)
|
||||||
|
if retval is not link:
|
||||||
|
return CacheEntry(retval, persistent=True)
|
||||||
|
|
||||||
|
retval = self._ephem_cache.get(
|
||||||
|
link=link,
|
||||||
|
package_name=package_name,
|
||||||
|
supported_tags=supported_tags,
|
||||||
|
)
|
||||||
|
if retval is not link:
|
||||||
|
return CacheEntry(retval, persistent=False)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def record_download_origin(cache_dir: str, download_info: DirectUrl) -> None:
|
||||||
|
origin_path = Path(cache_dir) / ORIGIN_JSON_NAME
|
||||||
|
if origin_path.exists():
|
||||||
|
try:
|
||||||
|
origin = DirectUrl.from_json(origin_path.read_text(encoding="utf-8"))
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
"Could not read origin file %s in cache entry (%s). "
|
||||||
|
"Will attempt to overwrite it.",
|
||||||
|
origin_path,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# TODO: use DirectUrl.equivalent when
|
||||||
|
# https://github.com/pypa/pip/pull/10564 is merged.
|
||||||
|
if origin.url != download_info.url:
|
||||||
|
logger.warning(
|
||||||
|
"Origin URL %s in cache entry %s does not match download URL "
|
||||||
|
"%s. This is likely a pip bug or a cache corruption issue. "
|
||||||
|
"Will overwrite it with the new value.",
|
||||||
|
origin.url,
|
||||||
|
cache_dir,
|
||||||
|
download_info.url,
|
||||||
|
)
|
||||||
|
origin_path.write_text(download_info.to_json(), encoding="utf-8")
|
4
venv/Lib/site-packages/pip/_internal/cli/__init__.py
Normal file
4
venv/Lib/site-packages/pip/_internal/cli/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
"""Subpackage containing all of pip's command line interface related code
|
||||||
|
"""
|
||||||
|
|
||||||
|
# This file intentionally does not import submodules
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
venv/Lib/site-packages/pip/_internal/cli/__pycache__/command_context.cpython-310.pyc
Normal file
BIN
venv/Lib/site-packages/pip/_internal/cli/__pycache__/command_context.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user