Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add upgrade command #882

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change

## [Unreleased]

### Added

- New and improved css style options. See PreTeXt documentation.
- `pretext upgrade` command will run `pip install --upgrade pretext` using the same python you are running pretext from, for smoother upgrades.

### Changed

- `pretext view` now reuses the current local server correctly, and starts different local servers for different projects. This allows you to correctly view multiple projects at the same time.
Expand Down
2 changes: 1 addition & 1 deletion pretext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

VERSION = get_version("pretext", Path(__file__).parent.parent)

CORE_COMMIT = "e532f6357afb849df2b54d10aef504ac88e4b271"
CORE_COMMIT = "2fb780c35d73aa2461219a6413b596788b1c5f23"


def activate() -> None:
Expand Down
24 changes: 20 additions & 4 deletions pretext/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from . import (
utils,
resources,
core,
constants,
plastex,
server,
Expand Down Expand Up @@ -153,7 +152,7 @@ def main(ctx: click.Context, targets: bool) -> None:
latest_version = utils.latest_version()
if latest_version and latest_version != VERSION:
log.info(
f"Using PreTeXt-CLI version {VERSION}. The latest stable version available is {latest_version}. Run `pip install pretext --upgrade` to update.\n"
f"Using PreTeXt-CLI version {VERSION}. The latest stable version available is {latest_version}. Run `pretext upgrade` to update.\n"
)
else:
log.info(
Expand Down Expand Up @@ -220,9 +219,12 @@ def support() -> None:
log.info(f"PreTeXt-CLI version: {VERSION}")
log.info(f" PyPI link: https://pypi.org/project/pretextbook/{VERSION}/")
log.info(f"PreTeXt core resources commit: {CORE_COMMIT}")
log.info(f"Runestone Services version: {core.get_runestone_services_version()}")
# Temporarily removing; this is handled by core differently now.
# log.info(f"Runestone Services version: {core.get_runestone_services_version()}")
log.info(f"OS: {platform.platform()}")
log.info(f"Python version: {platform.python_version()}")
log.info(
f"Python version: {platform.python_version()}, running from {sys.executable}"
)
log.info(f"Current working directory: {Path().resolve()}")
if utils.project_path() is not None:
log.info(f"PreTeXt project path: {utils.project_path()}")
Expand All @@ -245,6 +247,20 @@ def support() -> None:
log.info("No project.ptx found.")


# pretext upgrade
@main.command(
short_help="Upgrade PreTeXt-CLI to the latest version using pip.",
context_settings=CONTEXT_SETTINGS,
)
def upgrade() -> None:
"""
Upgrade PreTeXt-CLI to the latest version using pip.
"""
log.info("Upgrading PreTeXt-CLI...")
subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "pretext"])
log.info("Upgrade complete.")


# pretext devscript
@main.command(
short_help="Alias for the developer pretext/pretext script.",
Expand Down
Loading