Skip to content

Commit 9845998

Browse files
leotrsAathish04
andauthored
Create config subpackage (#376)
* add __all__ variables to all modules * move all the config stuff into a new config/ folder and make it a subpackage by adding a config/__init__.py file. This will make it easier to continue refactoring the config system later * fix: almost reverted a previous PR * fix setup.py * Set log_width to 512 for test_cli Co-authored-by: Aathish Sivasubrahmanian <[email protected]>
1 parent 67a4ee6 commit 9845998

32 files changed

+79
-57
lines changed

manim/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/usr/bin/env python
22

33
# Importing the config module should be the first thing we do, since other
4-
# modules depend on the global config dict for initialization. Note that the
5-
# global config dict is called 'config', just like the module itself. That's
6-
# why we import the module first with a different name, and then the dict.
7-
from . import config as _config
8-
from .config import config, file_writer_config, camera_config, tempconfig
4+
# modules depend on the global config dict for initialization.
5+
from .config import *
96

107
from .constants import *
118

manim/__main__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
import importlib.util
99
import types
1010

11-
from .config import file_writer_config, args
12-
from .utils import cfg_subcmds
11+
from . import constants, logger, console, file_writer_config
12+
from .config.config import args
13+
from .config import cfg_subcmds
1314
from .scene.scene import Scene
14-
from .utils.sounds import play_error_sound
15-
from .utils.sounds import play_finish_sound
15+
from .utils.sounds import play_error_sound, play_finish_sound
1616
from .utils.file_ops import open_file as open_media_file
17-
from . import constants
18-
from .logger import logger, console
1917

2018

2119
def open_file_if_needed(file_writer):

manim/animation/fading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..mobject.types.vectorized_mobject import VMobject
2424
from ..utils.bezier import interpolate
2525
from ..utils.rate_functions import there_and_back
26-
from ..logger import logger
26+
from .. import logger
2727

2828

2929
DEFAULT_FADE_LAG_RATIO = 0

manim/animation/indication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import numpy as np
2020

21+
from .. import config
2122
from ..constants import *
22-
from ..config import config
2323
from ..animation.animation import Animation
2424
from ..animation.movement import Homotopy
2525
from ..animation.composition import AnimationGroup

manim/camera/camera.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
import cairo
1616
import numpy as np
1717

18+
from .. import logger, config, camera_config
1819
from ..constants import *
19-
from ..config import config, camera_config
20-
from ..logger import logger
2120
from ..mobject.types.image_mobject import AbstractImageMobject
2221
from ..mobject.mobject import Mobject
2322
from ..mobject.types.point_cloud_mobject import PMobject

manim/camera/moving_camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
__all__ = ["CameraFrame", "MovingCamera"]
22

33

4+
from .. import config
45
from ..camera.camera import Camera
5-
from ..config import config
66
from ..constants import ORIGIN, WHITE
77
from ..mobject.frame import ScreenRectangle
88
from ..mobject.types.vectorized_mobject import VGroup

manim/camera/three_d_camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import numpy as np
55

6+
from .. import config
67
from ..camera.camera import Camera
78
from ..constants import *
8-
from ..config import config
99
from ..mobject.three_d_utils import get_3d_vmob_end_corner
1010
from ..mobject.three_d_utils import get_3d_vmob_end_corner_unit_normal
1111
from ..mobject.three_d_utils import get_3d_vmob_start_corner

manim/config/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Note that the global config dict is called 'config', just like the module
2+
# itself. That's why we import the module first with a different name
3+
# (_config), and then the dict.
4+
from . import config as _config
5+
from .config import config, tempconfig, file_writer_config, camera_config
6+
from .logger import logger, console
7+
8+
__all__ = ["_config", "config", "tempconfig", "file_writer_config",
9+
"camera_config", "logger", "console"]

manim/utils/cfg_subcmds.py renamed to manim/config/cfg_subcmds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ast import literal_eval
1212

1313
from .config_utils import _run_config, _paths_config_file, finalized_configs_dict
14-
from .file_ops import guarantee_existence, open_file
14+
from ..utils.file_ops import guarantee_existence, open_file
1515

1616
from rich.console import Console
1717
from rich.style import Style

manim/config.py renamed to manim/config/config.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
Process the manim.cfg file and the command line arguments into a single
55
config object.
66
"""
7+
8+
9+
__all__ = ["file_writer_config", "config", "camera_config", "tempconfig"]
10+
11+
712
import os
813
import sys
914
from contextlib import contextmanager
1015

1116
import colour
1217

13-
from . import constants
14-
from .utils.config_utils import _run_config, _init_dirs, _from_command_line
18+
from .. import constants
19+
from .config_utils import _run_config, _init_dirs, _from_command_line
1520

1621
from .logger import logger
17-
from .utils.tex import TexTemplate, TexTemplateFromFile
18-
19-
__all__ = ["file_writer_config", "config", "camera_config", "tempconfig"]
22+
from ..utils.tex import TexTemplate, TexTemplateFromFile
2023

2124

2225
config = None

0 commit comments

Comments
 (0)