Skip to content

Instantly share code, notes, and snippets.

@cmcconomy
Created March 14, 2023 03:04
Show Gist options
  • Select an option

  • Save cmcconomy/9bca20856a6a48704555bc8dcf169ba7 to your computer and use it in GitHub Desktop.

Select an option

Save cmcconomy/9bca20856a6a48704555bc8dcf169ba7 to your computer and use it in GitHub Desktop.
Makefile for pinning python requirements
# DOCUMENTATION NOTE: Regular comments don't print in 'help'; two #'s do.
## +------------------------------------------------------------------------------
## | This Makefile contains targets for various python build / deploy steps.
## |
## | Key Targets to know:
## | make / make help: Display Help
help:
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
pip_framework_setup:
pip install --upgrade pip-tools pip setuptools
install_local: pip_framework_setup
pip install --require-hashes --upgrade -r requirements/main.txt
## | make install: Install frozen dependencies into local pip modules
install: install_local
update_all_deps: check_pat pip_framework_setup
pip-compile --upgrade --allow-unsafe --generate-hashes --no-emit-index-url --output-file requirements/main.txt requirements/main.in
## | make update: Update frozen requirements from input specs, and install
## | into local pip modules (Only used if you have updated your input req
update: update_all_deps install
.PHONY: help pip_framework_setup install_local install update_all_deps update
@cmcconomy
Copy link
Author

This requires you to create a file called ./requirements/main.in which contains all your direct requirements.
Running make update will pin newest requirements according to your spec; make install will (re)-install existing spec requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment