-
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
Install and use dependencies automatically for new Python projects #4775
Conversation
59766a7
to
da406fb
Compare
args := []string{host.ServerAddr()} | ||
for k, v := range options { | ||
args = append(args, fmt.Sprintf("-%s=%v", k, v)) | ||
} |
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.
To make this work for dynamic providers in Python, I needed some way to pass the virtualenv
runtime option to the pulumi-resource-pulumi-python
provider plugin. This change passes along all runtime options as command line flags to providers. Are we OK doing this? (I looked and all our providers should be able to handle the additional command line flags; they'll be ignored). Should we prefix these flag names with runtime-
or something else to make it more clear where these are coming from?
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.
Environment variables seem like a safer option here--have you given those a try?
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.
Environment variables should be able to work for this. I can update the PR to pass them as PULUMI_RUNTIME_<OPTION>
.
Note that this does mean the provider plugins would be receiving these values differently than the language and analyzer plugins, which receive them as command line flags.
Automatically create a virtual environment and install dependencies with `pulumi new` and `pulumi policy new`.
da406fb
to
b02b513
Compare
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.
Structure looks good overall. Just one comment re: the use of envvars vs. command line args.
Rather than via command line args.
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.
🎉
Lots of docs and examples we'll want to update once we roll this out. In particular would be great to make sure we document the flag itself in https://www.pulumi.com/docs/intro/languages/python/ so we have a canonical reference to point to around this setting.
Automatically create a virtual environment and install dependencies in it with
pulumi new
andpulumi policy new
for Python templates.This will save a new
virtualenv
runtime option inPulumi.yaml
(PulumiPolicy.yaml
for policy packs):virtualenv
is the path to a virtual environment that Pulumi will use when runningpython
commands.Existing projects are unaffected and can opt-in to using this by setting
virtualenv
, otherwise, they'll continue to work as-is.Commits in this PR:
virtualenv
runtime option withpulumi new
andpulumi policy new
Fixes #4645
When Luke and I chatted about this a while back, he was wondering how we could make it easy to use for existing projects that don't already have the virtual environment created (e.g. git clone examples repo and trying to get started with an example). As a separate change, I think we should consider an additional CLI command or gesture to make this easier. Something like
pulumi stack prepare
orpulumi install
that would "prepare a project". Or potentially havepulumi stack init
prompt to create the virtual environment and install dependencies automatically (if interactive). Opened #4777 to track this.