Prefer Python2 tools; fail-fast when wrong
This change includes a few things: 1) Prefer python2 and pip2 when on the PATH, over the undecorated names python and pip. This is the standard convention for package managers like Pip, etc., to support Python2 and Python3 side-by-side. 2) Fail-fast if neither can be found on the PATH. 3) Check the reported version number for python, pip, and pylint, and fail-fast if it doesn't report back 2.7, just to safeguard against undecorated binaries with unsupported versions. Also, we had not listed wheel as a dependency in the requirements.txt file. This needs to be there to support building bdist_wheels. Fixed.
This commit is contained in:
parent
f59931d242
commit
440ffb27e5
|
@ -109,6 +109,42 @@ PULUMI_NODE_MODULES := $(PULUMI_ROOT)/node_modules
|
||||||
# ensure that `default` is the target that is run when no arguments are passed to make
|
# ensure that `default` is the target that is run when no arguments are passed to make
|
||||||
default::
|
default::
|
||||||
|
|
||||||
|
# Ensure the requisite tools are on the PATH.
|
||||||
|
# - Prefer Python2 over Python.
|
||||||
|
PYTHON := $(shell command -v python2 2>/dev/null)
|
||||||
|
ifeq ($(PYTHON),)
|
||||||
|
PYTHON = $(shell command -v python 2>/dev/null)
|
||||||
|
endif
|
||||||
|
ifeq ($(PYTHON),)
|
||||||
|
ensure::
|
||||||
|
$(error "missing python 2.7 (`python2` or `python`) from your $$PATH; \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
else
|
||||||
|
PYTHON_VERSION := $(shell command $(PYTHON) --version 2>&1)
|
||||||
|
ifeq (,$(findstring 2.7,$(PYTHON_VERSION)))
|
||||||
|
ensure::
|
||||||
|
$(error "$(PYTHON) did not report a 2.7 version number ($(PYTHON_VERSION)); \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
# - Prefer Pip2 over Pip.
|
||||||
|
PIP := $(shell command -v pip2 2>/dev/null)
|
||||||
|
ifeq ($(PIP),)
|
||||||
|
PIP = $(shell command -v pip 2>/dev/null)
|
||||||
|
endif
|
||||||
|
ifeq ($(PIP),)
|
||||||
|
ensure::
|
||||||
|
$(error "missing pip 2.7 (`pip2` or `pip`) from your $$PATH; \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
else
|
||||||
|
PIP_VERSION := $(shell command $(PIP) --version 2>&1)
|
||||||
|
ifeq (,$(findstring python 2.7,$(PIP_VERSION)))
|
||||||
|
ensure::
|
||||||
|
$(error "$(PIP) did not report a 2.7 version number ($(PIP_VERSION)); \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# If there are sub projects, our default, all, and ensure targets will
|
# If there are sub projects, our default, all, and ensure targets will
|
||||||
# recurse into them.
|
# recurse into them.
|
||||||
ifneq ($(SUB_PROJECTS),)
|
ifneq ($(SUB_PROJECTS),)
|
||||||
|
|
|
@ -5,7 +5,7 @@ nvm install v6.10.2
|
||||||
# they would be set in the outer shell as well, so do as much logic as
|
# they would be set in the outer shell as well, so do as much logic as
|
||||||
# we can in a subshell.
|
# we can in a subshell.
|
||||||
(
|
(
|
||||||
set -o nounset -o errexit -o pipefail
|
set -o nounset -o errexit -o pipefail -x
|
||||||
[ -e "$(go env GOPATH)/bin" ] || mkdir -p "$(go env GOPATH)/bin"
|
[ -e "$(go env GOPATH)/bin" ] || mkdir -p "$(go env GOPATH)/bin"
|
||||||
|
|
||||||
YARN_VERSION="1.3.2"
|
YARN_VERSION="1.3.2"
|
||||||
|
@ -58,9 +58,6 @@ nvm install v6.10.2
|
||||||
pip install --user "wheel==${WHEEL_VERSION}" "twine==${TWINE_VERSION}"
|
pip install --user "wheel==${WHEEL_VERSION}" "twine==${TWINE_VERSION}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# If the sub shell failed, bail out now.
|
|
||||||
[ "$?" -eq 0 ] || exit 1
|
|
||||||
|
|
||||||
# By default some tools are not on the PATH, let's fix that
|
# By default some tools are not on the PATH, let's fix that
|
||||||
|
|
||||||
# On OSX, the user folder that `pip` installs tools to is not on the
|
# On OSX, the user folder that `pip` installs tools to is not on the
|
||||||
|
@ -72,3 +69,6 @@ fi
|
||||||
|
|
||||||
# Add yarn to the $PATH
|
# Add yarn to the $PATH
|
||||||
export PATH=$HOME/.yarn/bin:$PATH
|
export PATH=$HOME/.yarn/bin:$PATH
|
||||||
|
|
||||||
|
# If the sub shell failed, bail out now.
|
||||||
|
[ "$?" -eq 0 ] || exit 1
|
||||||
|
|
|
@ -8,22 +8,37 @@ GOMETALINTER := ${GOMETALINTERBIN} --config=../../Gometalinter.json
|
||||||
include ../../build/common.mk
|
include ../../build/common.mk
|
||||||
|
|
||||||
ensure::
|
ensure::
|
||||||
pip install --user -r requirements.txt
|
$(PIP) install --user --upgrade -r requirements.txt
|
||||||
|
|
||||||
|
# Ensure Pylint is present and has the right version.
|
||||||
|
PYLINT := $(shell command -v pylint 2>/dev/null)
|
||||||
|
ifeq ($(PYLINT),)
|
||||||
|
ensure::
|
||||||
|
$(error "missing pylint from your $$PATH; \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
else
|
||||||
|
PYLINT_VERSION := $(shell command $(PYLINT) --version 2>&1)
|
||||||
|
ifeq (,$(findstring Python 2.7,$(PYLINT_VERSION)))
|
||||||
|
ensure::
|
||||||
|
$(error "$(PYLINT) did not report a 2.7 version number ($(PYLINT_VERSION)); \
|
||||||
|
please see https://github.com/pulumi/home/wiki/Package-Management-Prerequisites")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
lint::
|
lint::
|
||||||
pylint -E lib/pulumi/ --ignore-patterns '.*_pb2_.*.py'
|
$(PYLINT) -E lib/pulumi/ --ignore-patterns '.*_pb2_.*.py'
|
||||||
$(GOMETALINTER) ./cmd/pulumi-language-python/... | sort ; exit $${PIPESTATUS[0]}
|
$(GOMETALINTER) ./cmd/pulumi-language-python/... | sort ; exit $${PIPESTATUS[0]}
|
||||||
$(GOMETALINTER) ./pkg/... | sort ; exit $${PIPESTATUS[0]}
|
$(GOMETALINTER) ./pkg/... | sort ; exit $${PIPESTATUS[0]}
|
||||||
|
|
||||||
build::
|
build::
|
||||||
cd ./lib/ && python setup.py clean --all 2>/dev/null
|
cd ./lib/ && $(PYTHON) setup.py clean --all 2>/dev/null
|
||||||
rm -rf ./bin/ && cp -R ./lib/. ./bin/
|
rm -rf ./bin/ && cp -R ./lib/. ./bin/
|
||||||
sed -i.bak "s/\$${VERSION}/$(VERSION)/g" ./bin/setup.py && rm ./bin/setup.py.bak
|
sed -i.bak "s/\$${VERSION}/$(VERSION)/g" ./bin/setup.py && rm ./bin/setup.py.bak
|
||||||
cd ./bin/ && python setup.py build bdist_wheel --universal
|
cd ./bin/ && $(PYTHON) setup.py build bdist_wheel --universal
|
||||||
go install -ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
go install -ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
||||||
|
|
||||||
install::
|
install::
|
||||||
cd ./bin/ && python setup.py install --user --force --prefix=
|
cd ./bin/ && $(PYTHON) setup.py install --user --force --prefix=
|
||||||
cp ./cmd/pulumi-language-python-exec "$(PULUMI_BIN)"
|
cp ./cmd/pulumi-language-python-exec "$(PULUMI_BIN)"
|
||||||
GOBIN=$(PULUMI_BIN) go install \
|
GOBIN=$(PULUMI_BIN) go install \
|
||||||
-ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
-ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
||||||
|
|
|
@ -2,3 +2,4 @@ google==2.0.1
|
||||||
grpcio==1.9.1
|
grpcio==1.9.1
|
||||||
pylint==1.8.2
|
pylint==1.8.2
|
||||||
six==1.11.0
|
six==1.11.0
|
||||||
|
wheel==0.30.0
|
||||||
|
|
Loading…
Reference in a new issue