Closed ryaminal closed 2 years ago
Seems like a reasonable change. I'll test this out locally for a few days before merging it in as has the potential to break at lot.
Could you also add a test case for this change?
I would also suggest you reach out to the poetry devs about the slow command speed in case there is anything they can do to improve it :)
I've added a test and it runs on my machine but not circleci, so I'll try and figure that out.
I also wonder if this is something that should be used for pipenv as well.
Maybe something is mucked up with my machine/env or something, but pipenv takes ~98ms to run PIPENV_IGNORE_VIRTUALENVS=1 pipenv --venv
and poetry take ~600ms to run poetry env list --full-path
. This is an expensive/annoying delay every time I run a command in an autoswitchable directory.
Had to install poetry for the unit test to pass. Adds 3s to install poetry, but hopefully doesn't cause any other headache.
Closing because #160 is a better and less-risky solution.
I was frustrated with why on almost every command I do in a poetry project(ls, exa, vi a file then exit) there is a large time penalty.
I put in some basic time measurement around the
poetry env list
command and it was, on average, taking 600ms. This was quite frustrating. I'm not certain why it's so slow but it is.This change adds the use of the
VIRTUAL_ENV
environment variable if it exists else it usingpoetry env list
.VIRTUAL_ENV
isn't there until the first call toactivate
so we have to pay thepoetry env list
penalty at least once.VIRTUAL_ENV
is also checked in the_maybeworkon
call, and the_activate_poetry
call is only used to indicate if a message might be printed and if the_default_env
should be used. Perhaps a better change would be to have_maybeworkon
return a value that can be used to indicate ifmkvenv
should be run or something.