-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GetRequiredPlugins for Python #5787
Conversation
Diff for pulumi-random with merge commit 43610a1 |
Diff for pulumi-azuread with merge commit 43610a1 |
Diff for pulumi-kubernetes with merge commit 43610a1 |
Diff for pulumi-gcp with merge commit 43610a1 |
Diff for pulumi-azure with merge commit 43610a1 |
Diff for pulumi-aws with merge commit 43610a1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is similar to information included in package.json for Node.js and version.txt in .NET NuGet packages (though, version.txt does not currently support specifying a server).
Should we be considering this as a standard format to use across these different language ecosystems?
8523331
to
002a228
Compare
We certainly could consider it.
|
I guess I wonder if we should at least standardize on the JSON payload that we include inside the package.json, so that we have a consistent data model for this, even if it lives in different places for different package managers. Probably not a huge deal - but it feels like consistency here will help avoid capability drift between language ecosystems. |
002a228
to
6f968aa
Compare
Implement GetRequiredPlugins for Python, which determines the plugins required by the program. Also, if the `virtualenv` runtime option is set, and the specified virtual directory is missing or empty, automatically create it and install dependencies into it.
This is a new optional file that can be generated and included in a python package that provides information about a Pulumi plugin (resource, name, version, server) associated with the package. When this file isn't present, the plugin name and version are determined from the package name and version (if possible). If the package is an alpha/beta/rc/dev release, then the plugin version cannot be determined without it being provided in this file. Also, the server cannot be determined without this file. (If not present, the default server is used.)
6f968aa
to
4fccb93
Compare
I went ahead and did this. I defined a common |
Diff for pulumi-random with merge commit 552a8d9 |
Diff for pulumi-azuread with merge commit 552a8d9 |
Diff for pulumi-kubernetes with merge commit 552a8d9 |
Diff for pulumi-gcp with merge commit 552a8d9 |
Diff for pulumi-azure with merge commit 552a8d9 |
Diff for pulumi-aws with merge commit 552a8d9 |
Diff for pulumi-azuread with merge commit 160dd40 |
Diff for pulumi-random with merge commit 160dd40 |
Diff for pulumi-kubernetes with merge commit 160dd40 |
Diff for pulumi-gcp with merge commit 160dd40 |
Diff for pulumi-azure with merge commit 160dd40 |
Diff for pulumi-aws with merge commit 160dd40 |
This PR implements
GetRequiredPlugins
for Python, which is called by the engine at the beginning ofpulumi preview|up
to determine/install any missing plugins needed by the program.This is implemented by running
python -m pip list --format json
to determine the installed Pulumi packages (packages with names that start withpulumi-
). If thevirtualenv
runtime option is set inPulumi.yaml
, it runs thepython
inside the virtual environment. Otherwise, it callspython
in the usual ways, which works with other tools that manage their own virtual environment (such aspoetry run pulumi up
).The required plugins are determined based on the Pulumi packages. If a package contains an optional
pulumiplugin.json
file, the information in this file is used to determine the associated plugin: thename
,version
, andserver
. There's also aresource
option that must be set totrue
to indicate this package has an associated plugin, orfalse
to indicate the package does not have an associated plugin (e.g. I'd imagine we'd set this tofalse
forpulumi-policy
, in the meantime we hardcode this package as a known package that does not have a plugin). This file is similar to information included inpackage.json
for Node.js andversion.txt
in .NET NuGet packages (though,version.txt
does not currently support specifying aserver
). If thepulumiplugin.json
file doesn't exist, we attempt to determine the plugin name and version based on the package name and version. This works well for all released packages we have today (which don't have apulumiplugin.json
yet), but does not work for alpha/beta/rc/dev builds of these packages because the package version does not include enough information to determine the plugin version for these cases. A commit is included with this PR, which adds support for generating thepulumiplugin.json
file for packages (via a new schema option). I suspect we'll want to roll this out for all our packages, soGetRequiredPlugins
will work for dev builds.This PR also implements support for automatically creating the virtual environment and installing dependencies into it at the beginning of
pulumi preview|up
if thevirtualenv
option is set inPulumi.yaml
and the specified directory is missing or empty.I'd love to add more automated testing around this, but may have to do that as a follow-up item (I don't believe we have much automated testing around similar functionality for the other languages).
Fixes #4848
Fixes #5164
Fixes #5593