Hacker News new | ask | show | jobs
by Izkata 2167 days ago
This is in fact another misconception:

> and familiar at the same time (it's bash)

Make is an orchestrator that defaults to sh (not bash, actually). But what I've seen in some really good ones is taking advantage of the "orchestrator" part rather than the "sh/bash" part: One-line recipes that simply call a short script in any other language, including python, that do the desired thing for that recipe. The Makefile is then just used for coordinating partial-running those scripts.

On top of that, you could in fact set SHELL/ONESHELL and then the recipes themselves are python inside the Makefile:

  SHELL := python
  .ONESHELL:

  testfile:
      import csv
      writer = csv.writer(open("$@", 'w'))
      writer.writerow(['one', 'two'])
      writer.writerow(['three', 'four'])
And:

  $ make testfile
  import csv
  writer = csv.writer(open("testfile", 'w'))
  writer.writerow(['one', 'two'])
  writer.writerow(['three', 'four'])
  $ cat testfile
  one,two
  three,four
2 comments

Whoah! I didn't know about that feature. For most build tasks sh is probably best but this could be incredibly useful for some non build related things.

"Build tools are only for building software" is probably another falsehood to add, make can be a great tool anywhere you've got a dependency graph.

That's pretty neat, but I have never ever seen it used (not even in python projects). I'd be skeptical until I'd seen it used in anger.

It also would need to basically support virtualenvs and pip install to be really compelling, I think. Python without those is a pale imitation. That CSV module is known to be pretty bad, for instance (like many built in modules).