Poetry-Python 打包和依赖管理工具


原则

内容哪里来:

能带来什么:

- 性价比高:学习成本不高 VS 收获不少

Poetry 是什么


Poetry 使用的好处

Python 项目管理


Poetry 的好处


Poetry 创建项目

poetry new pydaily
tree pydaily


Poetry 虚拟环境

poetry shell


Poetry 添加依赖

poetry add requests
poetry add pytest -D


Poetry 项目文件


Poetry: pyporject.toml


Poetry 常用命令


Poetry 依赖管理 -- git 仓库管理

[tool.poetry.dependencies]
# Get the latest revision on the branch named "next"
requests = { git = "https://github.com/kennethreitz/requests.git", branch = "next" }

Poetry 依赖管理 -- 从 git 安装

poetry add "https://github.com/myorg/mypackage_with_subdirs.git#subdirectory=subdir"

Poetry 依赖管理 - 本地文件

[tool.poetry.dependencies]
# directory
my-package = { path = "../my-package/", develop = false }

# file
my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" }

Poetry 使用教程视频


↙↙↙阅读原文可查看相关链接,并与作者交流