Using Makefiles in Python projects

Pankaj Jangid pankaj.jangid at gmail.com
Sat Nov 9 22:53:12 EST 2019


Chris Angelico <rosuav at gmail.com> writes:
> 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.

Actually, the proposal to use Makefile is great. I have always been
thinking about it and using it in my own projects. At my previous
workplace there was compulsion to use Windows, so I had to setup
Cygwin. And I had same level of difficulty setting up Python on
Windows. So the difficulty level is same for Python and Make setup.

Another advantage of using Make is that it is easy to configure portable
mixed native programs with Python. To work on modern projects similar to
NumPy, TensorFlow, PyCharm where half of the code is native and half
Python, it is much easier to manage native part with Make. Autoconf,
automake etc. utilities tells you in advance what native libraries are
missing from the system - Windows or Linux.

We should not forget that Data Science, Machine Learning etc. fields
have helped in proliferation of Python lately. And the above mentioned
libraries have great role. We should make it even more easier to manage
mixed native projects portably. GNU Make is the way to go. Thanks for
raising this.

Regards,
-- 
Pankaj Jangid


More information about the Python-list mailing list