我正在尝试设置 Azure Devops 以使用 Poetry 发布到 PyPI 提要。
我了解 Twine 身份验证并将凭据存储到 Azure Key Vault。但是有没有更直接的方法呢?像这样的东西:
- script: |
source .venv/bin/activate
poetry build
displayName: Build wheel
- script: |
source .venv/bin/activate
poetry publish -u USER -p PASS
displayName: Publish wheel
Run Code Online (Sandbox Code Playgroud) 我正在使用poetry库来管理项目依赖项,所以当我使用
docker build --tag=helloworld .
我收到这个错误
[AttributeError]
'NoneType' object has no attribute 'group'
Run Code Online (Sandbox Code Playgroud)
在umongo (2.1.0)包上安装中断
这是我的pyproject.toml文件
[tool.poetry.dependencies]
python = "^3.7.0"
asyncio = "^3.4"
aiohttp = "^3.4"
motor = "^2.0"
umongo = "^2.0"
pyyaml = "^3.13"
[tool.poetry.dev-dependencies]
pytest = "^3.4"
black = {version = "^18.3-alpha.0",allows-prereleases = true}
mypy = "^0.650.0"
wemake-python-styleguide = "^0.5.1"
pytest-mock = "^1.10"
pytest-asyncio = "^0.9.0"
pytest-aiohttp = "^0.3.0"
Run Code Online (Sandbox Code Playgroud)
和poetry.lock
https://pastebin.com/kUjAKJHM
Dockerfile:
FROM python:3.7.1-alpine
RUN mkdir -p /opt/project/todo_api
RUN pip --no-cache-dir …Run Code Online (Sandbox Code Playgroud) 假设我想安装a需要包b1和b2. 反过来,b1需要c > 1.0.0和b2需要c < 1.0.0。所以不能用同一个包同时满足b1和的要求b2。
原则上/其他编程语言,这不是问题。可以c并排安装两个版本,并确保b1使用的版本不是b2.
但是,我不确定 pip 是否可以安装同一个包的两个版本。我的第一个问题是:pip 可以安装一个包的两个版本吗?
我的主要问题是如何实际处理该问题。我现在能想到的唯一方法就是
b1(或b2)和一个版本c是作品叉,并上传b1_forked和c_for_b1_forked到PyPI中,或b1(或b2)的代码两者似乎都比必要的问题更多。
>>> import natsort; print(natsort.__file___)
'/home/moose/.local/lib/python3.6/site-packages/natsort/__init__.py'
$ cd /home/moose/.local/lib/python3.6/site-packages
$ ls
[... a lot of *.dist-info directories, some .py files, some .so files, ]
[... some directories …Run Code Online (Sandbox Code Playgroud) 当我在 Python 3.7 中使用诗歌命令时,就我而言:
poetry export -f requirements.txt
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.
Run Code Online (Sandbox Code Playgroud)
到目前为止很清楚,但如果我运行诗歌更新,它会升级我的依赖项,这不是我目前想要的项目。如果我改为运行诗歌锁,它仍然会升级依赖项。
我该如何解决这个问题?
我的问题: Python 工具 Poetry 如何知道一个项目的虚拟环境的路径?
说明:当我poetry init在目录中运行时,会创建一个新项目。然后我运行poetry install并创建一个新的虚拟环境。但是,该虚拟环境的路径和散列都没有存储在我预期的中pyproject.toml或poetry.lock如我预期的那样。当我运行时,Poetry 如何知道虚拟环境的位置poetry env info -p?
除了想知道发生了什么之外,我还需要知道这一点,原因有两个:
可能的解决方案:查看 Poetry 的源代码,在我看来,一个文件envs.toml可能包含从文件系统目录到虚拟环境哈希的映射,但在我的 Mac OS 11.1 上我找不到这样的文件。
我很想初始化一个诗歌生成的项目,而无需通过交互式 shell 来获取版本和依赖项等。
然而,尝试修改命令行选项的几次尝试都失败了。
例如
poetry init --name my_proj --description "my proj" --author john.doe --python 3.9 --dependency "pytest:^6.2.0" --dev-dependency coverage -l MIT
Run Code Online (Sandbox Code Playgroud)
为我提供了交互式 shell 来确认我提供的所有信息。
我希望通过提供所有依赖项,该命令应该pyproject.toml自动生成一个,而无需我输入任何内容。
我哪里错了?
我在 Windows 10 上有 anaconda 3.8。我创建了 python3.9 虚拟环境并将诗歌配置 virtualenvs.in-project 设置为 true。但是当我进行诗歌安装时,它不会在项目内创建 .envn 文件夹。以下是诗歌环境信息结果:
(python39) C:\Users\username\Developer\Packages\test5>poetry env info
Virtualenv
Python: 3.9.6
Implementation: CPython
Path: C:\Users\username\Anaconda3\envs\python39
Valid: True
System
Platform: win32
OS: nt
Python: C:\Users\username\Anaconda3\envs\python39***
Run Code Online (Sandbox Code Playgroud)
但是,当停用 python39 环境并运行诗歌安装时,它会在项目内创建 .envn 文件夹。诗歌环境信息结果如下:
Virtualenv
Python: 3.9.6
Implementation: CPython
Path: C:\Users\username\Developer\Packages\test2\.venv
Valid: True
System
Platform: win32
OS: nt
Python: C:\Users\username\Anaconda3\envs\python39
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它在python39环境下工作?
尝试诗歌 1.1.11 并在我的 pyproject.toml 的 tool.poetry.dependencies 部分中添加 pandas。Pandas 依赖于 numpy
\npandas 1.3.3 Powerful data structures for data analysis, time series, and statistics\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 numpy >=1.17.3\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 python-dateutil >=2.7.3\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 six >=1.5 \n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pytz >=2017.3\nRun Code Online (Sandbox Code Playgroud)\n当我打电话时poetry add pandas它时,正确安装了 numpy 1.21.1。Numpy 已经升级到 1.22.2,诗歌也认识到了这一点
poetry show --outdated\nnumpy 1.21.1 1.21.2 NumPy is the fundamental package for array computing with Python.\nRun Code Online (Sandbox Code Playgroud)\n但 numpy 并没有被诗歌更新。
\npoetry update\nUpdating dependencies\nResolving dependencies... (0.3s)\n\nNo dependencies to install or update\nRun Code Online (Sandbox Code Playgroud)\n这是预期的吗?numpy 如何/何时更新?
\n编辑2:根据@finswimmer的请求,这里是TOML,并且是比第一个编辑TOML更简单的情况。这是一个来自 的空项目 …
我们正在使用诗歌来升级包并部署到我们的服务器,但有些问题阻止我们将工作持续部署到我们的服务器。下面的代码是我们的代码停止的堆栈跟踪。
\n$ poetry update \nCreating virtualenv kpbackend-ad2VTdyQ-py3.9 in /root/.cache/pypoetry/virtualenvs\nUpdating dependencies\nResolving dependencies...\nWriting lock file\nPackage operations: 171 installs, 0 updates, 0 removals\n \xe2\x80\xa2 Installing shortuuid (1.0.1)\n \xe2\x80\xa2 Installing simpleeval (0.9.10)\n \xe2\x80\xa2 Installing starkbank-ecdsa (1.1.1)\n \xe2\x80\xa2 Installing starlette (0.13.8)\n EnvCommandError\n Command ['/root/.cache/pypoetry/virtualenvs/kpbackend-ad2VTdyQ-py3.9/bin/pip', 'install', '--no-deps', '/root/.cache/pypoetry/artifacts/49/c9/a8/c45627062eb893ac0685ce1146f6b868eea117d5803fc63c56d21326de/simpleeval-0.9.10.tar.gz'] errored with the following return code 1, and output: \n Processing /root/.cache/pypoetry/artifacts/49/c9/a8/c45627062eb893ac0685ce1146f6b868eea117d5803fc63c56d21326de/simpleeval-0.9.10.tar.gz\n ERROR: Command errored out with exit status 1:\n command: /root/.cache/pypoetry/virtualenvs/kpbackend-ad2VTdyQ-py3.9/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-408xzy97/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-408xzy97/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) …Run Code Online (Sandbox Code Playgroud) 我正在使用最新版本的诗歌(1.1.10),在尝试更新我的锁定文件时,我在尝试安装 pycparser==2.20 时遇到了错误:
\nWriting lock file\n\nPackage operations: 65 installs, 0 updates, 0 removals\n\n \xe2\x80\xa2 Installing pycparser (2.20)\n\n ValueError\n\n File \\C:\\Users\\user\\AppData\\Local\\pypoetry\\Cache\\artifacts\\3b\\b4\\2e\\87ea123a592747e6f6c798c66837974694db0bca4783357f71718a538d\\pycparser-2.20-py2.py3-none-any.whl does not exist\n\n at c:\\users\\boris\\miniconda3\\envs\\project\\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))\nRun Code Online (Sandbox Code Playgroud)\n我尝试更改我的诗歌版本以及 pycparser 的版本,但这似乎只会破坏其他软件包。以前有人处理过这个问题吗?如果是的话,你能给我指出正确的方向吗?
\n规格:\n操作系统:Windows 10\nPython 版本:3.6\npoetry==1.1.10\npycparser==2.20
\npython-poetry ×10
python ×6
anaconda3 ×1
azure-devops ×1
devops ×1
docker ×1
linux ×1
pip ×1
pycparser ×1
python-3.6 ×1
ubuntu ×1