使用 Azure Pipelines 的 poetry
安装 Python 包依赖项的推荐方法是什么?我看到人们只通过 pip
下载poetry
,这是一个很大的禁忌。
- script: |
python -m pip install -U pip
pip install poetry
poetry install
displayName: Install dependencies
我可以使用curl来下载诗歌
。
- script: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
export PATH=$PATH:$HOME/.poetry/bin
poetry install --no-root
displayName: 'Install dependencies'
但是在后续的每个步骤中,我都必须再次将诗歌添加到 PATH
中......
- script: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
export PATH=$PATH:$HOME/.poetry/bin
poetry install --no-root
displayName: 'Install dependencies'
- script: |
# export PATH=$PATH:$HOME/.poetry/bin
poetry run flake8 src
displayName: 'Linter'
- script: |
# export PATH=$PATH:$HOME/.poetry/bin
poetry add pytest-azurepipelines
poetry run pytest src
displayName: 'Tests'
是否有任何正确方式在 Azure Pipelines 中使用诗歌?
最佳答案
与同事咨询了这个问题。他建议执行单独的步骤将 Poetry 添加到 PATH。
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
displayName: 'Use Python 3.8'
- script: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
export PATH=$PATH:$HOME/.poetry/bin
poetry install --no-root
displayName: 'Install dependencies'
- script: echo "##vso[task.prependpath]$HOME/.poetry/bin"
displayName: Add poetry to PATH
- script: |
poetry run flake8 src
displayName: 'Linter'
- script: |
poetry add pytest-azurepipelines
poetry run pytest src
displayName: 'Tests'
关于python - Azure Pipelines - 使用 Poetry 的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71423949/