Install dependencies from poetry to separated venv

Here is a short description on how to install all dependencies from project that uses poetry to a separated virtual environment. Even though it might seem straighforward, I spent quite a bit of time figuring it out.  Maybe it was due to my current setup that is Windows 10, Pycharm, gitBash, Docker, Poetry.

The initial problem was that I wanted to run test using pytest locally just with a simple command pytest file.py. We normally have all the testing setup wrapped in docker-compse and tests are run using makefile that delegates to docker-compose which in some cases is taking too much time and so pytest file.py  is much better. But of course there needs to be all the dependencies otherwise the pytest command will fail.

So, creating a venv and installing all the libs in there was the option for me. But I got plenty of errors, sometimes gitBash stoped working after venv was activated, or Docker got confused when copying venv files etc.

Finally I made it work. Here are the exact steps that I followed:

0] in Pycharm, File > Settings > Terminal uncheck Activate virtualenv

1] install virtualenv (pip install virtualenv)

2] create virtualenv possiblly ouside of the current project to avoid Docker confusion (python -m virtualenv venv)

3] activate virtualenv (source venv/Scripts/activate)

4] install poetry to venv (pip install poetry)

5] go back to project where poetry lock file is presented and install all the libs with the command poetry install

Now ale can be used locally in venv