【GitHub Actions】 GitHub Actions에서 awscli와 awsebcli를 pip로 설치하면 오류가 발생했지만 해결 방법을 찾았습니다.

8062 단어 awscliGitHubpipAWS
AWS Elastic Beanstalk에 배포할 때 awscliawsebcli를 사용하고 있습니다. 되었습니다.
여러가지 시행착오한 결과 에러를 해결할 수 있었으므로(?) 그래서, GitHub Actions로 양 커멘드를 정상적으로 인스톨 할 수 있는 방법을 소개합니다.

발생한 오류



환경


  • ubuntu 18.04 on GitHub Actions
  • 파이썬 3.7.5
  • awscli 1.16.*
  • awsebcli 3.15.*

  • 오류 내용


    awscliawsebcli 모두 pip를 사용하여 설치하는 동안 오류가 발생했습니다.
    $ pip install awscli awsebcli
    
    # --- omit -----
    
    ERROR: botocore 1.13.13 has requirement python-dateutil<2.8.1,>=2.1; python_version >= "2.7", but you'll have python-dateutil 2.8.1 which is incompatible.
    ERROR: docker-compose 1.23.2 has requirement PyYAML<4,>=3.10, but you'll have pyyaml 5.1.2 which is incompatible.
    ERROR: awsebcli 3.15.3 has requirement botocore<1.13,>=1.12.29, but you'll have botocore 1.13.13 which is incompatible.
    ERROR: awsebcli 3.15.3 has requirement colorama<0.4.0,>=0.3.9, but you'll have colorama 0.4.1 which is incompatible.
    ERROR: awsebcli 3.15.3 has requirement PyYAML<=3.13,>=3.10, but you'll have pyyaml 5.1.2 which is incompatible.
    
    # --- omit -----
    
    # Error Exit にならずインストールできてしまった...
    Successfully installed PyYAML-5.1.2 awscli-1.16.277 awsebcli-3.15.3 blessed-1.16.1 botocore-1.13.13 cached-property-1.5.1 cement-2.8.2 certifi-2019.9.11 chardet-3.0.4 colorama-0.4.1 docker-3.7.3 docker-compose-1.23.2 docker-pycreds-0.4.0 dockerpty-0.4.1 docopt-0.6.2 docutils-0.15.2 future-0.16.0 idna-2.7 jmespath-0.9.4 jsonschema-2.6.0 pathspec-0.5.9 pyasn1-0.4.7 python-dateutil-2.8.1 requests-2.20.1 rsa-3.4.2 s3transfer-0.2.1 semantic-version-2.5.0 six-1.11.0 termcolor-1.1.0 texttable-0.9.1 urllib3-1.24.3 wcwidth-0.1.7 websocket-client-0.56.0
    

    훌륭하게 의존성을 해결하지 못했습니다.
    설치 후 두 명령을 실행했을 때의 로그가 ↓입니다.
    $ aws --version
    
    aws-cli/1.16.277 Python/3.7.5 Linux/5.0.0-1023-azure botocore/1.13.13
    
    $ eb --version
    
    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
        ws.require(__requires__)
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
        needed = self.resolve(parse_requirements(requirements))
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
        raise VersionConflict(dist, req).with_context(dependent_req)
    pkg_resources.ContextualVersionConflict: (PyYAML 5.1.2 (/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages), Requirement.parse('PyYAML<=3.13,>=3.10'), {'awsebcli'})
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.7.5/x64/bin/eb", line 6, in <module>
        from pkg_resources import load_entry_point
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3250, in <module>
        @_call_aside
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3234, in _call_aside
        f(*args, **kwargs)
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3263, in _initialize_master_working_set
        working_set = WorkingSet._build_master()
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 585, in _build_master
        return cls._build_from_requirements(__requires__)
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
        dists = ws.resolve(reqs, Environment())
      File "/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'PyYAML<=3.13,>=3.10' distribution was not found and is required by awsebcli
    ##[error]Process completed with exit code 1.
    

    PyYAML 버전이 충돌하고 있습니다.
    Issue에 올라가도록 버전을 지정하거나 종속 패키지를 수동으로 설치해 보았지만 작동하지 않았습니다.
    또한 pipenv를 사용하여 가상 환경에서 분리하여 설치해 보아도 좋지 않았습니다.

    거기서 검증용의 리포지토리를 작성해 여러가지 패턴을 시험해 성공하는 것이 있는지 조사했습니다.

    성공 패턴



    여기 리포지토리에서 실험하여 성공한 패턴이 몇 가지 있었지만, 그 중에서도 개인적으로 베스트라고 생각하는 Workflow를 소개합니다.

    환경


  • MacOS Catalina
  • Python 3.7.5
  • awscli 1.16.*
  • awsebcli 3.15.*

  • 2019/11/6에 MacOS가 Catalina로 업데이트되었습니다
    참고: GitHub Actions – macOS virtual environment updated to Catalina

    GitHub Actions 예


    awscli를 brew로, awsebcli를 pip로 설치합니다.
    name: Install awscli and awsebcli on Mac
    
    on: push
    
    jobs:
     test:
        name: Install awscli and awsebcli
        runs-on: macos-latest
        steps:
          - uses: actions/checkout@master
    
          - name: Install awscli
            run: |
              brew update
              brew install awscli
              brew upgrade
    
          - uses: actions/setup-python@master
            with:
              python-version: '3.7'
    
          - name: Install awsebcli
            run: pip install -U awsebcli
    
          - name: Check version
            run: |
              aws --version
              eb --version
    
    Check version 실행 로그
    $ aws --version
    aws-cli/1.16.260 Python/3.7.5 Darwin/19.0.0 botocore/1.12.250
    
    $ eb --version
    EB CLI 3.15.3 (Python 3.7.5)
    

    이런 느낌의 성공적으로 설치할 수 있고, 제대로 명령을 실행할 수 있습니다.
    그 밖에도 성공 패턴이 있었습니다만, 베이스가 되고 있는 Python의 버젼이 2계가 되어 버렸습니다.
    그래서 ↑가 최고입니다

    다양한 패턴은 여기 리포지토리에 있습니다. (갑자기 사라질지도 모르지만 용서를 ...)

    좋은 웹페이지 즐겨찾기