Makefile tricks for Python projects

3 years ago by Jason Novinger to c/python

I like using Makefiles. They work great both as simple task runners as well as build systems for medium-size projects. This is my starter template for Python projects. Note: This blog post assumes some basic knowledge of how make and Makefiles work. Basic configuration I like using bash as the default shell. Then set some flags to exit on error (-eu -o pipefail), warn about undefined variables and disable built-in rules.

cross-posted from: https://lemmy.ml/post/1160466

I originally posted this over in https://lemmy.ml/c/python before discovering programming.dev.

Some neat tricks for using Makefiles with Python that I hadn't seen before. The one I have seen, having a help target, has been super useful in team environments and for debugging when used with variables.

load all comments
clawlor 2 points 3 years ago

Great post! I suspect that PYTHONPATH hack might be useful in reorganizing a particular repo at $JOB that contains a few different deployable packages and a common library.

The thing I like most about using Makefiles in this way is that it can provide a consistent dev experience across many repos in a team setting, if each repo defines a consistent set of make targets: make setup, make test, make build etc. I don't have to care too much if the project is using pip vs. poetry, or pytest vs. unittest.

path: 0 289616, hotness: undefined, score: 2, children: 0
python
python

@programming.dev

login for more options
8076
745
295

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events
Past

November 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
  • Pythรถrhead: a Python library for interacting with Lemmy
  • Plemmy: a Python package for accessing the Lemmy API
  • pylemmy pylemmy enables simple access to Lemmy's API with Python
  • mastodon.py, a Python wrapper for the Mastodon API
Feeds

go to feed...