poetry update --lock
和 和有什么区别poetry lock
?我在官方文档中找不到太多有用的提示,而且我知道两者并不相同,因为我们最近由于意外问题而不得不从升级包切换poetry update --lock
到升级包。poetry lock
我正在尝试使用以下命令安装诗歌
curl -sSL https://install.python-poetry.org | python3 -
Run Code Online (Sandbox Code Playgroud)
但它失败了,但有以下例外:
例外:此版本的 python 无法在不使用符号链接的情况下创建 venvs
下面是详细说明错误的文本
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/Users/DaftaryG/.local/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.2.1): Creating environment
Traceback (most recent call last): …
Run Code Online (Sandbox Code Playgroud) 我一直在研究使用 Poetry 来发布 Python 项目。我想使用一个类似于Python Packaging Authority 教程的小项目来测试发布过程。由于这是一个简单的项目,我想将其发布到 pypi 的测试实例而不是真实实例。Test.pypi 需要一个令牌才能发布,但我不知道如何让 Poetry 使用我的测试 pypi 令牌。我能找到的所有文档都使用 HTTP 基本身份验证进行 test-pypi,但该身份验证不再有效。
我使用以下命令添加了存储库:
poetry config.repositories.test-pypi https://test.pypi.org
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下命令创建令牌:
poetry config pypi-token.test-pypi my-token
Run Code Online (Sandbox Code Playgroud)
poetry config test-pypi-token.test-pypi my-token
Run Code Online (Sandbox Code Playgroud)
我在诗歌文档中找不到添加标记的语法的良好解释,因此我们将不胜感激。
我的 monorepo 中有多个项目,它们分别通过 Poetry 进行包管理。例如,
\nmonorepo\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 a\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pyproject.toml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 b\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pyproject.toml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 c\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pyproject.toml\n
Run Code Online (Sandbox Code Playgroud)\n每个项目都有自己的[tool.poetry.dependencies]
和会话[tool.poetry.dev-dependencies]
。然而,他们确实共享了大量的通用配置,例如
我的问题是如何定义可重用于 monorepo 项目的通用配置?
\n我正在研究这个Python 项目模板。它们用于poetry
定义开发依赖项
[tool.poetry.dev-dependencies]
black = {version = "*", allow-prereleases = true}
flake8 = "*"
isort = "^5.6"
mypy = ">0.900,<1"
...
Run Code Online (Sandbox Code Playgroud)
它们还用于pre-commit
检查 git 和 CI 工作流程的内务工作(例如,格式化、linting、分类等):
minimum_pre_commit_version: 2.8.0
default_stages: [commit, push, manual]
repos:
- repo: https://github.com/psf/black
rev: 21.11b1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args: [--max-line-length=88]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [--filter-files]
- ...
Run Code Online (Sandbox Code Playgroud)
就我而言,我肯定想要一个由 Poetry 为我的 IDE 管理的本地版本的开发包,并且我还想“按原样”利用预提交框架,而不需要切换到 …
我有一个不使用 setuptools 的诗歌项目
[tool.poetry.dependencies]
python = ">=3.9,<3.11"
opencv-python = "^4.7.0.68"
tensorflow-macos = "^2.11.0"
tensorflow-metal = "^0.7.0"
Run Code Online (Sandbox Code Playgroud)
但我在 pycharm 中不断收到此错误。截图中的命令:
/Users/mc/Library/Caches/pypoetry/virtualenvs/besafe-_8yAv-v6-py3.9/bin/Python /Users/mc/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/223.8214.51/PyCharm.app/Contents/plugins/python/helpers/packaging_tool.py list
Run Code Online (Sandbox Code Playgroud)
它只是弹出,我这边没有任何操作。看起来 PyCharm 正在幕后执行一些操作,但我不知道它是什么。
我不明白我该如何解决这个问题?
根据诗歌的 docs,设置新项目的正确方法是 with poetry new poetry-demo
,但是这会通过创建以下 toml 文件创建基于现已弃用的 python2.7 的项目:
[tool.poetry]
name = "poetry-demo"
version = "0.1.0"
description = ""
authors = ["Harsha Goli <harshagoli@gmail.com>"]
[tool.poetry.dependencies]
python = "^2.7"
[tool.poetry.dev-dependencies]
pytest = "^4.6"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Run Code Online (Sandbox Code Playgroud)
如何将其更新到 3.7?简单地更改python = "^2.7"
为python = "^3.7"
在poetry install
运行时会导致以下错误:
[SolverProblemError]
The current project's Python requirement (2.7.17) is not compatible with some of the required packages Python requirement:
- zipp requires Python >=3.6
Because …
Run Code Online (Sandbox Code Playgroud) 我有一个简单的问题。
我曾经用我的包在根目录下创建一个诗歌项目。
project.toml
mypackage
+- __init__.py
+- mypackage.py
+- test_mypackage.py
Run Code Online (Sandbox Code Playgroud)
我最近将测试移到了另一个目录中,因此该文件夹现在看起来像。
project.toml
src
+- mypackage
+- __init__.py
+- mypackage.py
tests
+- test_mypackage.py
Run Code Online (Sandbox Code Playgroud)
诗歌没有任何改变,当我创作时它仍然工作得很好poetry build
。它如何搜索包根文件夹?它是否搜索包名称为 的文件夹project.toml
?
感谢您的帮助。
我正在通过 Poetry 管理 Python 项目中的依赖项。
\n现在我想在与我的开发机器不同的机器上运行这个项目。要安装依赖项,我只需从根目录运行以下命令:
\n$ poetry install\n
Run Code Online (Sandbox Code Playgroud)\n但随后它会引发以下错误:
\nUpdating dependencies\nResolving dependencies...\n\nWriting lock file\n\nPackage operations: 70 installs, 0 updates, 0 removals\n\n \xe2\x80\xa2 Installing colorama (0.4.4)\n \xe2\x80\xa2 Installing tzdata (2021.1)\n\n ValueError\n\n File \\C:\\Users\\tteguayco\\AppData\\Local\\pypoetry\\Cache\\artifacts\\9e\\b3\\11\\7d87ac44fdb2d557301f1f4086a37c080d1482a98751abe7cdbabbad26\\colorama-0.4.4-py2.py3-none-any.whl does not exist\n\n at ~\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\poetry\\core\\packages\\file_dependency.py:40 in __init__\n 36\xe2\x94\x82 except FileNotFoundError:\n 37\xe2\x94\x82 raise ValueError("Directory {} does not exist".format(self._path))\n 38\xe2\x94\x82\n 39\xe2\x94\x82 if not self._full_path.exists():\n \xe2\x86\x92 40\xe2\x94\x82 raise ValueError("File {} does not exist".format(self._path))\n 41\xe2\x94\x82\n 42\xe2\x94\x82 if self._full_path.is_dir():\n 43\xe2\x94\x82 raise ValueError("{} is a directory, expected a file".format(self._path))\n …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,该项目使用Poetry和pyproject.toml文件来指定其依赖项来管理依赖项。我需要的库之一的文档建议使用 pip 安装其中一个依赖项的“额外”选项,如下所示:
pip install google-cloud-bigquery[opentelemetry]
Run Code Online (Sandbox Code Playgroud)
我应该如何在pyproject.toml
文件中反映这一要求?目前,有这样几行:
[tool.poetry.dependencies]
python = "3.7.10"
apache-beam = "2.31.0"
dynaconf = "3.1.4"
google-cloud-bigquery = "2.20.0"
Run Code Online (Sandbox Code Playgroud)
将最后一行更改为
google-cloud-bigquery[opentelemetry] = ">=2.20.0"
Run Code Online (Sandbox Code Playgroud)
产量
Invalid TOML file /home/jupyter/vertex-monitoring/pyproject.toml: Unexpected character: 'o' at line 17 col 22
Run Code Online (Sandbox Code Playgroud)
其他似乎无法正确解析的变体:
google-cloud-bigquery["opentelemetry"] = "2.20.0"
Run Code Online (Sandbox Code Playgroud)
还有其他看起来相关的StackOverflow问题,以及几个 不同的 PEP 文档,但我的搜索很复杂,因为我不确定这些是“选项”还是“附加”还是其他东西。
python ×10
python-poetry ×10
dependencies ×1
installation ×1
macos ×1
monorepo ×1
pycharm ×1
pypi ×1
setuptools ×1
testing ×1