Poetry Concepts: Difference between revisions
(13 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
=Overview= | =Overview= | ||
Poetry is a Python package management tool and an environment manager. | Poetry is a Python package management tool and an environment manager. It does create a Python virtual environment based on the project's declared dependencies. The project should declare its dependencies in <code>[[pyproject.toml|pyproject.toml]]</code>. Poetry can also be used to build and publish packages in Python package repositories. | ||
=<tt>pyproject.toml</tt>= | =<tt>pyproject.toml</tt>= | ||
{{Internal|pyproject.toml|<tt>pyproject.toml</tt>}} | |||
=Virtual Environments= | =Virtual Environments= | ||
Poetry maintains its virtual environments under <code>~/Library/Caches/pypoetry/virtualenvs</code>. Each virtual environment is named <font color=darkkhaki>after what?</font>, and it is postfixed by a hash (<code>ZyD6nUaS</code>). | Poetry maintains its virtual environments under <code>~/Library/Caches/pypoetry/virtualenvs</code>. Each virtual environment is named <font color=darkkhaki>after what?</font>, and it is postfixed by a hash (<code>ZyD6nUaS</code>). There is an index file <code>~/Library/Caches/pypoetry/virtualenvs/envs.toml</code>. | ||
The virtual environment is created <font color=darkkhaki>when?</font>, <font color=darkkhaki>how?</font> | The virtual environment is created <font color=darkkhaki>when?</font>, <font color=darkkhaki>how?</font> | ||
To display information about the project's current virtual environment: | |||
<syntaxhighlight lang='bash'> | |||
poetry env info | |||
</syntaxhighlight> | |||
To list all virtual environments associated with the project: | |||
<syntaxhighlight lang='bash'> | |||
poetry env list | |||
</syntaxhighlight> | |||
To remove the virtual environments associated with the project: | |||
<syntaxhighlight lang='bash'> | |||
poetry env remove <env-name> | |||
</syntaxhighlight> | |||
Also see: {{Internal|Python_Virtual_Environment#Overview|Python Virtual Environments}} | |||
=PyCharm and Poetry= | |||
{{External|https://www.jetbrains.com/help/pycharm/poetry.html}} | |||
Poetry needs to be installed locally and made available in the path for PyCharm to use it. Follow this [[Poetry_Operations#With_Custom_Installer|installation procedure]]. | |||
When initializing a project, PyCharm figures out if it is managed by Poetry and asks whether to set up a Poetry environment. It "offers" the Poetry executable: <code>/Users/ovidiu/.local/bin/poetry</code>. As part of the process, the Python interpreter configured as part of the Poetry-managed virtual environment is configured as project interpreter, and also the [[IntelliJ_Concepts#Global_SDKs|global PyCharm SDK table]] is updated. |
Latest revision as of 21:26, 3 November 2023
Internal
Overview
Poetry is a Python package management tool and an environment manager. It does create a Python virtual environment based on the project's declared dependencies. The project should declare its dependencies in pyproject.toml
. Poetry can also be used to build and publish packages in Python package repositories.
pyproject.toml
Virtual Environments
Poetry maintains its virtual environments under ~/Library/Caches/pypoetry/virtualenvs
. Each virtual environment is named after what?, and it is postfixed by a hash (ZyD6nUaS
). There is an index file ~/Library/Caches/pypoetry/virtualenvs/envs.toml
.
The virtual environment is created when?, how?
To display information about the project's current virtual environment:
poetry env info
To list all virtual environments associated with the project:
poetry env list
To remove the virtual environments associated with the project:
poetry env remove <env-name>
Also see:
PyCharm and Poetry
Poetry needs to be installed locally and made available in the path for PyCharm to use it. Follow this installation procedure.
When initializing a project, PyCharm figures out if it is managed by Poetry and asks whether to set up a Poetry environment. It "offers" the Poetry executable: /Users/ovidiu/.local/bin/poetry
. As part of the process, the Python interpreter configured as part of the Poetry-managed virtual environment is configured as project interpreter, and also the global PyCharm SDK table is updated.