/micromamba.mk

A Makefile for Python projects

Primary LanguageMakefileMIT LicenseMIT

micromamba.mk

Manage micromamba environments and common workflows for Python applications with make.

The goal is to make getting started as easy as git clone && make.

(This is unstable, unsafe and not ready for production.)

Demo

git clone https://github.com/giovannipcarvalho/micromamba.mk
cd micromamba.mk/example

make            # creates env, syncs deps, checks code, and runs tests
make build run  # builds and runs docker image

Requirements

Usage

  1. Create a Makefile with the following contents:
include micromamba.mk
micromamba.mk:
	curl \
		--output micromamba.mk \
		--location \
		"https://raw.githubusercontent.com/giovannipcarvalho/micromamba.mk/master/micromamba.mk"
  1. Create an environment.yml file:
channels:
  - conda-forge
dependencies:
  - python=3.11
  - pip:
    - uv
  1. Run make help to see available targets:
$ make help
all          Run main targets
env          Create or update virtual environment
activate     Open a new shell with the activated environment
deps         Sync dependencies in the virtual environment
lockdeps     Update or generate dependency lock files
check        Run checkers, linters and auto-fixers
test         Run tests
cov          Run tests and report coverage
build        Build artifacts
run          Run main entrypoint
notebook     Start jupyter notebook
clean        Clean-up generated files
purge        Clean-up and remove environment
help         Show help

Remember to ignore micromamba.mk and .micromambaenv, e.g.:

echo -e 'micromamba.mk\n.micromambaenv' >> .gitignore

This Makefile is designed to work with setuptools. Check out example/ for a complete example.

How to

Override commands

# file: Makefile
# [...]
build:
	@echo my custom build command

It works, but you'll get warnings such as:

Makefile:3: warning: overriding recipe for target 'build'

See also