使用actions/setup python和monoreo中的诗歌缓存



我正试图将setup-python操作与monorepo一起使用,但由于在根目录中找不到pyproject.toml,该操作无法激活正确版本的Python。

Run actions/setup-python@v4
Version 3.10.0 was not found in the local cache
Version 3.10.0 is available for downloading
Download from "https://github.com/actions/python-versions/releases/download/3.10.0-117927/python-3.10.0-linux-20.04-x64.tar.gz"
Extract downloaded archive
/usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/8cd8a45c-988b-46ca-89a9-ace52fc1c49d -f /home/runner/work/_temp/a061c229-0095-4087-a188-e56c51dce536
Execute installation script
Check if Python hostedtoolcache folder exist...
Create Python 3.10.0 folder
Copy Python binaries to hostedtoolcache folder
Create additional symlinks (Required for the UsePythonVersion Azure Pipelines task and the setup-python GitHub Action)
Upgrading pip...
Looking in links: /tmp/tmp6iiiom0p
Requirement already satisfied: setuptools in /opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages (57.4.0)
Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/site-packages (21.2.3)
Collecting pip
Downloading pip-22.2.2-py3-none-any.whl (2.0 MB)
Installing collected packages: pip
Successfully installed pip-22.2.2
Create complete file

Successfully set up CPython (3.10.0)
/opt/pipx_bin/poetry config --list
cache-dir = "/home/runner/.cache/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/runner/.cache/pypoetry/virtualenvs
/opt/pipx_bin/poetry env use /opt/hostedtoolcache/Python/3.10.0/x64/bin/python
RuntimeError
Poetry could not find a pyproject.toml file in /home/runner/work/my_proj/my_proj or its parents
at /opt/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/core/factory.py:369 in locate
365│             if poetry_file.exists():
366│                 return poetry_file
367│ 
368│         else:
→ 369│             raise RuntimeError(
370│                 "Poetry could not find a pyproject.toml file in {} or its parents".format(
371│                     cwd
372│                 )
373│             )
Warning: 
poetry cache is not found

因此,以下步骤将失败。我应该如何解决这个问题?

有一个开放功能请求和一个作为GitHub问题的解决方法。

以下片段(实际诗歌项目的路径存储为环境变量FOLDER(对我(本地跑步者,ubuntu 22.4(有效:

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Check poetry cache
uses: actions/cache@v3
id: cached-poetry-dependencies
with:
path: ${{ env.FOLDER }}/.venv
key: ${{ hashFiles(format('{0}/poetry.lock', env.FOLDER)) }}
- name: Install dependencies for <TOOL_IN_FOLDER>
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
working-directory: ${{ env.FOLDER }}

你可以在GitHub上找到这个动作,现在

最新更新