According to what I could find in the documentation poetry will only install into a virtualenv in all cases.
If already operating inside one, it will install into it.
If outside of one, it will create one for you and install into that.
In general it is of course good practice to work inside of a virtualenv, but unfortunatly this behavior is making packaging for deployment more awkward than I think is needed.
When packaging a project into one or more docker containers, each of those containers has a single responsibility, with no danger of conflicting packages or polluting of the global environment. As such how I've seen contairerization work the dependencies are installed globally within the container.
I'm pretty sure I could build a hack to get around this using multi-stage builds and copying the dependencies from the virtualenv into the global installation, but that feels very fragile, and liklely not the correct decision.
I enjoy the experience of using poetry, so I hope that such a feature could be added (or perhaps pointed out to me, if it does in fact already exist and I'm just missing it)
What you want to use is the settings.virtualenvs.create setting and set it to false:
poetry config settings.virtualenvs.create false
This way Poetry will not automatically create a virtualenv.
Thank you for the help!
I'd like to suggest re-opening this, with the idea of allowing poetry to support a global python installation in general.
I have a variety of global tools (e.g. poetry, jupyter, a custom CLI tool, etc) and being global it's kind of a pain to mange their dependencies.
What would be amazing is using poetry as a global dependency management, without having to have a custom project location and toggling poetry config settings.virtualenvs.create.
I'm thinking having a pyproject.toml file kept in ~/.poetry or %LOCALAPPDATA%/poetry, and then having a flag:
poetry add -g <package>
Basically the same way NPM allows for global package installs.
@Pluckerpluck
Poetry and your own project might have conflicting dependencies. To avoid that, you should install poetry in its own virtualenv.
That being said, if by global you mean the python installation of your operating system on e.g. linux then I would definitely suggest not to install things without using your package manager. If you do, things might be working for some time, but someday, months from now, they will break and you will be scratching your head trying to understand what the problem is.
So, if you need "global" python applications that cannot be found upstream on your distro, you could try to install them using something like pipx: https://github.com/pipxproject/pipx
That being said, if by global you mean the python installation of your operating system
To clarify, I did.
That being said, if by global you mean the python installation of your operating system on e.g. linux then I would definitely suggest not to install things without using your package manager.
I'm on Windows, hence the desire here.
you could try to install them using something like pipx: https://github.com/pipxproject/pipx
It looks like this is the solution to my problem. Thanks for this.
Thanks, @sdispater, but now the another setting works
poetry config virtualenvs.create false
Most helpful comment
What you want to use is the
settings.virtualenvs.createsetting and set it tofalse:This way Poetry will not automatically create a virtualenv.