Using Makefiles in Python projects

Thomas Jollans tjol at tjol.eu
Mon Nov 11 12:55:30 EST 2019


On 11/11/2019 14:23, Rhodri James wrote:
> On 09/11/2019 23:50, Thomas Jollans wrote:
>> On 09/11/2019 21:30, Chris Angelico wrote:
>>> On Sun, Nov 10, 2019 at 2:10 AM Thomas Jollans <tjol at tjol.eu> wrote:
>>>> On 07/11/2019 20:20, Vitaly Potyarkin wrote:
>>>>> What do you think of using Makefiles for automating common chores in
>>>>> Python projects? Like linting, type checking and testing?
>>>>>
>>>>> I've come up with a reusable Makefile for automating virtual 
>>>>> environment
>>>>> management in Python projects. I think it can be useful for 
>>>>> simplifying
>>>>> the onboarding of new developers (both new to project and new to 
>>>>> Python)
>>>>> and for documenting project's development practices.
>>>>>
>>>>> Here it is:
>>>>> - Repo: https://github.com/sio/Makefile.venv
>>>>> - Demo screencast: https://asciinema.org/a/279646
>>>>>
>>>>> What do you think? Is this useful or I'm just unaware of some tool 
>>>>> that
>>>>> abstracts venv chores away better?
>>>>>
>>>> As others have said, make is a useful tool and many people use it for
>>>> different purposes in their Python projects. Nothing wrong with that.
>>>>
>>>> HOWEVER, at risk of stating the obvious, using Makefiles written 
>>>> for/on
>>>> *nix systems on Windows is a bit of a hassle. If, for some reason, 
>>>> your
>>>> software is *nix-only anyway, that's fine. If not, using make means
>>>> sacrificing some portability.
>>>>
>>>> If your software runs on Windows, of you think it might run on Windows
>>>> in the future, maybe consider writing simple Python scripts for
>>>> platform-independent tasks rather than makefiles and shell scripts.
>>>>
>>> Are you assuming that every Windows system has Python, but that you
>>> can't get make or bash? Because neither half of that is true. I've
>>> happily used makefiles on Windows, and these days, bash is as easy to
>>> get hold of as Python is.
>>>
>>> ChrisA
>>
>> That's why I say "a bit of a hassle". You can get a MSYS set up 
>> (whether from Git for Windows or otherwise). You can get it to play 
>> nice with the right Python installation and the Python scripts you 
>> presumably want to call from the Makefile. But all of that is a bit 
>> of a hassle.
>
> If you've got almost any development environment for Windows, you've 
> got a version of make.  I quite like the NMake that comes with Visual 
> Studio, for example, and use it in preference to the IDE when I can. 
> Yes, it's a hassle, but it's a hassle you're going to go through anyway.
>
I'm sure it's possible to write Makefiles that work with both GNU make 
and NMake, but I imagine it's a rather limiting and thankless enterprise.

Is that something you actually do? (Maybe it's great, I really wouldn't 
know. Do tell!)




More information about the Python-list mailing list