https://pulumi.com logo
Title
r

rhythmic-sunset-53997

01/06/2023, 10:45 AM
Hi, a quick question about project configuration. How can I define a global path for the Python
virtualenv
option? My aim is for the project config to be • usable by anyone (so there cannot be an absolute path like
/Users/myname/foo
), and • the same
virtualenv
to be used by multiple Pulumi projects (I do not want to install the full 1.5-GB venv for every single project) The following would work, but sadly
~
does not get expanded to the home directory, so the virtualenv is created under
/Users/myname/path/project/~/.pulumi/venv
runtime:
  name: python
  options:
    virtualenv: ~/.pulumi/venv
Another option would be to define this via an environment variable, but I have not found any documentation on how that would be possible.
d

dry-keyboard-94795

01/06/2023, 10:55 AM
If all the projects are in the same repo, you can have the virtualenv reference a parent directory (
../.venv
)
r

rhythmic-sunset-53997

01/06/2023, 10:56 AM
Thanks for the suggestion, but they are not - they are in individual repos that may or may not be cloned to the same parent directory - that’s up to each team member.
d

dry-keyboard-94795

01/06/2023, 11:07 AM
hmm. I vaguely remember using the
PULUMI_PYTHON_CMD
envvar in the past to work around a venv issue, it should let you point to the python binary in the venv itself
symlinks may also work
r

rhythmic-sunset-53997

01/06/2023, 11:27 AM
Thanks, the
PULUMI_PYTHON_CMD
option works, but is mutually exclusive with the use of
virtualenv
. When both are defined, first venv is created and then the path in
PULUMI_PYTHON_CMD
is appended to the
virtualenv
path (even though it’s an absolute path):
error: failed to discover plugin requirements: calling `python -m pip list -v --format json`: fork/exec /Users/name/work/ci/infra/microk8s/venv/bin/Users/name/pulumi-venv/bin/python3.9: no such file or directory
so this is an option, but then one has to manage the virtualenv themselves without pulumi creating it for them if it does not yet exist. Symlinks seem to work. A little of extra hassle, but that’s manageable, thanks