ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
19.93k stars 1.48k forks source link

Support running without installation #3828

Open geajack opened 1 week ago

geajack commented 1 week ago

So I cloned this repo and wanted to run the code inside, but I wanted to run it in the "simplest" possible way - without going through an installation procedure. I just want to run the source code I have in front of me directly, without any extra steps, partly because I want to figure out how the code works, make changes to it and see them quickly, and maybe run it through a debugger, and I don't want to have to figure out how to make all that work with a pip installed version of manim. I just want to do python3 path/to/entrypoint.py or something.

The way to do this is just python3 -m manim in this case, but when I do this I get:

/usr/bin/python3: Error while finding module specification for 'manim.__main__' (PackageNotFoundError: No package metadata was found for manim)

This is due to an as far as I can tell not super important line in manim's __init__.py:

__version__ = version(__name__)

which can't return a version if no copy of manim is actually installed. I fixed this by just doing:

try:
    __version__ = version(__name__)
except:
    __version__ = "local"

and now I can run manim "locally" the way I would like. I am not sure if this particular fix suits, but I think it would be nice to in some way address this so that people in my use case can just grab the code and get hacking without having to jump through any extra "hoops" to run it.

behackl commented 1 week ago

Why don't you just run pip install --editable .? I am not sure I can see why you would want to avoid installing the library at all cost.