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
+2 -3
View File
@@ -30,7 +30,7 @@ import zipfile
from pathlib import Path
from utils.common import (
ROOT_DIR, SETUP_DIR, copySourceCode, extractVersion, readFile,
ROOT_DIR, SETUP_DIR, copySourceCode, extractReqs, extractVersion, readFile,
removeRedundantQt, systemCall, writeFile
)
@@ -45,7 +45,6 @@ def prepareCode(outDir: Path) -> None:
files = [
ROOT_DIR / "CREDITS.md",
ROOT_DIR / "LICENSE.md",
ROOT_DIR / "requirements.txt",
SETUP_DIR / "iss_license.txt",
SETUP_DIR / "windows" / "novelWriter.ico",
SETUP_DIR / "windows" / "novelWriter.exe",
@@ -85,7 +84,7 @@ def installRequirements(libDir: Path) -> None:
"""Install dependencies."""
print("Install dependencies ...")
systemCall([
sys.executable, "-m", "pip", "install", "-r", "requirements.txt", "--target", libDir
sys.executable, "-m", "pip", "install", *extractReqs(["app"]), "--target", libDir
])
print("Done")
print("")
+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.