[0]: https://pydoit.org
[0]: https://pydoit.org
I mean, it's declarative, works on Windows, easy things are (very) easy, and because you can mix and match bash and python actions, hard things are suspiciously easy too.
Given how complicated the alternatives are (maeven, ninja, make, gulp...), you'd think it would have taken the world for years.
Yet I've only started to see people in the Python core dev team use it this year. It's only getting traction now.
Care to share an example?
It has to make sure a bunch of directories exist, run a node js command to build some files from the proper dir, then run a python command to regroup them + all static files from all django apps into one dir. Simple.
But then I had a problem I had to hack around. This required me to change an entry to a generated TOML file on the fly at every build.
doit just lets me add a 5 lines python function that does whatever I want, and insert it between my bash tasks, and I'm done.
def task_bundle_static_files():
def update_manifest():
conf = Path("var/static/manifest.toml")
data = toml.loads(conf.read_text())
data["./src/main.js"] = data["index.html"]
conf.write_text(toml.dumps(data))
return {
"actions": [
"mkdir -p ./var/static/",
"rm -fr ./var/static/* ",
"cd frontend/; npm run build",
"python manage.py collectstatic --noinput",
update_manifest,
"cp -r ./var/static/* ",
]
}better yet, use both and just doit
But I prefer it because:
- it runs anywhere you have python.
- it uses a clean syntax, and the parser is great at telling you about errors since it's python.
- you get access to python's stdlib: string formatting, maths, etc.
- you get access to python's ecosystem. Want to deal with timezone, hashing, crypto ? Sure you can.
- you get access to python's tooling (debugger, formatter, linter).
- you can still just use bash if you want. Easy things stay easy.
btw, the project is old and it is useful with the current feature set. There is an issue with the bus factor but is common for many tools.