Poetry Guide
Installation and Setup
Install Poetry:
shcurl -sSL https://install.python-poetry.org | python3 -Configure Poetry:
shpoetry config virtualenvs.in-project true
Creating a New Project
Create a new project:
shpoetry new my-project cd my-projectInitialize a new project in an existing directory:
shcd existing-directory poetry init
Adding and Removing Modules
Add a module:
shpoetry add requestsRemove a module:
shpoetry remove requests
Exporting to Requirements
- Export dependencies to a requirements.txt file:sh
poetry export -f requirements.txt --output requirements.txt
Publishing Packages to PyPI / Test PyPI
Configure Poetry to use Test PyPI:
shpoetry config repositories.test-pypi https://test.pypi.org/legacy/Publish to Test PyPI:
shpoetry publish -r test-pypiPublish to PyPI:
shpoetry publish --build
This guide provides a basic overview of using Poetry for Python project management, including installation, project creation, dependency management, exporting requirements, and publishing packages.