Updates pip from 20.0.2 to 20.1.1 for Python 2.7 and Python 3.5+: https://pip.pypa.io/en/stable/news/#id40 The version used for Python 3.4 remains unchanged at 19.1.1, since it's the last version of pip that supports it. Pip has been updated to 20.1.1 rather than the recently released 20.2, since the latter has a few regressions and even though these will be fixed shortly in 20.2.1, we should let the changes soak for longer before picking them up. The `PIP_NO_PYTHON_VERSION_WARNING` environment variable has been set (equivalent to passing `--no-python-version-warning`) to prevent the Python 2.7 EOL warnings added in pip 20.1 from spamming the build log: https://github.com/pypa/pip/blob/20.1.1/src/pip/_internal/cli/base_command.py#L139-L154 This was set via environment variable rather than CLI flag, since: * otherwise we'd have to pass it to every pip invocation * older pip (such as the 19.1.1 used by Python 3.4) doesn't support this option and would error out due to an unknown CLI flag being passed, unless we added conditional flags throughout. The new pip wheel was uploaded to S3 using: ``` $ pip download --no-cache pip==20.1.1 Collecting pip==20.1.1 Downloading pip-20.1.1-py2.py3-none-any.whl (1.5 MB) Saved ./pip-20.1.1-py2.py3-none-any.whl Successfully downloaded pip $ aws s3 sync . s3://lang-python/common/ --exclude "*" --include "*.whl" --acl public-read --dryrun (dryrun) upload: ./pip-20.1.1-py2.py3-none-any.whl to s3://lang-python/common/pip-20.1.1-py2.py3-none-any.whl $ aws s3 sync . s3://lang-python/common/ --exclude "*" --include "*.whl" --acl public-read upload: ./pip-20.1.1-py2.py3-none-any.whl to s3://lang-python/common/pip-20.1.1-py2.py3-none-any.whl ``` Fixes #1005. @W-7659489@
Heroku Buildpack: Python
This is the official Heroku buildpack for Python apps.
Recommended web frameworks include Django and Flask, among others. The recommended webserver is Gunicorn. There are no restrictions around what software can be used (as long as it's pip-installable). Web processes must bind to $PORT, and only the HTTP protocol is permitted for incoming connections.
Python packages with C dependencies that are not available on the stack image are generally not supported, unless manylinux wheels are provided by the package maintainers (common). For recommended solutions, check out this article for more information.
See it in Action
$ ls
my-application requirements.txt runtime.txt
$ git push heroku main
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 276 bytes | 276.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting flask (from -r /tmp/build_c2c067ef79ff14c9bf1aed6796f9ed1f/requirements.txt (line 1))
remote: Downloading ...
remote: Installing collected packages: Werkzeug, click, MarkupSafe, Jinja2, itsdangerous, flask
remote: Successfully installed Jinja2-2.10 MarkupSafe-1.1.0 Werkzeug-0.14.1 click-7.0 flask-1.0.2 itsdangerous-1.1.0
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote:
A requirements.txt must be present at the root of your application's repository to deploy.
To specify your python version, you also need a runtime.txt file - unless you are using the default Python runtime version.
Current default Python Runtime: Python 3.6.9
Alternatively, you can provide a setup.py file, or a Pipfile.
Using pipenv will generate runtime.txt at build time if one of the field python_version or python_full_version is specified in the requires section of your Pipfile.
Specify a Buildpack Version
You can specify the latest production release of this buildpack for upcoming builds of an existing application:
$ heroku buildpacks:set heroku/python
Specify a Python Runtime
Supported runtime options include:
python-3.8.5python-3.7.8python-3.6.11python-2.7.18
Tests
The buildpack tests use Docker to simulate Heroku's stack images.
To run the test suite against the default stack:
make test
Or to test against a particular stack:
make test STACK=heroku-16
To run only a subset of the tests:
make test TEST_CMD=tests/versions
The tests are run via the vendored shunit2 test framework.
