feat(cli): check for newer Manim Slides version (#85)

* chore(deps): drop support for Python 3.7

In link with the recent release of [Manim v0.17.0](https://github.com/ManimCommunity/manim/releases/tag/v0.17.0), Manim Slides drops support for Python 3.7.

* feat(cli): check for newer Manim Slides version

Uses same logic as manim to check for a new version

* fix(lib): reset correct version

* fix(ci): add type stubs for requests
This commit is contained in:
Jérome Eertmans
2022-12-03 14:51:00 +01:00
committed by GitHub
parent 97e7bf8cb0
commit bf64962c46
5 changed files with 52 additions and 17 deletions

View File

@ -17,23 +17,17 @@ jobs:
matrix:
manim: [manim, manimgl]
os: [macos-latest, ubuntu-latest, windows-latest]
pyversion: ['3.7', '3.8', '3.9', '3.10', '3.11']
pyversion: ['3.8', '3.9', '3.10', '3.11']
exclude:
# excludes manimgl on Windows because if throws errors
# related to OpenGL, which seems hard to fix:
# Your graphics drivers do not support OpenGL 2.0.
- os: windows-latest
manim: manimgl
# manimgl actually requires Python >= 3.8, see:
# https://github.com/3b1b/manim/issues/1808
- manim: manimgl
pyversion: '3.7'
# manimgl seems to have problems with Python 3.11
- manim: manimgl
pyversion: '3.11'
# We only test Python 3.11 on Windows and MacOS
- os: windows-latest
pyversion: '3.7'
- os: windows-latest
pyversion: '3.8'
- os: windows-latest
@ -41,8 +35,6 @@ jobs:
- os: windows-latest
pyversion: '3.10'
manim: manim
- os: macos-latest
pyversion: '3.7'
- os: macos-latest
pyversion: '3.8'
- os: macos-latest

View File

@ -29,7 +29,7 @@ repos:
rev: 'v0.991'
hooks:
- id: mypy
additional_dependencies: [types-setuptools]
additional_dependencies: [types-requests, types-setuptools]
args:
- --install-types
- --non-interactive

View File

@ -1,22 +1,66 @@
import json
import click
import requests
from click_default_group import DefaultGroup
from . import __version__
from .convert import convert
from .manim import logger
from .present import list_scenes, present
from .wizard import init, wizard
@click.group(cls=DefaultGroup, default="present", default_if_no_args=True)
@click.option(
"--notify-outdated-version/--silent",
" /-S",
is_flag=True,
default=True,
help="Check if a new version of Manim Slides is available.",
)
@click.version_option(__version__, "-v", "--version")
@click.help_option("-h", "--help")
def cli() -> None:
def cli(notify_outdated_version: bool) -> None:
"""
Manim Slides command-line utilities.
If no command is specified, defaults to `present`.
"""
pass
# Code below is mostly a copy from:
# https://github.com/ManimCommunity/manim/blob/main/manim/cli/render/commands.py
if notify_outdated_version:
manim_info_url = "https://pypi.org/pypi/manim-slides/json"
warn_prompt = "Cannot check if latest release of Manim Slides is installed"
try:
req_info: requests.models.Response = requests.get(
manim_info_url, timeout=10
)
req_info.raise_for_status()
stable = req_info.json()["info"]["version"]
if stable != __version__:
click.echo(
"You are using Manim Slides version "
+ click.style(f"v{__version__}", fg="red")
+ ", but version "
+ click.style(f"v{stable}", fg="green")
+ " is available."
)
click.echo(
"You should consider upgrading via "
+ click.style("pip install -U manim-slides", fg="yellow")
)
except requests.exceptions.HTTPError:
logger.debug(f"HTTP Error: {warn_prompt}")
except requests.exceptions.ConnectionError:
logger.debug(f"Connection Error: {warn_prompt}")
except requests.exceptions.Timeout:
logger.debug(f"Timed Out: {warn_prompt}")
except json.JSONDecodeError:
logger.debug(warn_prompt)
logger.debug(f"Error decoding JSON from {manim_info_url}")
except Exception:
logger.debug(f"Something went wrong: {warn_prompt}")
cli.add_command(convert)

View File

@ -9,7 +9,6 @@ import click
import cv2
import numpy as np
from pydantic import ValidationError
from PySide6 import QtGui
from PySide6.QtCore import Qt, QThread, Signal, Slot
from PySide6.QtGui import QCloseEvent, QIcon, QImage, QKeyEvent, QPixmap, QResizeEvent
from PySide6.QtWidgets import QApplication, QGridLayout, QLabel, QWidget

View File

@ -8,9 +8,10 @@ description = "Tool for live presentations using manim"
authors = [
{ name = "Jérome Eertmans", email = "jeertmans@icloud.com" }
]
version = "4.6.0"
license = {file = "LICENSE.md"}
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
keywords = ["manim", "slides", "plugin", "manimgl"]
@ -32,14 +33,13 @@ dependencies = [
"click>=8.0",
"click-default-group>=1.2",
"numpy>=1.19.3",
"opencv-python>=4.6",
"pydantic>=1.9.1",
"pyside6>=6",
"opencv-python>=4.6",
"requests>=2.26.0",
"tqdm>=4.62.3",
]
dynamic = ["version"]
[tool.setuptools]
packages = ["manim_slides"]