Skip to content

Commit f14a4d6

Browse files
If pipenv is in path, install requirements with pipenv to avoid version incompatabilities (#50)
* If pipenv is in path, install requirements with pipenv to avoid version incompatabilities * Remove docker-compose, for now * Revert "Remove docker-compose, for now" This reverts commit 9bd1e46.
1 parent c47a7aa commit f14a4d6

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

Makefile.venv

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
BUILD_HARNESS_REQ_TEMPLATE:=$(BUILD_HARNESS_PATH)/requirements.template
22
BUILD_HARNESS_REQ_NAME:=.build-harness.requirements.txt
33
BUILD_HARNESS_REQ:=$(CURDIR)/$(BUILD_HARNESS_REQ_NAME)
4+
BUILD_HARNESS_PIPFILE_NAME:=.build-harness.Pipfile
5+
BUILD_HARNESS_PIPFILE:=$(CURDIR)/$(BUILD_HARNESS_PIPFILE_NAME)
46
BUILD_HARNESS_VENV_NAME:=.build-harness.venv
57
BUILD_HARNESS_VENV:=$(CURDIR)/$(BUILD_HARNESS_VENV_NAME)
68
WITH_BH_VENV=$(shell test -f $(BUILD_HARNESS_REQ) && echo "source $(BUILD_HARNESS_VENV)/bin/activate 2>/dev/null &&")
@@ -26,10 +28,25 @@ $(BUILD_HARNESS_REQ): $(BUILD_HARNESS_REQ_TEMPLATE)
2628
@if [ -f $@ ]; then echo "Removing previously generated build-harness requirements" && rm $@; fi
2729
@cat $(BUILD_HARNESS_REQ_TEMPLATE) | xargs -I % bash -c 'if [ -z "$$(which % 2>/dev/null)" ]; then echo "% not found" && echo "%" >> $@; fi'
2830

29-
$(BUILD_HARNESS_VENV): $(BUILD_HARNESS_REQ)
31+
$(BUILD_HARNESS_PIPFILE): $(BUILD_HARNESS_REQ)
32+
@if [ -f $@ ]; then echo "Removing previously generated build-harness Pipfile" && rm $@; fi
33+
@if [ -n "$$(which pipenv 2>/dev/null)" ]; then \
34+
echo "[packages]" >> $@; \
35+
cat $(BUILD_HARNESS_REQ) | xargs -I % bash -c 'if [ -z "$$(which % 2>/dev/null)" ]; then echo "% = \"*\"" >> $@; fi'; \
36+
fi
37+
38+
$(BUILD_HARNESS_VENV): $(BUILD_HARNESS_REQ) $(BUILD_HARNESS_PIPFILE)
3039
@if [ -s $(BUILD_HARNESS_REQ) ]; then echo "Installing: $$(cat $(BUILD_HARNESS_REQ) | tr '\n' ' ')"; fi
31-
@test -f $(BUILD_HARNESS_REQ) \
32-
&& ( \
40+
@if [ -n "$$(which pipenv 2>/dev/null)" ]; then \
41+
echo "Installing build-harness requirements with pipenv..."; \
42+
( \
43+
$(shell if [ $$(python -c 'import platform; ver=int(platform.python_version()[0]); print(ver)' 2>/dev/null) -eq 2 ] && [ -n "$$(which python3 2>/dev/null)" ]; then echo "python3"; else echo "python"; fi) -m venv $@ \
44+
&& source $@/bin/activate && pip install -r <(PIPENV_PIPFILE=$(BUILD_HARNESS_PIPFILE) PIPENV_QUIET=1 pipenv --bare lock -r --pre) --ignore-installed \
45+
); if [ $$? -ne 0 ]; then rm -rf $@; fi; \
46+
else \
47+
echo "WARNING: Installing build-harness requirements with venv + pip because pipenv was not installed..."; \
48+
( \
3349
$(shell if [ $$(python -c 'import platform; ver=int(platform.python_version()[0]); print(ver)' 2>/dev/null) -eq 2 ] && [ -n "$$(which python3 2>/dev/null)" ]; then echo "python3"; else echo "python"; fi) -m venv $@ \
3450
&& source $@/bin/activate && pip install -r $(BUILD_HARNESS_REQ) --ignore-installed \
35-
); if [ $$? -ne 0 ]; then rm -rf $@; fi
51+
); if [ $$? -ne 0 ]; then rm -rf $@; fi; \
52+
fi

modules/python/Makefile.style

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ python/lint/announce/%:
2727
.PHONY: python/lint
2828
## Check python files using black
2929
python/lint: bh/venv reports/
30-
@$(MAKE) python/lint/targets python/isort/check python/black/check python/flake8 # python/autoflake/check
30+
@$(MAKE) python/lint/targets python/isort/check python/black/check python/flake8 python/autoflake/check
3131
@echo "Done."
3232

3333
.PHONY: python/autoflake/check
@@ -78,4 +78,4 @@ python/flake8: bh/venv
7878

7979
.PHONY: python/fmt
8080
## Format python files
81-
python/fmt: python/isort python/black # python/autoflake
81+
python/fmt: python/isort python/black python/autoflake

requirements.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ advbumpversion
22
black
33
flake8
44
isort
5+
autoflake
6+
docker-compose

0 commit comments

Comments
 (0)