Commit graph

25 commits

Author SHA1 Message Date
joeduffy 162157c1a7 Add a Dockerfile for the Pulumi CLI
This introduces a Dockerfile for the Pulumi CLI. This makes it
easier to develop and test the engine in a self-contained environment,
in addition to being suitable for running the actual CLI itself.

For instance,

    $ docker run pulumi/pulumi -e "PULUMI_ACCESS_TOKEN=x" up

will run the Pulumi program mounted under the /app volume. This will
be used in some upcoming CI/CD scenarios.

This uses multi-stage builds, and Debian Stretch as the base, for
relatively fast and lean build times and resulting images. We are
intentional about restoring dep packages independent of the actual
source code so that we don't end up needlessly re-depping, which can
consume quite a bit of time. After fixing
https://github.com/pulumi/pulumi/issues/1986, we should explore an
Alpine base image option.

I made the decision to keep this image scoped to just the Go builds.
Therefore, none of the actual SDK packages themselves are built, just
the engine, CLI, and language plugins for Node.js, Python, and Go.
It's possible to create a mega-container that has all of these full
environments so that we can rebuild them too, but for now I figured
it was better to rely on package management for them.

Another alternative would have been to install released binaries,
rather than building them. To keep the useful flow for development,
however, I decided to go the build route for now. If we build at the
same hashes, the resulting binaries "should" be ~identical anyhow.

I've created a pulumi/pulumi Docker Hub repo that we can publish this
into. For now, there is no CI publishing of the image.

