Using Makefiles in Python projects

Chris Angelico rosuav at gmail.com
Fri Nov 8 14:21:42 EST 2019


On Sat, Nov 9, 2019 at 3:31 AM Marko Rauhamaa <marko at pacujo.net> wrote:
>
> Skip Montanaro <skip.montanaro at gmail.com>:
>
> > On Thu, Nov 7, 2019 at 1:24 PM Vitaly Potyarkin <sio.wtf at gmail.com> wrote:
> >>
> >> What do you think of using Makefiles for automating common chores in
> >> Python projects? Like linting, type checking and testing?
> >
> > Kinda unsure why this needs to be asked (says the guy who's used Make
> > longer than Python and nearly as long as Emacs). :-) That said, I will
> > answer in the affirmative. Make is a great tool.
>
> I can't agree that make is a great tool. It's a tool a slight step
> better than unconditional build scripts, but it's really only suitable
> for projects involving a single directory (although baffling heroics
> have been achieved using GNU Make in particular).
>

Really? I've used make with multi-directory projects many times. Also,
like Grant, I use a Makefile to document some things.

For simple projects, I use a Makefile to precompile, compile, and
deploy, all governed by a master "all" phony target. When I'm working
in SourcePawn, I have a Python script that reads my source file and
generates an include file from it (because SP doesn't have
metaprogramming facilities), and I might have a script that reads an
entirely separate file that isn't even under my control, and parse
that to create an include file. Then there's the actual compilation
command, and finally deployment (which is unconditional). That's a lot
of commands, some of them very easy to forget, involving files inside
and outside the project directory... and all done with a single "make"
command.

SCons is massive overkill for the project I'm doing. Why introduce a
dependency like that? Honestly, SCons can be a pain even with a
gigantic project, and there's no way that I want to use it for simple
automation.

ChrisA


More information about the Python-list mailing list