Python – Getting a custom package to install properly on Elastic Beanstalk

amazon ec2elastic-beanstalkpippython

I'm trying to get an elastic beanstalk worker environment set up, but one of the packages in the project's requirements.txt file comes from a private pypi server that I've got set up on EC2.

I can get this custom package to install on my local command line by including –trusted-host= –extra-index-url= on the pip install command, but apparently requirements.txt doesn't support –trusted-host option (it does in version 8, but the instance is using version 7 something and I can't figure out how to change it).

I tried setting up a pip.conf file by adding this to one of my .config files:

files:
"/home/ec2-user/.config/pip/pip.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      [global]
      extra-index-url = <url>
      trusted-host = <host>

But it still doesn't work. The logs are telling me that it can't find my package. How am I supposed to get this package to install?

Best Answer

You'll want to add the pip.conf to the virtual environment for the application, which should be something like "/opt/python/run/venv/pip.conf" instead of "/home/ec2-user/.config/pip/pip.conf".