Python project management tools: virtual env, pyenv, pip-tools, pipenv, poetry - stream 33

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024

Комментарии • 4

  • @horseinthesky
    @horseinthesky 5 лет назад +3

    Thank you very much for this stream.
    I'm doing python for about 1,5 year now and usually do install all libraries to system python with sudo cuz all these virtual env tools have made a complete mess in my mind.
    Everybody tells me I'm doing really bad things and the fact I haven't broken anything is a fortuity.
    After I watched the stream I've read a lot about these tools and how to use to make a workflow. Not a surprise I was not alone
    github.com/sdispater/poetry/issues/305
    github.com/sdispater/poetry/pull/82
    What I find strange is that poetry creates a venv after poetry install command but not activation it
    I've read the docs poetry.eustace.io/docs/basic-usage/#poetry-and-virtualenvs
    and I'll be very appreciated if you can comment on what I've decided to deal with it:
    1) Install pyenv and poetry globally
    2) Install necessary python with: pyenv install 3.7.1
    3) Create project directory: mkdir test && cd test
    4) then do pyenv local 3.7.1
    5) then create venv by myself with: python3 -m venv .venv,
    6) then activating it with: . .venv/bin/activate
    7) then do poetry init, poetry add and poetry install
    8) working on project
    Is this the workflow you are using or i've missed something?

    • @dmfigol_live_archive
      @dmfigol_live_archive  5 лет назад +1

      1.5) I usually add "poetry config settings.virtualenvs.in-project true" so that poetry creates virtual environments in .venv folder inside the project
      4) I usually switch with "pyenv global", but I think "pyenv local" will achieve the same result in this case
      5) It depends if I am lazy or not. Most of the times I create venv with "python -m venv .venv". I do this, so venv python binary is symlinked to the pyenv python binaries (or system binary). When I am lazy, my virtual environment will be created using "poetry install" after "poetry init" - this invokes virtualenv module which copies binaries instead of symlinking.
      6) you don't need to activate virtual environment if you are using poetry / pipenv. I usually just prepend "poetry run ..." to everything.

    • @horseinthesky
      @horseinthesky 5 лет назад +1

      @@dmfigol_live_archive Ok. I've missed that every command which starts with poetry works with venv it created so I'm able not to think about it at all. Thank you.