bumpy-noon-80834
10/06/2022, 10:21 AMimport pulumi
, and it fails with: ImportError: cannot import name 'cygrpc' from 'grpc._cython'
.
However, I can import pulumi
without any issue when I provision a shell with ./pants repl ::
.
In this case, cygrpc is imported from ~/.cache/pants/named_caches/pex_root/installed_wheels/b821403907e865e8377af3eee62f0cb233ea2369ba0fcdce9505ca5bfaf4eeb3/grpcio-1.47.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl/grpc/_cython/cygrpc.cpython-39-x86_64-linux-gnu.so
I'll try to write a standalone Pulumi program and run it as a PEX. But that's sub-optimal as I'd loose a lot of Pulumi's tooling.
Any suggestion?bumpy-noon-80834
10/06/2022, 12:31 PM$ tree -I __pycache__
.
├── Pulumi.develop.yaml
├── Pulumi.yaml
└── src
└── infrastructure
├── BUILD
└── __main__.py
$ cat Pulumi.yaml
name: infrastructure
main: src/infrastructure
runtime:
name: python
options:
virtualenv: ../../dist/export/python/virtualenvs/python-default/3.9.14
$ cat src/infrastructure/BUILD
python_sources()
python_requirement(
name = "pulumi",
requirements = ["pulumi>=3.0.0,<4.0.0"],
)
python_requirement(
name = "pulumi-aws",
requirements = ["pulumi-aws>=5.0.0,<6.0.0"],
)
$ cd ../.. && ./pants export :: && cd -
$ pulumi up
Said another way:
1. Declare Pulumi as a dependency
2. Export the virtualenv
3. Reference it in Pulumi.yamlhappy-kitchen-89482
10/06/2022, 3:02 PMWell, I tried to manually set PYTHONPATH to the exported virtualenvI wouldn’t expect this to work. A virtualenv needs to be activated, you can’t manually set PYTHONPATH to it.
happy-kitchen-89482
10/06/2022, 3:04 PMhappy-kitchen-89482
10/06/2022, 3:04 PMpex_binary
with pulumi’s entry point as its entry point, did you try that?bumpy-noon-80834
10/06/2022, 3:06 PMpulumi
command is not (AFAIK) installable as a PyPI package. It's a go binary, installed somewhere else on my system. It then forks and load a Python interpreter using that venv. (Pulumi supports multiple languages)happy-kitchen-89482
10/06/2022, 3:09 PMhappy-kitchen-89482
10/06/2022, 3:10 PMhappy-kitchen-89482
10/06/2022, 3:10 PMbumpy-noon-80834
10/06/2022, 3:11 PMbumpy-noon-80834
10/06/2022, 3:13 PMbumpy-noon-80834
10/06/2022, 3:16 PMhappy-kitchen-89482
10/06/2022, 3:41 PMhappy-kitchen-89482
10/06/2022, 3:41 PMbumpy-noon-80834
10/06/2022, 3:42 PMbumpy-noon-80834
10/06/2022, 3:44 PMhappy-kitchen-89482
10/06/2022, 3:46 PMhappy-kitchen-89482
10/06/2022, 3:47 PMhappy-kitchen-89482
10/06/2022, 3:47 PMbumpy-noon-80834
10/06/2022, 3:49 PMPYTHONPATH=$(pwd)/src pulumi pre
to make the "pulumi program" available to the Python interprer spawned by Pulumibumpy-noon-80834
10/06/2022, 3:50 PMbumpy-noon-80834
10/06/2022, 3:50 PMhappy-kitchen-89482
10/06/2022, 7:38 PMbumpy-noon-80834
10/06/2022, 7:40 PMfaint-businessperson-86903
10/07/2022, 5:55 PMPULUMI_PYTHON_CMD
environment variable to the path of the python executable you want to use. This can be a pex without an entrypoint (run as an interpreter), or the interpreter of a virtual environment (e.g. env/bin/python
).faint-businessperson-86903
10/07/2022, 5:56 PMfaint-businessperson-86903
10/07/2022, 6:01 PMbumpy-noon-80834
10/07/2022, 8:41 PM