我在 python 3.10 中使用诗歌 1.1.12。我的项目依赖于 numpy 1.21.1,每次运行持续集成管道时都需要 5 分钟的时间来安装。
有没有办法让诗歌使用某种编译的 numpy 包而不是每次构建都重建它?
我已经按照这个答案中描述的步骤缓存我的虚拟环境存储库来缓解这个问题,但是我想要一个即使我更改我的poetry.lock
文件或我的缓存已过期也能工作的解决方案。
ubuntu-latest
由于公司政策规则,我只能在 github 操作中使用图像
我的 pyproject.toml
[tool.poetry]
name = "test-poetry"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.10"
numpy = "^1.21.1"
[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
[build-system]
requires = ["poetry-core>=1.1.12"]
build-backend = "poetry.core.masonry.api"
我的 github 操作工作流程:
name: Continuous Integration
on: push
jobs:
test-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install Poetry packaging manager
run: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install project dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Run test
run: poetry run pytest