I've been deleting my venv each time i want to cha...
# python
b
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
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
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
both of them are, since they manage your venv behind the scenes
it's about trade-offs
b
poetry shell mode seems elegant
I'm using that now with type checking integrated into poetry
a
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
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
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
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