Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP : Change python version at install #82

Closed
wants to merge 5 commits into from
Closed

WIP : Change python version at install #82

wants to merge 5 commits into from

Conversation

jgirardet
Copy link
Contributor

This PR is related to #77

you can choose your python version:
poetry install --python 3.6

It will install the asked python version if present on the system.

Doing this I have to change the virtualenv name to make poetry know where to search.
The new name is project name + a md5 calculated from the path of the project
/path/to/virtualenv/myproject-fzef84z38ef4ze8f4z3e
So the venv can always be found if the project's path doesn't change.

Tests are not yet fully ok.

this doesn't solve the problemeof consistency between the created venv and the python version needed in the pyproject.toml

@sdispater
Copy link
Member

Thanks for taking the time to put this PR together.

Unfortunately, this is not something I want to implement in poetry. The idea is that if you want to use Python 2.7 for your project, you install poetry for the Python 2.7 of your system (ideally installed with pyenv).

@jgirardet
Copy link
Contributor Author

Hi,
I don't really understand where the problem is. If you don't specify anything it will install with the current system python version.
Maybe I'm wrong but I think that the 2 behaviors can exist together.

I think that this PR simplifies much the usage of poetry and makes it more accessible for new users.
I did this PR because I was lost at start using poetry about dealing with different python version.
Why would I use pyenv + poetry where everything can be done with poetry ?

PS: considering poetry is a new (great) thing for new project I'm close to open a Issue asking to drop python2 and let you more time for other things ;-)

thanks for this project anyway

@sdispater
Copy link
Member

The thing is with your changes is that you will only be able to have one virtualenv per project while the current implementation allows you to have one for each Python version you want to test you project with.

And besides, if the Python version you want to use does not exist on your system you will still need to install it so there isn't much to gain here.

@jgirardet
Copy link
Contributor Author

ok I see where you wanna go.
so in a certain way you have to use pyenv.
To be really sure that I understand, you install poetry in all pyenv versions or only in your system ?

@jgirardet
Copy link
Contributor Author

If you run different virtualenv with different python version, how the hashes un pyproject.lock could be ok for all different versions of python ?

@sdispater
Copy link
Member

When poetry is locking the dependencies it is agnostic and, thus, will lock any dependency regardless of its requirements.

However, when installing dependencies it will skip the ones that are not needed.

This is the same thing for hashes, every hashes are put in the lock file to make it it environment independant.

@jgirardet
Copy link
Contributor Author

ok I close this useless work.
But I still argue that the whole thing isn't clear at all for new comers.

so in a nutshell if you want to use different python version with poetry:

  • first you need a third party app to manage the even the python version +/- the virtualenv : for example pyenv.
  • The two different to go :
    • install poetry system wide and use it inside virtuenvs created via pyenv
    • install poetry in each pyenv versions and let poetry create the virtualenv

I think it's clear in your mind but you really should consider it isn't for others, especially for those not aware of thing like pyenv and I don't say for people coming from pipenv.
I saw later you always add an issue #35 about it, then me, another will come.

Maybe you should consider adding something in the doc to explain it more than it is now.

I still don't have you opinion on checking if current python version is compatible with the pyproject.toml #77

Jimmy

@laike9m
Copy link
Contributor

laike9m commented Dec 8, 2018

Thanks for taking the time to put this PR together.

Unfortunately, this is not something I want to implement in poetry. The idea is that if you want to use Python 2.7 for your project, you install poetry for the Python 2.7 of your system (ideally installed with pyenv).

@sdispater Say I'm using Poetry with pyenv-virtualenv, if I understand correctly, the recommended way is to install Poetry for every virtual environment, is that correct?

@sdispater
Copy link
Member

@laike9m Not anymore. If you use the recommended installer Poetry will pickup the currently activated Python version to create virtualenvs, so you only need to install it once.

Also if you are inside an activated virtualenv Poetry will automatically detect it and use it.

@laike9m
Copy link
Contributor

laike9m commented Dec 8, 2018

@sdispater That's really cool. Thanks!

@paranoidi
Copy link

@sdispater That is not a good solution, it will create a virtualenv which is different (and quite possibly incompatible) from what is declared in pyproject.toml

@LucianU
Copy link

LucianU commented Jul 2, 2019

I hit this issue as well. Using the recommended install approach on Mac OS X, I got poetry for Python 2. I discovered that when I tried to add ipython as a dependency of my project.

What happens if I want poetry to handle both projects for Python 2 and 3? Do I need to use pyenv?

dimbleby pushed a commit to dimbleby/poetry that referenced this pull request Apr 21, 2022
Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants