4

I want to move an app from the Python 3.7 standard environment to the Python 3.6 flex environment.

Python 3.7 comes with pip 18, Python 3.6 comes with pip 9. Pip 10 introduced a very useful feature, build dependencies. Many analytics packages need this to work, otherwise you have to install build dependencies like Cython manually in a separate step. That is obviously a non-starter in GAE.

Outside of GAE the solution is pip install --upgrade pip.

Is it possible to have the Python 3.6 environment update its pip before it runs pip install -r requirements.txt?

Adding pip to requirements.txt has no effect.

Adam
  • 16,808
  • 7
  • 52
  • 98

2 Answers2

4

Only python packages installable with pip (the one supplied) can be installed using the requirements.txt method.

To satisfy any other dependencies, including pip itself, you can build a custom runtime tailored exactly to your needs:

Use a custom runtime in the App Engine flexible environment to use an alternative implementation of Java, Python, Node.js, or Go, or write code in any other language. Defining new runtime environments allow you to include additional components like language interpreters or application servers.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Ah. I was hoping to avoid that. I guess that's the only way to go. – Adam Sep 15 '18 at 02:24
  • For others coming across this, folks in the GAE group said that upgrading pip is a potential feature they're looking at. – Adam Sep 15 '18 at 02:25
  • I was just surprised that the Python 3.7 standard environment was actually much more flexible in its dependency installation than the Python 3.6 flex env. There is another issue with custom packages that the standard env handles that the flex doesn't. – Adam Sep 15 '18 at 02:27
0

At least since Python 3.9, and higher I have been routinely including the following in my Dockerfile for standard environment.

# Install production dependencies.
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

(and then you can run Cython after that).

Tunneller
  • 381
  • 2
  • 13