Make it so that simply typing 'python -m manim' will embed you in a blank scene to work with

This commit is contained in:
Grant Sanderson
2021-01-02 22:03:00 -08:00
parent 7b3f4d08f5
commit 93fe783b80
4 changed files with 31 additions and 15 deletions

View File

@ -143,15 +143,17 @@ def get_manim_dir():
def get_module(file_name):
if file_name == "-":
module = types.ModuleType("input_scenes")
code = "from manimlib.imports import *\n\n" + sys.stdin.read()
try:
exec(code, module.__dict__)
return module
except Exception as e:
print(f"Failed to render scene: {str(e)}")
sys.exit(2)
# if file_name == "-":
# module = types.ModuleType("input_scenes")
# code = "from manimlib.imports import *\n\n" + sys.stdin.read()
# try:
# exec(code, module.__dict__)
# return module
# except Exception as e:
# print(f"Failed to render scene: {str(e)}")
# sys.exit(2)
if file_name is None:
return None
else:
module_name = file_name.replace(os.sep, ".").replace(".py", "")
spec = importlib.util.spec_from_file_location(module_name, file_name)
@ -187,7 +189,7 @@ def get_configuration(args):
"mirror_module_path": custom_defaults["directories"]["mirror_module_path"],
"output_directory": args.video_dir or custom_defaults["directories"]["output"],
"file_name": args.file_name,
"input_file_path": args.file,
"input_file_path": args.file or "",
"open_file_upon_completion": args.open,
"show_file_location_upon_completion": args.finder,
"quiet": args.quiet,