Python - poetry(3)配置项详解

简介: Python - poetry(3)配置项详解

config 命令


  • poetry 通过 config 命令进行配置
  • 也可以直接在 config.toml 文件中进行配置,该文件将在首次运行该命令时自动创建

文件目录

  • macOS:~/Library/Application Support/pypoetry
  • Windows: C:\Users\<username>\AppData\Roaming\pypoetry

 

查看当前配置列表


poetry config --list

image.png

目前就这些配置项

 

查看某个配置项


poetry config virtualenvs.path

 

修改某个配置项


poetry config virtualenvs.path /path/to/cache/directory/virtualenvs

 

移除某个配置项


poetry config virtualenvs.path --unset

 

使用环境变量


  • 在使用 CI 工具时,会经常使用环境变量,这样可以不必执行 poetry config 命令
  • poetry 支持环境变量,任何设置都可以使用环境变量来设置
  • 环境变量必须以 poetry_  作为前缀,大写名称组成,用 _ 下划线代替 .-

 

栗子:virtualenvs.path

export POETRY_VIRTUALENVS_PATH=/path/to/virtualenvs/directory

 

配置项详解


cache-dir

poetry 使用的缓存目录的路径

默认目录路径

  • macOS: ~/Library/Caches/pypoetry
  • Windows: C:\Users\<username>\AppData\Local\pypoetry\Cache
  • Unix: ~/.cache/pypoetry

 

installer.parallel

安装程序时并行执行,默认 true

 

virtualenvs.create

  • 如果虚拟环境不存在,则会自动创建一个新的虚拟环境,默认 true
  • 如果设为 false,则私用的 Python 环境必须安装且可使用 pip

 

virtualenvs.in-project

  • 在项目的根目录中创建 virtualenv,默认 null
  • 如果设置为 true,将在项目根目录中名为 .venv 的文件夹中创建 virtualenv
  • 如果未显式设置(默认),poetry 将使用 .venv 目录中的 virtualenv(如果有)
  • 如果设置为 false,poetry 将忽略任何现有的 .venv 目录

 

virtualenvs.path

在其中创建虚拟环境的目录

默认: {cache-dir}/virtualenvs

像我上面的配置就是: /Users/polo/Library/Caches/pypoetry/virtualenvs

相关文章
|
iOS开发 MacOS Python
Python包管理工具之poetry
之前讲了一个pipenv包管理工具,这里说另外一个poetry工具,它是一个Python 虚拟环境和依赖管理工具。还提供了打包发布的功能。
|
存储 缓存 Rust
Python依赖管理及打包利器-Poetry
简介 Poetry 是一个包管理和打包的工具。 在 Python 中,对于初学者来说,打包系统和依赖管理是非常复杂和难懂的。即使对于经验丰富的开发者,一个项目总是要同时创建多个文件: setup.py ,requirements.txt,setup.cfg , MANIFEST.in ,还有最新的 Pipfile,十分繁琐。因此, poetry 将所有的配置都放置在一个 toml 文件(pyproject.toml)中,这些配置包括:依赖管理、构建、打包、发布。 Poetry 的灵感来自于其他语言的一些工具: composer(PHP) 和 cargo (Rust) 。
|
Python
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
278 0
Python 常见问题 - 使用 poetry build 打包构建失败,报 ModuleOrPackageNotFound No file/folder found for package filesystemfastapi
|
数据安全/隐私保护 Python
Python 常见问题 - pip install 指定 poetry 导出的 requirements.txt,报错 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not: cffi>=1.1 from https://.....
Python 常见问题 - pip install 指定 poetry 导出的 requirements.txt,报错 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not: cffi>=1.1 from https://.....
686 0
Python 常见问题 - pip install 指定 poetry 导出的 requirements.txt,报错 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not: cffi>=1.1 from https://.....
|
存储 关系型数据库 MySQL
Python - poetry(6)pyproject.toml 文件详解
Python - poetry(6)pyproject.toml 文件详解
936 0
|
开发工具 git Python
Python - poetry(5)依赖规范
Python - poetry(5)依赖规范
316 0
|
Python
Python - poetry(4)管理环境
Python - poetry(4)管理环境
378 0
Python - poetry(4)管理环境
|
存储 缓存 Shell
Python - poetry(2)命令介绍(下)
Python - poetry(2)命令介绍(下)
757 0
Python - poetry(2)命令介绍(下)
|
Python
Python - poetry(2)命令介绍(上)
Python - poetry(2)命令介绍(上)
623 0
Python - poetry(2)命令介绍(上)
|
Linux 网络安全 开发工具
Python - poetry(1)包管理利器的入门介绍
Python - poetry(1)包管理利器的入门介绍
651 0