簡體   English   中英

在 monorepo 中使用 actions/setup-python 和詩歌緩存

[英]Using actions/setup-python with poetry cache in monorepo

我正在嘗試將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 上找到這個動作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM