Composer不支持在requirements.txt文件中添加注释。

huangapple go评论75阅读模式
英文:

Does Composer not support comments in requriements.txt?

问题

这是我的requirements.txt文件:

# 这是一个注释
python-json-logger==2.0.4

# 这是一个私有包
my_private_pypi_package==1.2.3

我遇到了一个错误:

> gcloud composer environments update myenv  --format=json --project myproj --location=us-central1 --update-pypi-packages-from-file='requirements.txt'

ERROR: (gcloud.composer.environments.update) INVALID_ARGUMENT: 发现了2个问题:

	1) 验证密钥错误 # 这是一个私有包。PyPI 依赖项名称格式不正确。它必须遵循 PEP-508 中指定的 'identifier' 格式。
	2) 验证密钥错误 # 这是一个注释。PyPI 依赖项名称格式不正确。它必须遵循 PEP-508 中指定的 'identifier' 格式。

看起来它进行了一些相当粗糙的验证。

Composer 真的不支持带有注释的有效 requirements.txt 文件吗?有没有办法添加它们而不会导致 Composer 出错?

编辑

我打开了一个错误跟踪器:https://issuetracker.google.com/issues/295764408

我在这里提到的 GitHub 问题中发表了评论,指出这仍然是一个 bug:https://github.com/composer/composer/issues/5364

英文:

This is my requirements.txt

# This is a comment
python-json-logger==2.0.4

# Here's a private package
my_private_pypi_package==1.2.3

I get an error:

> gcloud composer environments update myenv  --format=json --project myproj --location=us-central1 --update-pypi-packages-from-file='requirements.txt'

ERROR: (gcloud.composer.environments.update) INVALID_ARGUMENT: Found 2 problems:

	1) Error validating key # Here's a private package. PyPI dependency name is not formatted properly. It must follow the format of 'identifier' specified in PEP-508.
	2) Error validating key # This is a comment. PyPI dependency name is not formatted properly. It must follow the format of 'identifier' specified in PEP-508.

Seems like it's doing some pretty crude validation.

Does Composer really not support valid requirements.txt's with comments? Is there a way to add them Composer won't choke on?

Edit

I opened a bug tracker: https://issuetracker.google.com/issues/295764408

I commented on the GitHub issue mentioned here that this is still a bug: https://github.com/composer/composer/issues/5364

答案1

得分: 1

我之前遇到过这个问题,据我记得,已经修复了一个关于这个问题的内部错误;正如其中所述:“在读取要求文件时跳过注释行”。我建议您提交一个问题报告,让他们知道为什么这个错误仍然存在或重新发生。

此外,解决此问题的方法是删除注释行,以消除错误,因为它以#字符开头,而requirements.txt必须遵循PEP-508中指定的格式

英文:

I have encountered this before and as I can remember, an internal bug has been fixed regarding this; as what was stated there: "Skip commented lines when reading in requirements file". I suggest to file an issue report regarding this for them to know why this bug is still existing or reoccurred.

Also, the workaround in this is to delete the comment line(s) to remove the error since it begins with # character, and requirements.txt must follow the format specified in PEP-508.

huangapple
  • 本文由 发表于 2023年8月8日 22:13:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76860410.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定