Can I update Amazon's old versions of pip and setuptools?

前端 未结 2 901
无人及你
无人及你 2021-02-04 07:44

Can I update or remove the pip and setuptools provided with AWS Elastic Beanstalk?

The versions of pip and setuptools provided with my AWS Elastic Beanstalk Python envir

相关标签:
2条回答
  • 2021-02-04 08:25

    Try adding an ebextension file that will upgrade pip before running pip install -r requirements.txt

    for example:

    004_prehook.config

    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/pre/02a_upgrade_pip.sh":
      mode: "000755"
      owner: root
      group: root
      content: |
        #!/usr/bin/env bash
        source /opt/python/run/venv/bin/activate
        python3 -m pip install --upgrade pip
    
    0 讨论(0)
  • 2021-02-04 08:28

    Taking pip as an example, the default AWS environment provides usually an old version. Currently it is a 6.1.1 on a machine I use, while pip repeats at each call that 9.0.1 is available.

    Dependencies sometimes require recent versions of pip. One way to have it available is to rely on pip itself, as the yum sources provided by AWS are slower to upgrade (due to the sheer impact that would cause...).

    Different AWS services have different solutions. The question is about Beanstalk. Assuming deployment based on eb provided by AWS, it is possible to execute commands in the target container:

    • Create a .ebextensions/upgrade_pip.config file.
    • Insert the command to execute.

    To upgrade pip, a command like this does the job:

    commands:
      pip_upgrade:
        command: /opt/python/run/venv/bin/pip install --upgrade pip
        ignoreErrors: false
    

    Note that the file name for .ebextensions/upgrade_pip.config defines the order of execution. If it needs to run earlier than any other script in .ebextensions, a prefix like 01_upgrade... is necessary.

    0 讨论(0)
提交回复
热议问题