[GiitHub Actions] Poetry 프로젝트에서 종료합니다.txt 생성 및 자동 제출

배경.


Heroku 공식 Python Buidpack Poetry(2021/10 기준)는 지원되지 않습니다.
현재 Poetry 프로젝트를 Heroku로 설계할 때 다음과 같은 두 가지 방법이 있다고 생각합니다.
  • 비공식Poetry 지원 Buildpack 사용
  • requirements.txt이번에는 후자를 쉽게 진행할 수 있는 방법을 소개한다.

    보태다


    히로쿠 공식은 Poetry에 대응하는 절차에 따라 진행되기 때문에 조만간 대응할 것으로 생각한다.
    참조: Support for Poetry #796

    해본 일

    pyproject.toml에 변경 사항을 추가하여 제출할 경우 GiitHub Actions를 사용하여 자동으로 업데이트requirements.txt하고 제출합니다.
    Poetry가 생성requirements.txt 기능을 준비했기 때문에 우리는 poetry 명령을 실행하는 동작GiitHub에 자동 제출된 작업를 조합하여workflow를 만들었다.
    여기.의 창고를 통해 집행례를 확인할 수 있습니다.

    name: generate requirements.txt
    on: push
    
    jobs:
      ci:
        strategy:
          fail-fast: false
          matrix:
            python-version: [3.9]
            poetry-version: [1.0]
            os: [ubuntu-18.04]
        runs-on: ${{ matrix.os }}
        steps:
          - uses: actions/checkout@v2
          - uses: actions/setup-python@v2
            with:
              python-version: ${{ matrix.python-version }}
          - name: Run image
            uses: abatilo/actions-[email protected]
            with:
              poetry-version: ${{ matrix.poetry-version }}
          - name: Export requirements.txt
            run: poetry export -f requirements.txt --output requirements.txt
          - name: Update requirements.txt
            uses: stefanzweifel/git-auto-commit-[email protected]
            with:
              commit_message: update requirements.txt
              commit_user_name: GitHub Actions
              commit_user_email: [email protected]
    
    actions-poetry에서는 파이톤의 버전 지정, git-auto-commit-action에서 제출한 사용자와 제출한 메시지의 사용자 정의 등 다양한 옵션을 설정할 수 있다.
    자세한 내용은 각 Action의 문서를 참조하십시오.

    끝말


    뭔가 이상하다고 느껴지지만 Poetry보다는 사용requirements.txt이 더 많았다.
    히로쿠를 기반으로 이야기를 나눴고, 자신이 만든 포에트리 프로젝트를 다른 사람도 이용할 수 있도록 위와 같은 방법requirements.txt을 사용해 준비한 용법도 있죠.
  • 좋은 웹페이지 즐겨찾기