https://pulumi.com logo
#python
Title
# python
b

bright-crayon-39468

03/18/2024, 4:22 AM
I've been deleting my venv each time i want to change a pip dependency version inside Pulumi. Is there a better way to refresh dependencies defined in requirements.txt?
h

hundreds-gpu-71155

03/18/2024, 4:23 PM
ahhh... python dependencies.
Honestly, I would suggest using one of the locking tools. Pipenv, pip-tools, and Poetry are all solid options.
(I'm currently using pipenv, but you should pick what suits your needs and workflow the best)
b

bright-crayon-39468

03/18/2024, 10:32 PM
Yeah you're right-on there! I introduced Poetry in my last project. Can't recall if it fixes this specific issue around caching of Pulumi's venv on changes. I'll fire it up again and see! Thank you for the reminder! 🙂
i remember poetry requires wrapping every pulumi command with
poetry run
is pipenv like that too?
h

hundreds-gpu-71155

03/19/2024, 2:50 PM
both of them are, since they manage your venv behind the scenes
it's about trade-offs
b

bright-crayon-39468

03/19/2024, 10:14 PM
poetry shell mode seems elegant
I'm using that now with type checking integrated into poetry
a

adventurous-butcher-54166

03/29/2024, 11:49 AM
Really recommend setting up
direnv
– either manually or via something via
oh-my-zsh
,
asdf
or something like that which automatically activates a venv if it finds one in the working directory.
h

hundreds-gpu-71155

03/29/2024, 4:52 PM
direnv
is nice venv tool, but it doesn't do any dependency management. you'd need to pair it with one of the above tools (i think both poetry and pipenv have an option to operate on the current venv instead of making their own)
a

adventurous-butcher-54166

03/29/2024, 7:59 PM
Sorry my comment was a bit out of context 🙂 Responding to...
i remember poetry requires wrapping every pulumi command with
poetry run
is pipenv like that too? options:
Acutally there's no need to prefix
pulumi <cmd>
with
poetry run
as long as the venv is activated - which I recommend
direnv
for. Just remove the virtualenv option from
Pulumi.yaml
(which IMO is a bizarre default)
Copy code
options:
     virtualenv: venv
b

bright-crayon-39468

03/30/2024, 11:27 PM
I've been using
poetry shell
to run all my pulumi activities and it seems to interact gracefully with Poetry when changing dependencies there. Haven't had any problems yet, it supports version locking with poetry.lock