-
Notifications
You must be signed in to change notification settings - Fork 2.5k
os.system -> subprocess #3955
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
os.system -> subprocess #3955
Conversation
manim/utils/tex_file_writing.py
Outdated
return result | ||
|
||
|
||
def tex_compilation_command( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function no longer returns a str
with the TeX command, but instead returns a list[str]
containing the command arguments, could we change this function's name to something like prepare_tex_compilation_args
or prepare_tex_compilation_command_args
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the synopsys of subprocess.run, the name of the first and only positional argument, args
, is a bit misleading because its first item is the command name. I think it follows the C language tradition where the first item of the argument vector (argv) of exec and main(int argc, char *argv[])
is the command name too.
If I saw a function named prepare_tex_compilation_command_args
I would assume it returns the arguments only, not the command. I suggest we simply name this function make_tex_compilation_command
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make_tex_compilation_command
sounds fine to me 👍
manim/utils/tex_file_writing.py
Outdated
tex_compiler: str, output_format: str, tex_file: Path, tex_dir: Path | ||
) -> str: | ||
) -> list[str]: | ||
"""Prepares the tex compilation command with all necessary cli flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Prepares the tex compilation command with all necessary cli flags | |
"""Prepares a list of arguments for the TeX compilation command, with all necessary | |
CLI flags. |
Returns | ||
------- | ||
:class:`str` | ||
Compilation command according to given parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't select the line above this one (:class:`str`), but could you please change that one to :class:`list`[:class:`str`]?
Compilation command according to given parameters | |
A list of arguments for the TeX compilation command, according to the given parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the type annotation, thanks. But I think the description is accurate. What is returned is really the full command, just in list form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be an error in this part:
:class:`list`[:class:`str`]
The html output does not look correct in Firefox, something like list`[:class:`str
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct syntax seems to be:
:class:`list[str]`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I forgot that there was an issue with :class:`list`[:class:`str`].
The way Sphinx and Autodoc work for us is weird. When it autoinfers the return type from the typings, it doesn't seem to enclose the names with backticks, so if it autoinferred it would simply render list[str]. We do have a lot of explicit return types in docstrings enclosed in backticks, and they're rendered as inline code. That's an inconsistency which we should address at some point.
I would say, for the purpose of this PR, simply using list[str]
would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR! I left some very minor changes regarding tex_compilation_command
and its docstring.
Quoting the python library documentation: > The subprocess module provides more powerful facilities for spawning > new processes and retrieving their results; using that module is > preferable to using this function.
55434cf
to
e7b4ba3
Compare
To avoid confusion I renamed variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Quoting the python library documentation: