Skip to content

Instantly share code, notes, and snippets.

@gmanfunky
Last active September 22, 2017 01:21
Show Gist options
  • Save gmanfunky/70732256ee5c9c336435921d7a9f0255 to your computer and use it in GitHub Desktop.
Save gmanfunky/70732256ee5c9c336435921d7a9f0255 to your computer and use it in GitHub Desktop.
Windows compatible python Makefile virtualenv venv
# If on windows, you may need to download some custom python wheels for libxml and xmlsec
APP_VENV_PATH ?= ../python-venv
ifeq ($(OS),Windows_NT)
VENV_PATH_BIN := $(addsuffix /Scripts,$(APP_VENV_PATH))
else
VENV_PATH_BIN := $(addsuffix /bin,$(APP_VENV_PATH))
endif
default: install-dev
clean:
rm -rf $(APP_VENV_PATH)
rm -rf .eggs *.egg-info
run: logs
$(VENV_PATH_BIN)/python manage.py runserver
install-dev: venv
PBR_VERSION=0.0.1 $(VENV_PATH_BIN)/pip install --no-deps -e .
test: test-deps install-dev
-$(VENV_PATH_BIN)/flake8
$(VENV_PATH_BIN)/pytest --cov MYAPP --cov-report=xml --cov-report=term
test-deps: $(APP_VENV_PATH)/.test-deps-installed venv
$(APP_VENV_PATH)/.test-deps-installed: requirements-dev.txt
$(VENV_PATH_BIN)/pip install -r requirements-dev.txt
touch .test-deps-installed
logs:
mkdir -p logs
venv: $(VENV_PATH_BIN)/activate
$(VENV_PATH_BIN)/activate: requirements.txt
test -d $(APP_VENV_PATH) || virtualenv $(APP_VENV_PATH)
# If on windows, download lxml and xmlsec python wheels to below location
-$(VENV_PATH_BIN)/pip install ../local-packages/*.whl
$(VENV_PATH_BIN)/pip install -r requirements.txt
touch $(VENV_PATH_BIN)/activate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment