|
| 1 | +import importlib |
1 | 2 | import logging |
2 | 3 | import logging.handlers |
3 | 4 | import sys |
|
17 | 18 | from typing import Any, Callable, List, Literal, Optional |
18 | 19 | from functools import update_wrapper |
19 | 20 |
|
20 | | - |
21 | 21 | from . import ( |
22 | 22 | utils, |
23 | 23 | resources, |
@@ -195,10 +195,26 @@ def upgrade() -> None: |
195 | 195 | """ |
196 | 196 | Upgrade PreTeXt-CLI to the latest version using pip. |
197 | 197 | """ |
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]) |
200 | 216 | 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." |
202 | 218 | ) |
203 | 219 |
|
204 | 220 |
|
|
0 commit comments