feat: implement comprehensive configuration management system with multi-mirror support

- Add ServerSettings class with pydantic-settings for type-safe configuration
- Support multiple PyPI mirror sources with priority-based fallback mechanism
- Implement RepositoryConfig and RepositoryManager for multi-repository support
- Add environment variable support for all configuration options
- Include private repository authentication configuration
- Add advanced dependency analysis settings (max depth, concurrency, security)
- Provide secure credential management with sensitive data masking
- Update documentation and configuration examples
- Add comprehensive test suite with 23 test cases covering all features
- Include demo script showcasing multi-mirror configuration capabilities

Configuration features:
- Primary, additional, and fallback index URLs
- Automatic duplicate URL removal with priority preservation
- Runtime configuration reloading
- Integration with repository manager for seamless multi-source queries

Signed-off-by: longhao <hal.long@outlook.com>
This commit is contained in:
longhao 2025-05-27 17:36:25 +08:00 committed by Hal
parent f27493d8d2
commit a0c507c3ff
20 changed files with 1276 additions and 165 deletions

View file

@ -12,11 +12,14 @@ def pytest(session: nox.Session) -> None:
session.install(".")
session.install("pytest", "pytest-cov", "pytest-mock", "pytest-asyncio")
test_root = os.path.join(THIS_ROOT, "tests")
session.run("pytest", f"--cov={PACKAGE_NAME}",
"--cov-report=xml:coverage.xml",
"--cov-report=term-missing",
f"--rootdir={test_root}",
env={"PYTHONPATH": THIS_ROOT.as_posix()})
session.run(
"pytest",
f"--cov={PACKAGE_NAME}",
"--cov-report=xml:coverage.xml",
"--cov-report=term-missing",
f"--rootdir={test_root}",
env={"PYTHONPATH": THIS_ROOT.as_posix()},
)
def mypy(session: nox.Session) -> None:

View file

@ -15,4 +15,9 @@ def lint_fix(session: nox.Session) -> None:
session.run("ruff", "check", "--fix")
session.run("isort", ".")
session.run("pre-commit", "run", "--all-files")
session.run("autoflake", "--in-place", "--remove-all-unused-imports", "--remove-unused-variables")
session.run(
"autoflake",
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variables",
)

View file

@ -21,7 +21,9 @@ def build(session: nox.Session) -> None:
def build_exe(session: nox.Session) -> None:
parser = argparse.ArgumentParser(prog="nox -s build-exe --release")
parser.add_argument("--release", action="store_true")
parser.add_argument("--version", default="0.5.0", help="Version to use for the zip file")
parser.add_argument(
"--version", default="0.5.0", help="Version to use for the zip file"
)
parser.add_argument("--test", action="store_true")
args = parser.parse_args(session.posargs)
build_root = THIS_ROOT / "build"
@ -42,11 +44,17 @@ def build_exe(session: nox.Session) -> None:
version = str(args.version)
print(f"make zip to current version: {version}")
os.makedirs(temp_dir, exist_ok=True)
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}-{platform_name}.zip")
zip_file = os.path.join(
temp_dir, f"{PACKAGE_NAME}-{version}-{platform_name}.zip"
)
with zipfile.ZipFile(zip_file, "w") as zip_obj:
for root, _, files in os.walk(platform_dir):
for file in files:
zip_obj.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(platform_dir, ".")))
zip_obj.write(
os.path.join(root, file),
os.path.relpath(
os.path.join(root, file),
os.path.join(platform_dir, "."),
),
)
print(f"Saving to {zip_file}")