Skip to content

Instantly share code, notes, and snippets.

@mexisme
Last active January 7, 2018 22:43
Show Gist options
  • Save mexisme/06370ac15946569e59d419f3a76c2846 to your computer and use it in GitHub Desktop.
Save mexisme/06370ac15946569e59d419f3a76c2846 to your computer and use it in GitHub Desktop.
Vendorising Python pips via Pipfile
# Makefile-friendly version of:
#
# pipenv run -- pip install -r <(pipenv lock -r) --target $PWD/vendored --no-deps
# You will need to add something like the following to your Main .py file:
#
# import os
# import sys
# parent_dir = os.path.abspath(os.path.dirname(__file__))
# # (Might need to adjust the path, e.g. adding '..' if appropriate)
# vendor_dir = os.path.join(parent_dir, 'vendored')
# # (Add vendor directory to module search path)
# sys.path.append(vendor_dir)
PIPENV=pipenv
PIP=pip
VENDOR_DIR=vendored
$(VENDOR_DIR): requirements.txt
$(PIPENV) run -- $(PIP) install -r "$<" --target "$@" --no-deps
.INTERMEDIATE: requirements.txt
Pipfile.lock requirements.txt: Pipfile
$(PIPENV) lock -r >"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment