Reenable Pylint (#1024)
This change uses virtualenv to insulate us from platform differences in our building of the Python SDK, and to create an isolated Python 2 environment. This includes meaning we don't need to worry about the specific location and behavior of Pylint. I *think* this will work no matter whether it's Mac, Ubuntu, ArchLinux, Windows, and so on. We do install to the --user directory in the install target using `pip install -e`, however, which enables the machine-wide symlinking that we need to support various workflows. This fixes pulumi/pulumi#1007.
This commit is contained in:
parent
c1a06b14cc
commit
98aaf12cdf
|
@ -14,5 +14,5 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then
|
|||
twine upload \
|
||||
--repository-url https://pypi.pulumi.com?token=${PULUMI_API_TOKEN} \
|
||||
-u pulumi -p pulumi \
|
||||
${ROOT}/sdk/python/bin/dist/*.whl
|
||||
${ROOT}/sdk/python/env/lib/dist/*.whl
|
||||
fi
|
||||
|
|
2
sdk/python/.gitignore
vendored
2
sdk/python/.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
*.pyc
|
||||
/bin/
|
||||
/env/
|
||||
/*.egg-info
|
||||
|
|
|
@ -2,27 +2,45 @@ PROJECT_NAME := Pulumi Python SDK
|
|||
LANGHOST_PKG := github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python
|
||||
VERSION := $(shell git describe --tags --dirty 2>/dev/null | sed "s/v//" | sed "s/-/+/" | sed "s/-/./g")
|
||||
|
||||
PYENV := env
|
||||
PYENVBIN := $(PYENV)/bin
|
||||
PYENVSRC := $(PYENV)/src
|
||||
PYENVLIB := $(PYENV)/lib
|
||||
|
||||
GOMETALINTERBIN := gometalinter
|
||||
GOMETALINTER := ${GOMETALINTERBIN} --config=../../Gometalinter.json
|
||||
|
||||
include ../../build/common.mk
|
||||
|
||||
ensure::
|
||||
$(PIP) install --user --upgrade -r requirements.txt
|
||||
$(PIP) install virtualenv
|
||||
rm -rf $(PYENV) && virtualenv --python=$(PYTHON) $(PYENV)/
|
||||
echo "export PYTHONPATH=$${PYTHONPATH}:$(shell pwd)/$(PYENVLIB)/python2.7/site-packages" >> $(PYENVBIN)/activate
|
||||
( \
|
||||
source $(PYENVBIN)/activate ; \
|
||||
pip install -r requirements.txt ; \
|
||||
)
|
||||
mkdir -p $(PYENVSRC)
|
||||
|
||||
build::
|
||||
rm -rf $(PYENVSRC) && cp -R ./lib/. $(PYENVSRC)/
|
||||
sed -i.bak "s/\$${VERSION}/$(VERSION)/g" $(PYENVSRC)/setup.py && rm $(PYENVSRC)/setup.py.bak
|
||||
( \
|
||||
source $(PYENVBIN)/activate ; \
|
||||
cd $(PYENVSRC) && python setup.py build bdist_wheel --universal ; \
|
||||
)
|
||||
go install -ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
||||
|
||||
lint::
|
||||
( \
|
||||
source $(PYENVBIN)/activate ; \
|
||||
cd $(PYENVSRC) && pylint -E ./pulumi --ignore-patterns '.*_pb2_.*.py' ; \
|
||||
)
|
||||
$(GOMETALINTER) ./cmd/pulumi-language-python/... | sort ; exit $${PIPESTATUS[0]}
|
||||
$(GOMETALINTER) ./pkg/... | sort ; exit $${PIPESTATUS[0]}
|
||||
|
||||
build::
|
||||
cd ./lib/ && $(PYTHON) setup.py clean --all 2>/dev/null
|
||||
rm -rf ./bin/ && cp -R ./lib/. ./bin/
|
||||
sed -i.bak "s/\$${VERSION}/$(VERSION)/g" ./bin/setup.py && rm ./bin/setup.py.bak
|
||||
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}
|
||||
|
||||
install::
|
||||
cd ./bin/ && $(PYTHON) setup.py install --user --force --prefix=
|
||||
cd $(PYENVSRC) && $(PIP) install --user -e .
|
||||
cp ./cmd/pulumi-language-python-exec "$(PULUMI_BIN)"
|
||||
GOBIN=$(PULUMI_BIN) go install \
|
||||
-ldflags "-X github.com/pulumi/pulumi/sdk/python/pkg/version.Version=${VERSION}" ${LANGHOST_PKG}
|
||||
|
|
Loading…
Reference in a new issue