287 lines
7.2 KiB
TOML
287 lines
7.2 KiB
TOML
# Advanced Python Project Configuration
|
|
# Full-featured configuration with custom indexes, workspace, and advanced settings
|
|
|
|
[project]
|
|
name = "advanced-project"
|
|
version = "1.0.0"
|
|
description = "Advanced Python project with custom configuration"
|
|
readme = "README.md"
|
|
requires-python = ">=3.11"
|
|
authors = [{name = "Your Name", email = "your.email@example.com"}]
|
|
license = {text = "MIT"}
|
|
|
|
dependencies = [
|
|
"fastapi>=0.115.0",
|
|
"torch", # Will be sourced from custom index
|
|
"pydantic>=2.5.0",
|
|
]
|
|
|
|
# Development dependencies using PEP 735 dependency groups
|
|
[dependency-groups]
|
|
dev = [
|
|
"pytest>=8.4.2",
|
|
"pytest-cov>=6.0.0",
|
|
"pytest-mock>=3.15.1",
|
|
"ruff>=0.13.3",
|
|
"pyright>=1.1.406",
|
|
"mypy>=1.18.2",
|
|
"pre-commit>=4.3.0",
|
|
]
|
|
test = [
|
|
"pytest-cov>=6.0.0",
|
|
"pytest-asyncio>=0.21.0",
|
|
"hypothesis>=6.0.0",
|
|
]
|
|
docs = [
|
|
"sphinx>=7.0",
|
|
"sphinx-rtd-theme>=1.3.0",
|
|
]
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.uv]
|
|
# Core settings
|
|
managed = true
|
|
package = true
|
|
default-groups = ["dev"]
|
|
|
|
# Resolution strategy
|
|
resolution = "highest" # highest/lowest/lowest-direct
|
|
fork-strategy = "requires-python"
|
|
index-strategy = "first-index"
|
|
|
|
# Environment restrictions (only resolve for these platforms)
|
|
environments = [
|
|
"sys_platform == 'darwin'",
|
|
"sys_platform == 'linux'",
|
|
]
|
|
|
|
# Require support for specific platforms
|
|
required-environments = [
|
|
"sys_platform == 'linux' and platform_machine == 'x86_64'",
|
|
]
|
|
|
|
# Dependency version management
|
|
constraint-dependencies = [
|
|
"grpcio<1.65", # Constraint: don't allow grpcio >= 1.65
|
|
]
|
|
override-dependencies = [
|
|
"werkzeug==2.3.0", # Override: always use this exact version
|
|
]
|
|
build-constraint-dependencies = [
|
|
"setuptools==60.0.0", # Constraint for build dependencies
|
|
]
|
|
|
|
# Build configuration
|
|
compile-bytecode = true
|
|
no-build-isolation-package = ["flash-attn", "deepspeed"]
|
|
|
|
# Cache configuration
|
|
cache-dir = "./.uv_cache"
|
|
cache-keys = [
|
|
{ file = "pyproject.toml" },
|
|
{ file = "requirements.txt" },
|
|
{ git = { commit = true } },
|
|
]
|
|
|
|
# Network configuration
|
|
concurrent-downloads = 20
|
|
concurrent-builds = 8
|
|
|
|
# Python management
|
|
python-preference = "managed"
|
|
python-downloads = "automatic"
|
|
|
|
# Security
|
|
keyring-provider = "subprocess"
|
|
allow-insecure-host = []
|
|
|
|
# Preview features
|
|
preview = false
|
|
|
|
# Extra build dependencies (for packages without proper metadata)
|
|
[tool.uv.extra-build-dependencies]
|
|
flash-attn = ["torch", "setuptools", "ninja"]
|
|
deepspeed = [{ requirement = "torch", match-runtime = true }]
|
|
|
|
# Build environment variables
|
|
[tool.uv.extra-build-variables]
|
|
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
|
|
opencv-python = { CMAKE_ARGS = "-DWITH_CUDA=ON" }
|
|
|
|
# Custom package sources
|
|
[tool.uv.sources]
|
|
# PyTorch from custom index
|
|
torch = { index = "pytorch-cu121" }
|
|
|
|
# Internal workspace dependency
|
|
# internal-lib = { workspace = true }
|
|
|
|
# Git source
|
|
# httpx = { git = "https://github.com/encode/httpx", tag = "0.27.0" }
|
|
|
|
# Local path (development)
|
|
# local-pkg = { path = "../local-pkg", editable = true }
|
|
|
|
# Conditional sources (platform-specific)
|
|
# torch = [
|
|
# { index = "pytorch-cu118", marker = "sys_platform == 'darwin'" },
|
|
# { index = "pytorch-cu121", marker = "sys_platform == 'linux'" },
|
|
# ]
|
|
|
|
# Custom package indexes
|
|
[[tool.uv.index]]
|
|
name = "pytorch-cu121"
|
|
url = "https://download.pytorch.org/whl/cu121"
|
|
explicit = true # Only use for explicitly pinned packages
|
|
default = false # Don't replace PyPI as default
|
|
|
|
[[tool.uv.index]]
|
|
name = "private-registry"
|
|
url = "https://packages.example.com/simple"
|
|
explicit = true
|
|
authenticate = "always" # Always send authentication
|
|
|
|
# Workspace configuration (for monorepos)
|
|
[tool.uv.workspace]
|
|
members = ["packages/*", "apps/*"]
|
|
exclude = ["packages/deprecated"]
|
|
|
|
# Conflict resolution (mutually exclusive extras)
|
|
[[tool.uv.conflicts]]
|
|
extra = ["cuda", "rocm"]
|
|
|
|
[[tool.uv.conflicts]]
|
|
group = ["prod", "dev"]
|
|
|
|
# pip-specific settings (only for uv pip commands)
|
|
[tool.uv.pip]
|
|
compile-bytecode = true
|
|
strict = true
|
|
generate-hashes = false
|
|
annotation-style = "line"
|
|
extra = ["dev"]
|
|
universal = false
|
|
no-strip-markers = false
|
|
|
|
# Ruff configuration
|
|
[tool.ruff]
|
|
target-version = "py311"
|
|
line-length = 120
|
|
fix = true
|
|
preview = true
|
|
|
|
[tool.ruff.format]
|
|
docstring-code-format = true
|
|
quote-style = "double"
|
|
line-ending = "lf"
|
|
skip-magic-trailing-comma = true
|
|
preview = true
|
|
|
|
[tool.ruff.lint]
|
|
extend-select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # pyflakes
|
|
"I", # isort
|
|
"UP", # pyupgrade
|
|
"YTT", # flake8-2020
|
|
"S", # flake8-bandit
|
|
"B", # flake8-bugbear
|
|
"A", # flake8-builtins
|
|
"C4", # flake8-comprehensions
|
|
"T10", # flake8-debugger
|
|
"SIM", # flake8-simplify
|
|
"C90", # mccabe
|
|
"PGH", # pygrep-hooks
|
|
"RUF", # ruff-specific
|
|
"TRY", # tryceratops
|
|
"DOC", # pydocstyle
|
|
"D", # pydocstyle
|
|
]
|
|
|
|
ignore = [
|
|
"COM812", # Missing trailing comma
|
|
"COM819", # Missing trailing comma
|
|
"D107", # Missing docstring in __init__
|
|
"D415", # First line should end with a period
|
|
"E111", # Indentation is not a multiple of four
|
|
"E117", # Over-indented for visual indent
|
|
"E203", # whitespace before ':'
|
|
"E402", # Module level import not at top
|
|
"E501", # Line length exceeds maximum limit
|
|
"ISC001", # isort configuration is missing
|
|
"ISC002", # isort configuration is missing
|
|
"Q000", # Remove bad quotes
|
|
"Q001", # Remove bad quotes
|
|
"Q002", # Remove bad quotes
|
|
"Q003", # Remove bad quotes
|
|
"TRY003", # Exception message should not be too long
|
|
"S404", # module is possibly insecure
|
|
"S603", # subprocess-without-shell-equals-true
|
|
"S606", # start-process-with-no-shell
|
|
"DOC501", # Missing raises section
|
|
]
|
|
|
|
unfixable = ["F401", "S404", "S603", "S606", "DOC501"]
|
|
|
|
[tool.ruff.lint.pycodestyle]
|
|
max-line-length = 120
|
|
|
|
[tool.ruff.lint.isort]
|
|
combine-as-imports = true
|
|
split-on-trailing-comma = false
|
|
force-single-line = false
|
|
force-wrap-aliases = false
|
|
|
|
[tool.ruff.lint.flake8-quotes]
|
|
docstring-quotes = "double"
|
|
|
|
[tool.ruff.lint.pydocstyle]
|
|
convention = "google"
|
|
|
|
[tool.ruff.lint.mccabe]
|
|
max-complexity = 10
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
"**/tests/*" = ["S101", "S603", "S607", "D102", "D200", "D100"]
|
|
"**/test_*.py" = ["S101", "S603", "S607", "D102", "D200", "D100"]
|
|
|
|
# Mypy configuration
|
|
[tool.mypy]
|
|
python_version = "3.11"
|
|
strict = true
|
|
extra_checks = true
|
|
warn_unused_configs = true
|
|
warn_redundant_casts = true
|
|
warn_unused_ignores = true
|
|
ignore_missing_imports = true
|
|
show_error_codes = true
|
|
pretty = true
|
|
disable_error_code = "call-arg,arg-type"
|
|
|
|
# Pytest configuration
|
|
[tool.pytest.ini_options]
|
|
addopts = [
|
|
"--cov=advanced_project",
|
|
"--cov-report=term-missing",
|
|
"-v",
|
|
]
|
|
testpaths = ["tests"]
|
|
python_files = ["test_*.py"]
|
|
python_classes = ["Test*"]
|
|
python_functions = ["test_*"]
|
|
markers = [
|
|
"slow: tests that take significant time to run",
|
|
"integration: integration tests",
|
|
]
|
|
|
|
[tool.coverage.run]
|
|
omit = ["*/tests/*"]
|
|
|
|
[tool.coverage.report]
|
|
show_missing = true
|
|
fail_under = 70
|