incalculable-ambulance-59583
11/14/2023, 5:32 AMrun_shell_command
. I don't want to rely on someones year old code and it seems that run_shell_command
doesn't do what I thought.
What I Tried
Here's what I have:
1. I exported the dependencies to a virtualenv
2. I have an infra folder with a Pulumi.yaml
that has virtualenv: ../dist/export/python/virtualenvs/python-default/3.11.4
3. At this point if I run pulumi up
I get this error `error: failed to discover plugin requirements: calling `python -m pip list -v --format json`: exit status 1`
4. I tried getting into an ipython repl and using !pulumi up
only to get the same error
5. So I tried to add a run_shell_command
that looks as follow:
# in infra/BUILD
run_shell_command(
command="pulumi",
execution_dependencies=[":infra"],
runnable_dependencies=["/home/me/.pulumi/bin/pulumi"],
)
At this point I can't run the shell command. Running pants run
lets me know that there are no runnable targets. Using pants peek infra:infra
gives me this error `InvalidSpecPathError: Invalid address /home/me/.pulumi/bin/pulumi
from the runnable_dependencies
field from the target infra:infra. It has an un-normalized path part: `""``.
The Questions
1. I don't have a high tolerance for a complicated or brittle solution. Should I just separate this part out and use poetry/etc to manage it?
2. If not, what am I missing to get this to work?
3. I noticed that it doesn't seem that there's an equivalent to poetry run
or poetry shell
. Why not?careful-address-89803
11/14/2023, 6:15 AMrun_shell_command
, the PATH is inherited, since it's a "run"able target. ( runnable_dependenices
is for pants' runnable targets that you want to include.)
run_shell_command(
command="pulumi",
execution_dependencies=[":infra"],
)
^ should workcareful-address-89803
11/14/2023, 6:30 AMpoetry run
, if you want to run python scripts/code in your repo, you can use pants run path/to/file.py
; pants will analyse your source code to determine what 3rd party dependencies your code has, bundle them into a PEX, and run PEX.
You can also export the full venv with pants export --resolve=my-resolve
and source it from "dist/export/python/virtualenvs/"
There's also pants repl
for interactive python sessions. You can specify the code to load as a target and pants will pull in the relevant 3rd party dependencies (ex pants repl src/python/service0::
)incalculable-ambulance-59583
11/14/2023, 4:00 PMpoetry run
and poetry shell
is that they can run any command not just python that's in your repo. So for instance if I'm using vim and have a plugin that checks the current python environment to provide autocompletion pants run
wont help me.incalculable-ambulance-59583
11/14/2023, 4:05 PMrun_shell_command
. I cant see the command with pants peek
and pants run infra:infra
doesn't work. Also moving out to the root dir and using pants run infra/infra:infra
doesn't work either.careful-address-89803
11/23/2023, 7:01 AMpants peek
works on build files, so I think you'd want to use pants peek infra
. You can also see all targets with pants list //::
. If your BUILD file is "infra/BUILD", and your target has the default name, I think the target you want is "infra:infra".