Remove dependencies on requirements files and generate when needed

This commit is contained in:
Veronica Berglyd Olsen
2025-10-22 21:11:20 +02:00
parent 0b79bcd4b4
commit 06cb128876
7 changed files with 93 additions and 50 deletions
+14
View File
@@ -26,10 +26,24 @@ import sys
from pathlib import Path
import tomllib
ROOT_DIR = Path(__file__).parent.parent
SETUP_DIR = ROOT_DIR / "setup"
def extractReqs(groups: list[str]) -> list[str]:
"""Generate requirements.txt file from pyproject.toml."""
data = tomllib.loads((ROOT_DIR / "pyproject.toml").read_text(encoding="utf-8"))
reqs = []
if "app" in groups or "all" in groups:
reqs += data["project"]["dependencies"]
for group in data["dependency-groups"]:
if group in groups or "all" in groups:
reqs += [d for d in data["dependency-groups"][group] if isinstance(d, str)]
return reqs
def extractVersion(beQuiet: bool = False) -> tuple[str, str, str]:
"""Extract the novelWriter version number without having to import
anything else from the main package.