简介
Poetry 是 Python 的项目依赖管理构建打包工具。
官网:Poetry - Python dependency management and packaging made easy
源码:GitHub - python-poetry/poetry: Python packaging and dependency management made easy
安装并修改虚拟环境路径
# 使用 pipx 安装 poetry
$ pipx install poetry
# poetry 修改虚拟环境路径
$ poetry config cache-dir D:\Cache\pypoetry
# 查看 poetry 配置
$ poetry config --list
cache-dir = "D:\\Cache\\pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs" # D:\Cache\pypoetry\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true
创建项目并修改镜像源
# poetry 创建项目
$ poetry new poetrytest
$ cd poetrytest
# 设置默认镜像
$ poetry source add --priority=default mirrors https://pypi.tuna.tsinghua.edu.cn/simple/
# 进入虚拟环境
$ poetry shell
Spawning shell within D:\Cache\pypoetry\virtualenvs\poetrytest-GGuV2pTH-py3.10
(poetrytest-py3.10) C:\Users\Administrator\Desktop\poetrytest>
评论区