This fixes pulumi/pulumi#1991.
2018-09-29 11:48:21 -07:00
Thomas Schersach 3224cdfcec Use go env to resolve GOPATH but escape it properly 2018-08-13 10:54:20 -07:00
Thomas Schersach a254c05271 Fix gopath resolution in python makefile dist target 2018-08-13 10:54:20 -07:00
Matt Ellis 84ac039661 Also copy python helper script during make dist
During Code Review, I forgot that for the python language host we need
both the go binary and the -exec script.
2018-08-08 20:51:02 -07:00
Thomas Schersach 62463ab3bc Added dist target for make, will help with Homebrew (#1731)
* Added dist target for make, will help with Homebrew

* Try to install go dependencies before building

* Make sure dep ensure is called before trying to build SDKs

* Removed dep ensure from dist initial step
2018-08-08 13:00:42 -07:00
Matt Ellis 1f638410c7 Include README in pypi package
Use `pandoc` to convert our README.md to a README.rst and then include
that as the long_description in our pypi package.
2018-07-13 18:19:42 -07:00
Sean Gillespie abb0c2769b
Pin to a specific Pipenv version (#1570) 2018-06-25 14:08:56 -07:00
Sean Gillespie 89b052fc6d
Use Pipenv to manage Python environments (#1553)
* Use Pipenv to manage Python environments

* Rename PIPENV_ARGS to PIPENV_PYTHON_VERSION to avoid confusion. Also remove two unused variables
2018-06-21 18:01:23 -07:00
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
Joe Duffy 0d79d2106c
Ensure pip 10.0.0 is installed (#1199)
This change installs pip 10.0.0 in all three places it might come up:

1) Machine-wide packages.

2) User-local packages.

3) In the isolated virtualenv.
2018-04-14 16:43:48 -07:00
Joe Duffy 19e6c9c2bc
Fix Python versions (again) (#1106)
This change actually makes our Python version numbers conformant
to PEP440.  Previously we were including the Git commit hash in the
alpha "version number" part, which is incorrect.  This simply led to
warnings upon publication and installation, but that warning very
clearly states that support for invalid versions will stop at some
point.  This change puts any "informative" parts, like the Git hash,
inside of a local version tag, where such things are permitted.

Also move away from the inline sed silliness so that we can more
easily share this logic across all of our repos.
2018-04-02 10:31:05 -07:00
Joe Duffy 0c308efb1d
Install virtualenv to user packages (#1104)
This installs virtualenv to the user packages site, to insulate us from
permission problems in CI, and also invokes that version.
2018-04-01 18:54:57 -07:00
joeduffy e27ad9eb75 Specify virtualenv>=15.2.0
It appears 15.0.2 generates a bad reference to the pip._install module.
I've tested that 15.2.0 does not so, although I don't really understand
why and when this changed (my current guess is the Travis base image
changed), this should fix pulumi/pulumi#1103.
2018-03-31 16:57:37 -07:00
joeduffy 7162f6ea52 Publish proper pre-release PyPI packages
The semantic versions we were using for pre-release PyPI packages wasn't
quite right.  We had been using local version identifiers, a la +, rather
than proper pre-release tags, which means that version specifications like
`pulumi==0.11.0` will match `0.11.0+dev.1521506136.g7f043fd.dirty`, in
addition to just `0.11.0`.  This is clearly not what we want.

This change moves us over to proper alpha and release candidate versions,
as specified in https://www.python.org/dev/peps/pep-0440/#pre-releases.
Namely, any `x.y.z-dev-123456789-abcdef` version will get translated into
an alpha `x.y.za12345679-abcdef`, and any `x.y.z-rc1` will get translated
into a proper release candidate `x.y.zrc1` version number.
2018-03-19 18:18:25 -07:00
Matt Ellis 5c4a31f692 Adopt new version strategy
Our previous strategy of just using `git describe --tags --dirty` to
compute a version caused issues. The major one was that since version
sort lexigrapically, git's strategy of having a commit count without
leading zeros lead to cases where 0.11.0-dev-9 was "newer than"
0.11.0-dev-10 which is not what you want at all.

With this change, we compute a version by first seeing if the commit
is tagged, and if so, we use that tag. Otherwise, we take the closest
tag and to it append the unix timestamp of the commit and then append
a git hash.

Because we use the commit timestamp, things will sort correctly again.

Part of pulumi/home#174
2018-03-15 18:06:04 -07:00
Joe Duffy 98aaf12cdf
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.
2018-03-09 15:11:37 -08:00
joeduffy 66f3f84d16 Disable Pylint temporarily
This change temporarily disables Pylint.  Assuming it is on the path,
and furthermore that the one on the path runs under 2.7, simply won't
work.  See pulumi/pulumi#1007 for details; it also tracks reenabling.
2018-03-07 09:06:51 -08:00
joeduffy 440ffb27e5 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.
2018-03-06 17:50:42 -08:00
Joe Duffy 9412f4ac7a
Publish Pulumi Python SDK package (#988)
We now publish the Pulumi Python SDK package to our private PyPI
server at the same time we also publish the NPM package.  For now,
we use the test Pulumi.com service, and will switch to staging as
soon as it becomes available.
2018-02-28 18:38:08 -08:00
Luke Hoban ff87af1a44
Workaround for issue with python setup.py (#980)
Pass `--prefix=` to avoid hitting: `error: can't combine user with with prefix/exec_prefix/home or install_(plat)base`.
2018-02-24 17:50:54 -08:00
joeduffy a1c4115fa6 Also setup.py with --user
This ensures we can properly install the built package in Travis's
images, which have everything owned by root by default.
2018-02-24 09:52:30 -08:00
joeduffy 153344354c Pip install to user homedir
This change passes --user to pip install, so that it installs packages
underneath the home directory.  This is required because, except for the
"python" image in Travis, all Python and Pip-related directories are
root-owned.  The --user approach avoids needing to sudo all over the place.
2018-02-24 09:21:16 -08:00
joeduffy a045e2fb1e Implement more of the Python runtime
This change includes a lot more functionality.  Enough to actually
run the webserver-py example through previews, updates, and destroys!

* Actually wire up the gRPC connections to the engine/monitor.

* Move the Node.js and Python generated Protobuf/gRPC files underneath
  the actual SDK directories to simplify this generally.  No more
  copying during `make` and, in fact, this was required to give a smoother
  experience with good packages/modules for the Python's SDK development.

* Build the Python egg during `make build`.

* Add support for program stacks.  Just like with the Node.js runtime,
  we will auto-parent any resources without explicit parents to a single
  top-level resource component.

* Add support for component resource output properties.

* Add get_project() and get_stack() functions for retrieving the current
  project and stack names.

* Properly use UNKNOWN sentinels.

* Add a set_outputs() function on Resource.  This is defined by the
  code-generator and allows custom logic for output property setting.
  This is cleaner than the way we do this in Node.js, and gives us a
  way to ensure that output properties are "real" properties, complete
  with member documentation.  This also gives us a hook to perform
  name demangling, which the code-generator typically controls anyway.

* Add package dependencies to setuptools.py and requirements.txt.
2018-02-24 08:58:34 -08:00
joeduffy 74563afdc8 Get the empty Python program working
This change gets enough of the Python SDK up and running that the
empty Python program will work.  Mostly just scaffolding, but the
basic structure is now in place.  The primary remaining work is to
wire up resource creation to the gRPC interfaces.

In summary:

* The basic structure is as follows:

    - Everything goes into sdk/python/.

    - sdk/python/cmd/pulumi-langhost-python is a Go language host
      that simply knows how to spawn Python processes to run out
      entrypoint in response to requests by the engine.

    - sdk/python/cmd/pulumi-langhost-python-exec is a little Python
      shim that is invoked by the language host to run Python programs,
      and is responsible for setting up the minimal goo before we can
      do so (RPC connections and the like).

    - sdk/python/lib/ contains a Python Pip package suitable for PyPi.

    - In there, we have two packages: the root pulumi package that
      contains all of the basic Pulumi programming model abstractions,
      and pulumi.runtime, which contains the implementation of
      resource registration, RPC interfacing with the engine, and so on.

* Add logic in our test framework to conditionalize on the language
  type and react accordingly.  This will allow us to skip Yarn for
  Python projects and eventually run Pip if there's a requirements.txt.

* Created the basic project structure, including all of the usual
  Make targets for installing into the proper places.

* Building also runs Pylint and we are clean.

There are a few other minor things in here:

* Add an "empty" test for both Node.js and Python.  These pass.

* Fix an existing bug in plugin shutdown logic.  At some point, we
  started waiting for stderr/stdout to flush before shutting down
  the plugin; but if certain failures happen "early" during the
  plugin launch process, these channels will never get initialized
  and so waiting for them deadlocks.

* Recently we seem to have added logic to delete test temp
  directories  if a failure happened during initialization of said
  temp directories.  This is unfortunate, because you often need to
  look at the temp directory to see what failed.  We already clean
  them up elsewhere after the full test completes successfully, so
  I don't think we need to be doing this, and I've removed it.

Still many loose ends (config, resources, etc), but it's a start!
2018-02-23 19:33:02 -08:00
joeduffy d9a143c8a1 Implement the Python langhost RPC server
This change adds a basic Python langhost RPC server.  It's fairly
barebones and merely acts as a jumping off point for the Pulumi engine
to spawn a Python program.  The host is written in Go, in contrast to
implementing the host in Python, and more closely resembles how I
expect the Node.js language host to work once pulumi/pulumi#331 is done.
2018-02-23 19:33:02 -08:00