Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pretext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import logging
import logging.handlers
import psutil
import re
import typing as t
from . import types as pt # PreTeXt types
from lxml import etree as ET # noqa: N812
Expand Down Expand Up @@ -133,9 +134,10 @@ def requirements_version(dirpath: Optional[Path] = None) -> Optional[str]:
return None
try:
with open(pp / "requirements.txt", "r") as f:
REGEX = r"\s*pretext(book)?(\[.*\])?\s*==\s*(?P<version>[\d\.]*)\s*"gm
for line in f.readlines():
if ("pretext ==" in line) or ("pretextbook ==" in line):
return line.split("==")[1].strip()
if re.match(REGEX, line):
return re.match(REGEX, line).group("version")
except Exception as e:
log.debug("Could not read `requirements.txt`:")
log.debug(e)
Expand Down
Loading