Python Version for Custom Build

When I visit this documentation page it reads that netlify supports python 3.6 as long as I add it to runtime.txt

So I did that. My runtime.txt file is a single line file that contains 3.6. Still ā€¦ it gave me a strange error.

8:52:07 PM: Waiting for other deploys from your team to complete
8:52:16 PM: Build ready to start
8:52:17 PM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
8:52:17 PM: build-image tag: v3.3.5
8:52:17 PM: buildbot version: 2d05064ce3dd2eb95d282a24602ab707dd9581e8
8:52:18 PM: Fetching cached dependencies
8:52:18 PM: Starting to download cache of 60.0MB
8:52:18 PM: Finished downloading cache in 456.895954ms
8:52:18 PM: Starting to extract cache
8:52:20 PM: Finished extracting cache in 2.076996924s
8:52:20 PM: Finished fetching cache in 2.565305067s
8:52:20 PM: Starting to prepare the repo for build
8:52:21 PM: Preparing Git Reference merge-requests/2/head
8:52:22 PM: Found Netlify configuration file. Overriding site configuration
8:52:22 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'bash ./netlify.sh' versus '' in the Netlify UI
8:52:22 PM: Starting build script
8:52:22 PM: Installing dependencies
8:52:22 PM: /usr/local/bin/run-build-functions.sh: line 170: /opt/buildhome/python3.6/bin/activate: No such file or directory
8:52:22 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
8:52:22 PM: Error setting python version from runtime.txt
8:52:22 PM: Please see https://github.com/netlify/build-image/#included-software for current versions
8:52:22 PM: Error running command: Build script returned non-zero exit code: 1
8:52:22 PM: Failing build: Failed to build site
8:52:22 PM: Shutting down logging, 1 messages pending

This suggests that python3.6 cannot be selected. Have I done something wrong?

I have now fixed it by doing it manually after checking this repo. But it feels dangerous.

  1. Why is 3.7 not listed on the docs?
  2. Will this trick continue to work in the future?
source /opt/buildhome/python3.7/bin/activate
pip install -r requirements.txt
npm install purgecss uglifycss
python3 automate.py populate-html
./node_modules/.bin/purgecss --css css/tailwind.min.css css/bootstrap.min.css --content src/*.html --out src
./node_modules/.bin/uglifycss src/tailwind.min.css src/bootstrap.min.css > src/style.css

Context; automate.py is a command line app that contains populate-html as a command.

Hi @koaning, our build-image is in active development and can get updated frequently which means that the docs can sometimes be out of sync. Thanks for pointing it out.

Regarding your fix, Iā€™m not clear on what you did and why you feel it is dangerous. Can you provide more context on why you feel this way?

1 Like

Let me rephrase; what are the odds of my script breaking? When production is not in line with the documentation ā€¦ that is a bit scary.

@koaning the versions are kept up to in the build-image repo in the following file: https://github.com/netlify/build-image/blob/xenial/included_software.md

Blog posts like the one you linked to are not usually updated but we do try to update our documentation.

You can use python 3.7 in the Xenial image. We do not include 3.6 though, just 2.7, 3.5, and 3.7.