Skip to content

Commit c4801cb

Browse files
authored
Prefig upgrade (#1034)
1 parent 3f32644 commit c4801cb

4 files changed

Lines changed: 40 additions & 79 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
1111

1212
### Changed
1313

14-
- Template devcontainer will now use versioned docker image
14+
- Template devcontainer will now use versioned docker image.
15+
- The `pretext upgrade` command will include prefigure and pelican if they are already installed.
1516

1617
### Fixed
1718

poetry.lock

Lines changed: 16 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pretext/cli.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib
12
import logging
23
import logging.handlers
34
import sys
@@ -17,7 +18,6 @@
1718
from typing import Any, Callable, List, Literal, Optional
1819
from functools import update_wrapper
1920

20-
2121
from . import (
2222
utils,
2323
resources,
@@ -195,10 +195,26 @@ def upgrade() -> None:
195195
"""
196196
Upgrade PreTeXt-CLI to the latest version using pip.
197197
"""
198-
log.info("Upgrading PreTeXt-CLI...")
199-
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "pretext"])
198+
extras = []
199+
if importlib.util.find_spec("prefig") is not None:
200+
log.debug(
201+
"The 'prefig' package is installed; will attempt to upgrade it as well."
202+
)
203+
extras.append("prefigure")
204+
if importlib.util.find_spec("pelican") is not None:
205+
log.debug(
206+
"The 'pelican' package is installed; will attempt to upgrade it as well."
207+
)
208+
extras.append("homepage")
209+
if len(extras) > 0:
210+
log.info(f"Upgrading PreTeXt (with extras: {', '.join(extras)})")
211+
pretext_cmd = "pretext[" + ",".join(extras) + "]"
212+
else:
213+
log.info("Upgrading PreTeXt.")
214+
pretext_cmd = "pretext"
215+
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", pretext_cmd])
200216
log.info(
201-
"Upgrade complete. Individual projects can be updated to align with the latest version of the CLI with `pretext update` from their project folder."
217+
"Upgrade complete. Individual projects can be updated to align with the latest version of the CLI by running `pretext update` from their project folder."
202218
)
203219

204220

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ click-log = "^0.4"
3838
ghp-import = "^2"
3939
single-version = "^1"
4040
playwright = "^1"
41-
pydantic-xml = ">=2"
41+
pydantic-xml = "2.14.3"
4242
qrcode = "^7"
4343
psutil = "^7"
4444
plastex = "^3"
4545
jinja2 = "^3"
4646
coloraide = "^4"
4747
pelican = { extras = ["markdown"], version = "^4.10", optional = true }
48-
prefig = { extras = ["text"], version = "^0.3.2", optional = true }
48+
prefig = { extras = ["text"], version = "^0.3.6", optional = true }
4949

5050

5151
# Development dependencies

0 commit comments

Comments
 (0)