-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Option to create virtual environments in the project root (.venv) #108
Comments
Alternatively, an option in |
I might add a setting that can be set via the The only downside to that is that you can only have one virtualenv by project. |
@jacebrowning isn't there a config option already? https://github.com/sdispater/poetry/blob/87c4aaf9cadbbb6c5657101d715b5a4e1a8d9a05/poetry/utils/venv.py#L64 |
@buriy How might I use that? I'm having trouble understanding the documentation here:
|
@jacebrowning I guess if you manually create the config.toml file, it would work, but there's no CLI support for that right now. Please, could you try if that works? |
@buriy @jacebrowning This setting is here to tell poetry where to create every virtualenv so it wouldn't work for this use case. That's why I am thinking of adding a new setting to tell poetry to create the virtualenv for the current project inside the |
Having a |
Just wanted to point out the similarity to the approach Rust's package manager |
Python packages can/have to support both python2 and python3, whereas you rarely need multiple rust versions to compile with. Something along these lines in the [tool.poetry.virtualenvs]
venv = { python = "~2.7" }
venv3 = { python = "^3.5" } |
@kelseasy I just thought it would be fun to share this: https://pythonclock.org/ |
Usually tox is used if you need to test several versions, and I haven't
seen anybody who needs to have several venvs for a reason other than that.
Only for upgrade maybe but then you can set up 2 project folders, each with
its venv.
Support for several venvs is ok, but if having only one venv simplifies
things greatly, and doesn't hurt anyone, why not introducing this limit?
ср, 23 мая 2018, 5:07 Kelsey Z <notifications@github.com>:
… python packages can/have to support both python2 and python3, whereas you
rarely need multiple rust versions to compile with.
Something along these lines in the pyproject.toml being used to create
venvs could go a long way:
[tool.poetry.virtualenvs].venv = { python = "~2.7" }.venv3 = { python = "^3.5" }
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#108 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABShBuar33_GQtedJC73OtlNG3yLAyfks5t1IwPgaJpZM4UAPUe>
.
|
The new poetry config settings.virtualenvs.in-project true |
This is great - glad to be able to set this. Question though - does it make more sense for local .venv to be the default ? This is the first thing I changed when I started using pipenv - since it also wants to create the venv under user settings. More than likely - I'm missing some fundamental reason that using user settings is a better option - but arguments for defaulting to local .venv might be :
|
Sorry for commenting on an old issue, but is there a way to set this option for a project (in |
I noticed in v1 beta it only works without the |
@Cito, you mean |
@bangseongbeom Yes, sorry, corrected that already. |
If you had a project created using virtualenvs.in-project=false, and then subsequently set the config setting to true, is there any way to get poetry to copy the venv contents from its prior venv location to the "new" location? |
@jwiede yes you can. Just do the following: $ poetry env list Find the name of the virtual environment you currently have. $ poetry env remove This will delete the Venv. Now just do poetry install and it will work out. |
It would be nice if this was the default so you don't end up with zombie environments when you delete a project's folder. |
I've read numerous issues for both poetry and pipenv about placing the venv in the project directory by default and cannot recall a single reason why that is a bad idea. |
@joshfriend One disadvantage is that you can easily create monster size backups with the ".venv" und "node_modules" sub-directories of all your various projects, which is completely unnecessary because you can easily recreate them. It took me quite a while to find a backup program that allows to generally ignore sub-directories with certain names, and not just a list of fixed paths or files with certain extensions. If the ".venv"s are all in a central place, you can more easily exclude them from backups. |
@joshfriend This is a good use case for global directory feature but not a reason why it should be the default. I think 90% or more of the users would benefit with the more transparent and maintainable local strategy. The local |
@sdispater local (in-project) by default would be an amazing feature for |
1.0 has already been released 😄 I'm glad @Cito mentioned the backups reason, personally I don't mind having 100 venvs in my backups, but thats not true for everyone ;) I still don't think thats a good enough reason to keep in-project |
@joshfriend to be clear about that - I also like to have my |
Local |
With poetry > 1.0.0, the command to set in-project venv is: poetry config --local virtualenvs.in-project true |
And VSCode
|
There is also the problem that shared configuration in VSCode does not really work without local envs. |
Why not using a $ variable ? |
I'm surprised that the
This produces a local
|
I've been reading and commenting on threads like this both in Poetry and Pipenv for well over 2 years now and it seems pretty clear to me that the most beneficial default is having The remaining users have a few (valid) edge cases that they care about which I'm fairly certain make up the minority:
I don't think either is difficult to work around, and I think the benefits of compatibility with PyCharm/VSCode/etc should carry more weight in the decision of what should be the default. Further, to what @b-long is saying above me, I knew exactly what I wanted poetry to do for me and I still found it difficult to find the CLI command to set that flag or write it manually in
|
But does that the path configuration works too? Because it seems to be ignored. |
The setting has now changed to: poetry config virtualenvs.in-project true |
could be useful for enabling it exclusively in a project. For example you may want to use a formatter installed with dev dependency in settings.json in vscode as in
|
* Fix for including modules from different locations When we define multiple packages from different source locations, Poetry currently only uses the last specified from= location. This patch adds explicit paths to package_dir for additional packages. This fixes python-poetry#1811, fixes python-poetry#2354, and possibly even python-poetry#2450. * Test the fix for including modules from different locations When we try to include moduleA from libA and moduleB from libB then package_dir in the generated setup.py must to contain either one or both `"moduleA": "libA/moduleA"` or `"moduleB": "libB/moduleB"` so we are able to find both modules when building the source dist. `ns["package_dir"].keys() == {"", "module_b"}` should always be true, so we don't have to test for module_a in `ns["package_dir"]`.
This is the thing everyone needs. |
is it possible to set this configuration in
|
It is set in |
I Have set this in |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm considering migrating some of my projects from
pipenv
topoetry
. I would like to be able to tellpoetry
to create virtual environments at./.venv/
to supportMakefile
target dependencies, CI build caching, and automatic IDE support.I added a feature to
pipenv
to detect and use virtual environments located at./.venv/
based on the mere presence of a directory of that name. It looks likepoetry
nearly has the same behavior:https://github.com/sdispater/poetry/blob/87c4aaf9cadbbb6c5657101d715b5a4e1a8d9a05/poetry/utils/venv.py#L55-L59
but I noticed that if
.venv
is an empty directory (in order to let the tool populate it)poetry
seems to install dependencies into my global Python instead.Would you consider a PR to add another case to this logic to create virtual environments in the root of a project? This should allow
poetry
to handle all of the following scenarios:$VIRTUAL_ENV
set)./.venv/<bin>/python
exists)./.venv/
is empty)The text was updated successfully, but these errors were encountered: