pulumi/sdk/python/Makefile
Sean Gillespie 5cbc979e17
Fix a couple of issues when projecting Protobuf and UNKNOWN in Python (#1468)
* Fix a few issues with the Python language host

1. Fix an issue where the UNKNOWN sentinel was leaking into user
programs
2. Fix an issue where Protobuf types were leaking into user programs

In fixing this issues I also added a framework for writing tests against
the Python SDK.

* License headers, and adopt a more idiomatic testing pattern

* Additional idiomatic Python

* That's what I get for trying to be fancy (Travis CI python version is very old and does not respect this form)

* CR feedback: use more comprehensions, typo fix

* Break a circular dependency between resource, runtime.resource, and runtime.rpc

* Don't check in .vscode

* CR: sort inputs, rename global variable, add a test for CustomResource serialization

* Remove accidental code duplication
2018-06-06 16:09:07 -07:00

51 lines
1.7 KiB
Makefile

PROJECT_NAME := Pulumi Python SDK
LANGHOST_PKG := github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python
VERSION := $(shell ../../scripts/get-py-version)
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 'virtualenv>=15.2.0'
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 --upgrade 'pip>=10.0.0' ; \
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]}
install::
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}
test_fast::
$(PYTHON) -m unittest discover -s lib/test