sparse-intern-71089
10/03/2023, 9:11 AMdry-keyboard-94795
10/03/2023, 9:30 AMruntime.options.virtualenv
specified in Pulumi.yaml
?proud-art-41399
10/03/2023, 9:31 AMoptions
in the path.dry-keyboard-94795
10/03/2023, 9:34 AM./venv/bin/python --version
gives you Python 3.11.x?proud-art-41399
10/03/2023, 9:34 AMdry-keyboard-94795
10/03/2023, 9:37 AMpip
, it's installing the wrong versions, or that pulumi isn't using the venv?proud-art-41399
10/03/2023, 9:40 AMpip
is a Python script which contains a shebang with path to the Python interpreter. When Pulumi is not using the venv
, pip
uses the wrong Python interpreter (on a system path)dry-keyboard-94795
10/03/2023, 9:48 AMsource .venv/bin/activate
(ie, use the venv in current shell), it all works.
But without, pulumi defaults to using the system python env for running and installing.
Can you post the contents of Pulumi.yaml
, can redact anything sensitive?dry-keyboard-94795
10/03/2023, 9:48 AMpip
side, I wasn't aware pulumi did dependency management. Always managed my own venvs 🙂proud-art-41399
10/03/2023, 9:51 AMso if you doYes, exactly.(ie, use the venv in current shell), it all works.source .venv/bin/activate
But without, pulumi defaults to using the system python env for running and installing.That's not exactly what I stated (and hence the question). Pulumi clearly uses the
venv
for installing the dependencies and also interpreting the Pulumi program. It just doesn't switch to the virtualenv. (And thus, when using local.Command
with command like pip install ...
, it uses the pip
on system path instead the one in the virtualenv.)proud-art-41399
10/03/2023, 9:52 AMname: xxx-prod
description: xxx
runtime:
name: python
options:
virtualenv: venv
options:
refresh: always
dry-keyboard-94795
10/03/2023, 10:01 AMproud-art-41399
10/03/2023, 10:07 AMlocal.Command
would most probably run the command in a subprocess... Thanks!dry-keyboard-94795
10/03/2023, 1:15 PMlocal.Command
should use the venv as well.
It's worth raising a feature request.
I've similar problems with passing Google Auth tokens around, and it'd be good to see functionality to remove this kind of boilerplategreat-sunset-355
11/04/2023, 11:20 PMruntime.virtualenv
config at all because I've had multiple projects using the same VENV and just used poetry shell
before I started working.
Nevertheless, I also made a mistake of using pedantic for pulumi.ComponentResource
which resulted in a lot of unnecessary type headaches with outputs.
Apart from that I used ASDF to manage my python installations and sometimes Pulumi just did not register the PATH to python binary correctly 🤷 (perhaps it has to do something with multiple PyCharm windows I had opened)
In the end, I decided to move to TypeScript because it is much easier to express and write for pulumi. Mainly due to required boilerplate of for python classes (this ma be a gamechanger though https://github.com/pulumi/pulumi/issues/11732)
As for lambdas, I find your solution interesting. I settled on dissociating the artifact from pulumi and just give pulumi an S3 path of pre-built package, so that lambda can use any runtime and I can write a more generic/flexible component.