You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to install dependencies to the system site packages #234
It is not always easy to have some packages installed inside the virtualenv + having the virtualenv inside the docker container, which only runs your app, makes no sense.
It would be nice to have an option i.e. --system to deploy your package right inside the system without venv.
Now solving it in a stupid way:
RUN mkdir -p /root/.cache/pypoetry/virtualenvs/phex-recutech-mcs-py3.6/lib/python3.6
RUN ln -sf /usr/local/lib/python3.6/site-packages /root/.cache/pypoetry/virtualenvs/phex-recutech-mcs-py3.6/lib/python3.6
You can disable the automatic creation of virtualenvs by using:
poetry config settings.virtualenvs.create false
Reacted by Joshua Arnott, Antoine Gallix, Martijn Hemeryck, Stig Oskar Ofstad, Dobrovolskyi Bohdan, Aliaksei Urbanski, Sergio García Prado, Andy Zhuang, Na'aman Hirschfeld, Cássio Antoniazzi and 5 more
Reacted by Simion, zeelot and nraw
Reacted by zhukovgreen, Santiago Fraire Willemoes, Michael Wright, Dobrovolskyi Bohdan and Andrew Vaccaro
Reacted by zhukovgreen, Santiago Fraire Willemoes, Dobrovolskyi Bohdan and Andrew Vaccaro
There are some situations when using a virtualenv creates complications. For example a docker container with some global python package. In my case it was compiled from the source freecad. Exposing it to the virtualenv is a headache.
Reacted by Michael Wright, leiserfg, Kay Gosho, Changsheng Wu, Martijn Hemeryck, Kevin Minehart Tenorio, Simion, Marcin Zaremba, Andrew Vaccaro, Philip Couling and 1 more
For those who find here later, the config command worked for me was:
poetry config virtualenvs.create false
Reacted by Pavel, Martijn Hemeryck, Saksham Gautam, Terri Cain, Jonathan Vasquez, Grey-Fox, Chris Arnesen, Hung-I Wang, Panaos Alisandratos, eltonplima and 25 more
I heard you liked virtual environments so I put a virtual environment in your virtual environment so you can isolate while you're isolated.
More seriously: calling this a "misconception" is overstated. There can be contexts where a virtual-env in a docker container is useful but many (and arguably most) of them are the result of an anti-pattern.
The most common anti-pattern to make them useful is breaking the "one app per container" rule. If your container is supposed to just run your python app then the "system" packages should be redundant and just useless files in the image. This redundancy should mean there's no need for a virualenv; you should just be able to clobber the system packages.
Reacted by jonluechen, Gottfried Ganßauge, Roman Steinberg, Jos van Egmond and Chris Knight
The problem with this is that the application is not properly installed as a package. You only install the requirements.
For most applications this is not a problem, but for applications with various entrypoints you might want to install it to the system.
Activity
sdispater commentedon Jun 19, 2018
You can disable the automatic creation of virtualenvs by using:
piotr-dobrogost commentedon Jul 10, 2018
This is common misconception. See Deploying Python Applications with Docker - A Suggestion or Why people create virtualenv in a docker container?.
This is duplicate of issue #218
zhukovgreen commentedon Jul 10, 2018
There are some situations when using a virtualenv creates complications. For example a docker container with some global python package. In my case it was compiled from the source freecad. Exposing it to the virtualenv is a headache.
wyl8899 commentedon Jan 8, 2020
For those who find here later, the config command worked for me was:
dyno commentedon Mar 17, 2021
how about use the export option?
https://python-poetry.org/docs/cli/#export
ci: fix missing `poetry install` in `downstream.yml` workflow (python…
ci: fix poetry installation for downstream
couling commentedon May 12, 2022
I heard you liked virtual environments so I put a virtual environment in your virtual environment so you can isolate while you're isolated.
More seriously: calling this a "misconception" is overstated. There can be contexts where a virtual-env in a docker container is useful but many (and arguably most) of them are the result of an anti-pattern.
The most common anti-pattern to make them useful is breaking the "one app per container" rule. If your container is supposed to just run your python app then the "system" packages should be redundant and just useless files in the image. This redundancy should mean there's no need for a virualenv; you should just be able to clobber the system packages.
clafoutis42 commentedon Feb 24, 2023
The problem with this is that the application is not properly installed as a package. You only install the requirements.
For most applications this is not a problem, but for applications with various entrypoints you might want to install it to the system.
github-actions commentedon Feb 29, 2024
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.