mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
remove pip-accel and make sure commands work if you're in a venv
remove pip-accel - it's not been updated in two years, and pins our version of pip to a version that is several breaking changes old. make sure commands work if you're already in a venv - mostly by checking for presence of $VIRTUAL_ENV, and ensuring we use the correct pip to install packages. Also clean up the commands a bit.
This commit is contained in:
26
Makefile
26
Makefile
@@ -2,7 +2,6 @@
|
||||
SHELL := /bin/bash
|
||||
DATE = $(shell date +%Y-%m-%d:%H:%M:%S)
|
||||
|
||||
PIP_ACCEL_CACHE ?= ${CURDIR}/cache/pip-accel
|
||||
APP_VERSION_FILE = app/version.py
|
||||
|
||||
GIT_BRANCH ?= $(shell git symbolic-ref --short HEAD 2> /dev/null || echo "detached")
|
||||
@@ -34,11 +33,19 @@ help:
|
||||
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: venv
|
||||
# if there's a virtualenv already active, we don't want to do anything
|
||||
ifeq ($(VIRTUAL_ENV),)
|
||||
venv: venv/bin/activate ## Create virtualenv if it does not exist
|
||||
|
||||
venv/bin/activate:
|
||||
test -d venv || virtualenv venv -p python3
|
||||
. venv/bin/activate && pip install pip-accel
|
||||
|
||||
VENV_BIN_DIR = $(shell . venv/bin/activate && echo $$VIRTUAL_ENV/bin)
|
||||
else
|
||||
venv:
|
||||
|
||||
VENV_BIN_DIR = $(VIRTUAL_ENV)/bin
|
||||
endif
|
||||
|
||||
.PHONY: check-env-vars
|
||||
check-env-vars: ## Check mandatory environment variables
|
||||
@@ -65,10 +72,9 @@ production: ## Set environment to production
|
||||
@true
|
||||
|
||||
.PHONY: dependencies
|
||||
dependencies: venv ## Install build dependencies
|
||||
mkdir -p ${PIP_ACCEL_CACHE}
|
||||
. venv/bin/activate && make install-pycurl
|
||||
. venv/bin/activate && PIP_ACCEL_CACHE=${PIP_ACCEL_CACHE} pip-accel install -r requirements_for_test.txt
|
||||
dependencies: venv
|
||||
$(call install-pycurl, $(VENV_BIN_DIR)/pip)
|
||||
$(VENV_BIN_DIR)/pip install -r requirements_for_test.txt
|
||||
|
||||
.PHONY: generate-version-file
|
||||
generate-version-file: ## Generates the app version file
|
||||
@@ -76,7 +82,7 @@ generate-version-file: ## Generates the app version file
|
||||
|
||||
.PHONY: build
|
||||
build: dependencies generate-version-file ## Build project
|
||||
. venv/bin/activate && PIP_ACCEL_CACHE=${PIP_ACCEL_CACHE} pip-accel install -r requirements.txt
|
||||
|
||||
|
||||
.PHONY: build-paas-artifact
|
||||
build-paas-artifact: ## Build the deploy artifact for PaaS
|
||||
@@ -109,7 +115,7 @@ freeze-requirements:
|
||||
|
||||
define install-pycurl
|
||||
# install pycurl separately to avoid flags disabling wheels for other packages
|
||||
PYCURL_SSL_LIBRARY=openssl ${1} install pycurl --global-option="build_ext" --global-option="-I/usr/local/opt/openssl/include"
|
||||
PYCURL_SSL_LIBRARY=openssl ${1} install pycurl==7.43.0.2 --global-option="build_ext" --global-option="-I/usr/local/opt/openssl/include"
|
||||
endef
|
||||
|
||||
.PHONY: install-pycurl
|
||||
@@ -125,11 +131,10 @@ test-requirements:
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: venv ## Create coverage report
|
||||
. venv/bin/activate && coveralls
|
||||
coveralls
|
||||
|
||||
.PHONY: prepare-docker-build-image
|
||||
prepare-docker-build-image: ## Prepare the Docker builder image
|
||||
mkdir -p ${PIP_ACCEL_CACHE}
|
||||
make -C docker build
|
||||
|
||||
.PHONY: build-with-docker
|
||||
@@ -137,7 +142,6 @@ build-with-docker: prepare-docker-build-image ## Build inside a Docker container
|
||||
@docker run -i${DOCKER_TTY} --rm \
|
||||
--name "${DOCKER_CONTAINER_PREFIX}-build" \
|
||||
-v "`pwd`:/var/project" \
|
||||
-v "${PIP_ACCEL_CACHE}:/var/project/cache/pip-accel" \
|
||||
-e UID=$(shell id -u) \
|
||||
-e GID=$(shell id -g) \
|
||||
-e GIT_COMMIT=${GIT_COMMIT} \
|
||||
|
||||
Reference in New Issue
Block a user