Poetry: Poetry doesn't appear to work with pyenv-virtualenv

Created on 27 Apr 2019  路  7Comments  路  Source: python-poetry/poetry

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have searched the documentation and believe that my question is not covered.

Question


The documentation says:

When you execute the install command (or any other "install" commands like add or remove), Poetry will check if it's currently inside a virtualenv and, if not, will use an existing one or create a brand new one for you to always work isolated from your global Python installation.

I took this to mean that if I had set up a pyenv virtualenv for my project, and was in that virtualenv (usually via a .python-version file in the root of the project) that poetry would use that virtualenv for installing dependencies. This doesn't appear to be the case, though, as when I run poetry install it creates a new virtualenv in ~/Library/Caches/pypoetry/virtualenvs.

After running poetry install if I run pip freeze I don't see the packages that poetry has installed. I would rather have the libraries and commands installed with my dependencies be available in the active pyenv-virtualenv rather than having to prefix everything with poetry run.

Most helpful comment

@diefans If you have nothing constructive to add, please refrain from commenting. You are criticizing something that is given to you for free, maintained by a group of volunteers that do it on their free time, so the least you can do is being considerate of their time and effort. If Poetry no longer fits your workflow, feel free to use something else. I mean it because I know that sometimes Poetry might not cover some use cases that people are really attached to.

Now, that being said, I use Poetry with pyenv and pyenv-virtualenv myself without any issue so either there is something wrong with you configuration or there is indeed a bug.

For information, I have in my .zshrc the following lines:

if [[ -z "$VIRTUAL_ENV" ]]; then
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi

Normally, pyenv-virtualenv should set the VIRTUAL_ENVenvironment variable that is used by Poetry to detect if it's currently inside a virtualenv. If it's not set, there must be something wrong with your configuration.

All 7 comments

Poetry started quite interesting, with sane dependency and locking feature. But suddenly it evolved into a one-fits-all-monster trying to be smart on virtualenvs.

I use pyenv for a good reason since years. The missing part was just a tool like poetry in its beginnings.

Now it hijacks my virtualenv concept and how I run scripts... You guys should focus on doing your business!
See your amount of issues and open PRs? You will never fix it again, just by blowing up your focus...

@diefans If you have nothing constructive to add, please refrain from commenting. You are criticizing something that is given to you for free, maintained by a group of volunteers that do it on their free time, so the least you can do is being considerate of their time and effort. If Poetry no longer fits your workflow, feel free to use something else. I mean it because I know that sometimes Poetry might not cover some use cases that people are really attached to.

Now, that being said, I use Poetry with pyenv and pyenv-virtualenv myself without any issue so either there is something wrong with you configuration or there is indeed a bug.

For information, I have in my .zshrc the following lines:

if [[ -z "$VIRTUAL_ENV" ]]; then
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi

Normally, pyenv-virtualenv should set the VIRTUAL_ENVenvironment variable that is used by Poetry to detect if it's currently inside a virtualenv. If it's not set, there must be something wrong with your configuration.

Something I just noticed looking into this: I've got a bunch of projects that locally use multiple virtualenvs. In that context, the VIRTUAL_ENV variable isn't set, while if there's just one, it is set.

I was using multiple virtualenvs because I develop mostly in Python 3, but I'm a mercurial holdout. But, I recently installed pyenv-implicit because some other tooling was interacting badly with pyenv-virtualenv, and I think that means I don't need to explicitly include the mercurial virtualenv any more.

I don't know if pyenv-virtualenv "should" populate that environment variable under all circumstances, but apparently it doesn't.

(EDIT: I have discovered issues with the above solution to my issue that don't involve Poetry, and so are outside the scope of this repo. pyenv-implicit may or may not work for a given configuration, but it's always possible to be explicit, so might as well try, if, like me, you were using multiple local virtualenvs.)

@sdispater I know what open source is. My constructive argument is - since you are nearly the only driver of this project and your time is limited: KISS.

Your project got a lot of traction, but as you might have noticed there are even multiple PRs fixing the same issue. So I would ask myself if there are 6.7k stars, 452 open issues and 89 open PRs where people voluntarily spend their time helping you... why are they not recognized?

@diefans

My constructive argument is - since you are nearly the only driver of this project and your time is limited: KISS.

And I already do. I rejected a lot of feature requests because they did not align with the vision I have for Poetry. I know exactly what I want Poetry to be.

So I would ask myself if there are 6.7k stars, 452 open issues and 89 open PRs where people voluntarily spend their time helping you... why are they not recognized?

They are recognized but my time and the time of the other collaborators is limited and doing code reviews takes time as well as going over a backlog of 400+ issues. I regularly go back to the oldest issues to see if they are still relevant and close or classify appropriately.

@sdispater (my last comment on this)

they did not align with the vision I have for Poetry. I know exactly what I want Poetry to be.

So it would be sane to communicate this vision, to not distract or even disappoint your valuable contributors, since basically this "mismatch in vision" is just wasting energy...

@mwchase I'm assuming the multiple virtualenvs is in order to use scripts installed by a package while keeping other environments separate. You might look into pipx. I've been using pipx for a while now for managing things such as awscli and aws-utilities and it uses a virtualenv for each while abstracting it away so you don't have to deal directly with the virtualenvs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbarlow83 picture jbarlow83  路  3Comments

probablykasper picture probablykasper  路  3Comments

sobolevn picture sobolevn  路  3Comments

mozartilize picture mozartilize  路  3Comments

ghost picture ghost  路  3Comments