Skip to content
Merged
5 changes: 2 additions & 3 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sys

import click
import cloup

from . import __version__, cli_ctx_settings, console
Expand Down Expand Up @@ -35,15 +34,15 @@ def exit_early(ctx, param, value):
"is specified. Run 'manim render --help' if you would like to know what the "
f"'-ql' or '-p' flags do, for example.\n\n{EPILOG}",
)
@click.option(
@cloup.option(
"--version",
is_flag=True,
help="Show version and exit.",
callback=exit_early,
is_eager=True,
expose_value=False,
)
@click.pass_context
@cloup.pass_context
def main(ctx):
"""The entry point for manim."""
pass
Expand Down
14 changes: 6 additions & 8 deletions manim/cli/cfg/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
"""
from __future__ import annotations

import os
from ast import literal_eval
from pathlib import Path

import click
import cloup
from rich.errors import StyleSyntaxError
from rich.style import Style
Expand Down Expand Up @@ -123,21 +121,21 @@ def replace_keys(default: dict) -> dict:
epilog=EPILOG,
help="Manages Manim configuration files.",
)
@click.pass_context
@cloup.pass_context
def cfg(ctx):
"""Responsible for the cfg subcommand."""
pass


@cfg.command(context_settings=cli_ctx_settings, no_args_is_help=True)
@click.option(
@cloup.option(
"-l",
"--level",
type=click.Choice(["user", "cwd"], case_sensitive=False),
type=cloup.Choice(["user", "cwd"], case_sensitive=False),
default="cwd",
help="Specify if this config is for user or the working directory.",
)
@click.option("-o", "--open", "openfile", is_flag=True)
@cloup.option("-o", "--open", "openfile", is_flag=True)
def write(level: str = None, openfile: bool = False) -> None:
config_paths = config_file_paths()
console.print(
Expand Down Expand Up @@ -258,8 +256,8 @@ def show():


@cfg.command(context_settings=cli_ctx_settings)
@click.option("-d", "--directory", default=Path.cwd())
@click.pass_context
@cloup.option("-d", "--directory", default=Path.cwd())
@cloup.pass_context
def export(ctx, directory):
directory_path = Path(directory)
if directory_path.absolute == Path.cwd().absolute:
Expand Down
17 changes: 12 additions & 5 deletions manim/cli/default_group.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""DefaultGroup allows a subcommand to act as the main command
"""``DefaultGroup`` allows a subcommand to act as the main command.

In particular, this class is what allows ``manim`` to act as ``manim render``.

.. note::
This is a vendored version of https://github.com/click-contrib/click-default-group/
under the BSD 3-Clause "New" or "Revised" License.

This library isn't used as a dependency as we need to inherit from ``cloup.Group`` instead
of ``click.Group``.
"""
import cloup
import warnings

from .. import logger
import cloup

__all__ = ["DefaultGroup"]

Expand Down Expand Up @@ -54,8 +61,8 @@ def command(self, *args, **kwargs):
decorator = super().command(*args, **kwargs)
if not default:
return decorator
logger.log(
"Use default param of DefaultGroup or " "set_default_command() instead",
warnings.warn(
"Use default param of DefaultGroup or set_default_command() instead",
DeprecationWarning,
)

Expand Down
2 changes: 1 addition & 1 deletion manim/cli/init/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def select_resolution():
resolution_options.pop()
choice = click.prompt(
"\nSelect resolution:\n",
type=click.Choice([f"{i[0]}p" for i in resolution_options]),
type=cloup.Choice([f"{i[0]}p" for i in resolution_options]),
show_default=False,
default="480p",
)
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/new/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def select_resolution():
resolution_options.pop()
choice = click.prompt(
"\nSelect resolution:\n",
type=click.Choice([f"{i[0]}p" for i in resolution_options]),
type=cloup.Choice([f"{i[0]}p" for i in resolution_options]),
show_default=False,
default="480p",
)
Expand Down
5 changes: 2 additions & 3 deletions manim/cli/render/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys
from pathlib import Path

import click
import cloup
import requests

Expand All @@ -30,8 +29,8 @@
no_args_is_help=True,
epilog=EPILOG,
)
@click.argument("file", type=Path, required=True)
@click.argument("scene_names", required=False, nargs=-1)
@cloup.argument("file", type=Path, required=True)
@cloup.argument("scene_names", required=False, nargs=-1)
@global_options
@output_options
@render_options # type: ignore
Expand Down
5 changes: 2 additions & 3 deletions manim/cli/render/ease_of_access_options.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import annotations

import click
from cloup import option, option_group
from cloup import Choice, option, option_group

ease_of_access_options = option_group(
"Ease of access options",
option(
"--progress_bar",
default=None,
show_default=False,
type=click.Choice(
type=Choice(
["display", "leave", "none"],
case_sensitive=False,
),
Expand Down
5 changes: 2 additions & 3 deletions manim/cli/render/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import re
from typing import TYPE_CHECKING

import click
from cloup import option, option_group
from cloup import Choice, option, option_group

from ... import logger

Expand Down Expand Up @@ -53,7 +52,7 @@ def validate_gui_location(ctx, param, value):
option(
"-v",
"--verbosity",
type=click.Choice(
type=Choice(
["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
case_sensitive=False,
),
Expand Down
9 changes: 4 additions & 5 deletions manim/cli/render/output_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import click
from cloup import option, option_group
from cloup import IntRange, Path, option, option_group

output_options = option_group(
"Output options",
Expand All @@ -15,7 +14,7 @@
option(
"-0",
"--zero_pad",
type=click.IntRange(0, 9),
type=IntRange(0, 9),
default=None,
help="Zero padding for PNG file names.",
),
Expand All @@ -27,13 +26,13 @@
),
option(
"--media_dir",
type=click.Path(),
type=Path(),
default=None,
help="Path to store rendered videos and latex.",
),
option(
"--log_dir",
type=click.Path(),
type=Path(),
help="Path to store render logs.",
default=None,
),
Expand Down
9 changes: 4 additions & 5 deletions manim/cli/render/render_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import re

import click
from cloup import option, option_group
from cloup import Choice, option, option_group

from manim.constants import QUALITIES, RendererType

Expand Down Expand Up @@ -55,15 +54,15 @@ def validate_resolution(ctx, param, value):
),
option(
"--format",
type=click.Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False),
type=Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False),
default=None,
),
option("-s", "--save_last_frame", is_flag=True, default=None),
option(
"-q",
"--quality",
default=None,
type=click.Choice(
type=Choice(
list(reversed([q["flag"] for q in QUALITIES.values() if q["flag"]])), # type: ignore
case_sensitive=False,
),
Expand Down Expand Up @@ -95,7 +94,7 @@ def validate_resolution(ctx, param, value):
),
option(
"--renderer",
type=click.Choice(
type=Choice(
[renderer_type.value for renderer_type in RendererType],
case_sensitive=False,
),
Expand Down
27 changes: 13 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
click = ">=7.2,<=9.0"
click-default-group = "^1.2.2"
numpy = "^1.19"
Pillow = ">=9.1,<10.0"
scipy = "^1.7.3"
tqdm = "^4.62.3"
pydub = "^0.25.1"
click = ">=8.0"
cloup = ">=2.0.0"
numpy = ">=1.22"
Pillow = ">=9.1"
scipy = ">=1.6.0"
tqdm = ">=4.0.0"
pydub = ">=0.20.0"
rich = ">=6.0,!=12.0.0"
pycairo = "^1.21"
manimpango = "^0.4.0.post0"
networkx = "^2.5"
decorator = "^5.0.7"
pycairo = ">=1.13"
manimpango = "<=1.0.0" # Complete API change in 1.0.0
networkx = ">=2.6"
decorator = ">=4.3.2"
importlib-metadata = { version = "^4.10.0", python = "<3.8" }
watchdog = "^2.1.6"
watchdog = ">=2.0.0"
jupyterlab = { version = "^3.0", optional = true }
notebook = { version = "^6.4", optional = true }
moderngl = "^5.6.3"
moderngl-window = "^2.3.0"
mapbox-earcut = "^1.0.0"
cloup = "^0.13.0"
requests = "^2.26.0"
dearpygui = { version = "^1.3.1", optional = true }
skia-pathops = "^0.7.0"
Expand Down Expand Up @@ -136,5 +135,5 @@ exclude_lines = ["pragma: no cover"]
"manimce" = "manim.__main__:main"

[build-system]
requires = ["setuptools","poetry-core>=1.0.0"]
requires = ["setuptools", "poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
11 changes: 5 additions & 6 deletions scripts/dev_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from pathlib import Path
from textwrap import dedent, indent

import click
import cloup
from git import Repo
from github import Github
Expand Down Expand Up @@ -192,16 +191,16 @@ def get_summary(body):
context_settings=CONTEXT_SETTINGS,
epilog=EPILOG,
)
@click.argument("token")
@click.argument("prior")
@click.argument("tag")
@click.argument(
@cloup.argument("token")
@cloup.argument("prior")
@cloup.argument("tag")
@cloup.argument(
"additional",
nargs=-1,
required=False,
type=int,
)
@click.option(
@cloup.option(
"-o",
"--outfile",
type=str,
Expand Down