Writing Makefiles for Python Projects
venthur.de
venthur.de
The commands are useful, getting support for declaring easy to use test and lint commands in pyproject.toml shouldn't be so hard and something I'd love to see. In the meantime, you can use shell scripts (or a makefile sans the venv stuff) and do e.g. `poetry run ./test`.
Tbh, there's nothing wrong with a makefile, and poetry isn't perfect. I just feel poetry works better than trying to work around the limitation of existing tooling. An so far, I'm happy with pyproject.toml. Putting dev tool configuration in there is a lot nicer than having several different files with different syntax for e.g. isort, pylint, etc
However, for setting up the whole environment, I'm looking for a cookiecutter-based or -integrated solution.
We have a de facto, decades old standard for a "run the tests" or a "build the damn thing" big red button. We should use it, even if it's just a few line wrapper over npm run or docker build or whatever. (The fact that it could be either is the reason that there should be a standardized entrypoint.)
Once upon a time anybody using a Unix-like OS was familiar with most of those standard targets as a consequence of the ubiquity of autotools, especially when package repositories weren't so comprehensive and it was more common to download and build tarballs locally.
But at my current job, there's no rhyme or reason to make targets. Something like `make build` (where build may or may not be the default target, likely accidentally if it is) is more likely to install Go toolchain dependencies than to build any of the project source code. And of course little if any attempt is made to actually declare dependencies, correct or broken, as for so many programmers these days a Makefile is just a container for ad hoc shell code.
I don't often make use of autotools in my own projects as I can usually get good mileage from plain POSIX make, switching to GNU make in a bind, but I religiously try to adhere to the standard targets and other build and distribution conventions outlined at https://www.gnu.org/software/make/manual/html_node/Makefile-... and https://www.gnu.org/prep/standards/standards.html#Managing-R...
Not gonna lie, that's completely what it is for me. I don't work in any compiled languages, and I don't have any kind of a "build target" (unless you count a Docker image?) in my workflow.
Some old timers insist that "make test" (what are you 'making'?) is more intuitive than "run_tests.sh" so I indulge them. But it's just a list of 'phony' and some weirdly-formatted bash with tabs.
Does anyone else have other approaches beyond the two from the article?