Remove dependencies on requirements files and generate when needed
This commit is contained in:
@@ -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("")
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user