@@ -52,15 +52,15 @@ function python_version::read_requested_python_version() {
52
52
53
53
local runtime_txt_path=" ${build_dir} /runtime.txt"
54
54
if [[ -f " ${runtime_txt_path} " ]]; then
55
- contents=" $( cat " ${runtime_txt_path} " ) "
55
+ contents=" $( cat --show-nonprinting " ${runtime_txt_path} " ) "
56
56
version=" $( python_version::parse_runtime_txt " ${contents} " ) "
57
57
origin=" runtime.txt"
58
58
return 0
59
59
fi
60
60
61
61
local python_version_file_path=" ${build_dir} /.python-version"
62
62
if [[ -f " ${python_version_file_path} " ]]; then
63
- contents=" $( cat " ${python_version_file_path} " ) "
63
+ contents=" $( cat --show-nonprinting " ${python_version_file_path} " ) "
64
64
version=" $( python_version::parse_python_version_file " ${contents} " ) "
65
65
origin=" .python-version"
66
66
return 0
@@ -106,23 +106,28 @@ function python_version::parse_runtime_txt() {
106
106
The following file contents were found, which aren't valid:
107
107
${contents: 0: 100}
108
108
109
- However, the runtime.txt file is deprecated since it has
110
- been replaced by the .python-version file. As such, we
111
- recommend that you switch to using a .python-version file
109
+ However, the runtime.txt file is deprecated since it has been
110
+ replaced by the more widely supported .python-version file.
111
+ As such, we recommend that you switch to using .python-version
112
112
instead of fixing your runtime.txt file.
113
113
114
114
Please delete your runtime.txt file and create a new file named:
115
115
.python-version
116
116
117
- Make sure to include the '.' at the start of the filename.
117
+ Make sure to include the '.' character at the start of the
118
+ filename. Don't add a file extension such as '.txt'.
118
119
119
- In the new file, specify your app's Python version without
120
- quotes or a 'python-' prefix. For example:
120
+ In the new file, specify your app's major Python version number
121
+ only. Don't include quotes or a 'python-' prefix.
122
+
123
+ For example, to request the latest version of Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
124
+ update your .python-version file so it contains exactly:
121
125
${DEFAULT_PYTHON_MAJOR_VERSION}
122
126
123
- We strongly recommend that you use the major version form
124
- instead of pinning to an exact version, since it will allow
125
- your app to receive Python security updates.
127
+ We strongly recommend that you don't specify the Python patch
128
+ version number, since it will pin your app to an exact Python
129
+ version and so stop your app from receiving security updates
130
+ each time it builds.
126
131
EOF
127
132
meta_set " failure_reason" " runtime-txt::invalid-version"
128
133
meta_set " failure_detail" " ${contents: 0: 50} "
@@ -160,19 +165,20 @@ function python_version::parse_python_version_file() {
160
165
${line}
161
166
162
167
However, the Python version must be specified as either:
163
- 1. The major version only: 3.X (recommended)
164
- 2. An exact patch version: 3.X.Y
168
+ 1. The major version only, for example: ${DEFAULT_PYTHON_MAJOR_VERSION} (recommended)
169
+ 2. An exact patch version, for example: ${DEFAULT_PYTHON_MAJOR_VERSION} .999
165
170
166
- Don't include quotes or a 'python-' prefix. To include
167
- comments, add them on their own line, prefixed with '#'.
171
+ Don't include quotes, a 'python-' prefix or wildcards. Any
172
+ code comments must be on a separate line prefixed with '#'.
168
173
169
174
For example, to request the latest version of Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
170
- update your .python-version file so it contains:
175
+ update your .python-version file so it contains exactly :
171
176
${DEFAULT_PYTHON_MAJOR_VERSION}
172
177
173
- We strongly recommend that you use the major version form
174
- instead of pinning to an exact version, since it will allow
175
- your app to receive Python security updates.
178
+ We strongly recommend that you don't specify the Python patch
179
+ version number, since it will pin your app to an exact Python
180
+ version and so stop your app from receiving security updates
181
+ each time it builds.
176
182
EOF
177
183
meta_set " failure_reason" " python-version-file::invalid-version"
178
184
meta_set " failure_detail" " ${line: 0: 50} "
@@ -185,10 +191,11 @@ function python_version::parse_python_version_file() {
185
191
186
192
No Python version was found in your .python-version file.
187
193
188
- Update the file so that it contains a valid Python version.
194
+ Update the file so that it contains your app's major Python
195
+ version number. Don't include quotes or a 'python-' prefix.
189
196
190
197
For example, to request the latest version of Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
191
- update your .python-version file so it contains:
198
+ update your .python-version file so it contains exactly :
192
199
${DEFAULT_PYTHON_MAJOR_VERSION}
193
200
194
201
If the file already contains a version, check the line doesn't
@@ -212,6 +219,10 @@ function python_version::parse_python_version_file() {
212
219
213
220
Update the file so it contains only one Python version.
214
221
222
+ For example, to request the latest version of Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
223
+ update your .python-version file so it contains exactly:
224
+ ${DEFAULT_PYTHON_MAJOR_VERSION}
225
+
215
226
If you have added comments to the file, make sure that those
216
227
lines begin with a '#', so that they are ignored.
217
228
EOF
@@ -278,15 +289,18 @@ function python_version::read_pipenv_python_version() {
278
289
${version}
279
290
280
291
However, the Python version must be specified as either:
281
- 1. The major version only: 3.X (recommended)
282
- 2. An exact patch version: 3.X.Y
292
+ 1. The major version only, for example: ${DEFAULT_PYTHON_MAJOR_VERSION} (recommended)
293
+ 2. An exact patch version, for example: ${DEFAULT_PYTHON_MAJOR_VERSION} .999
294
+
295
+ Wildcards aren't supported.
283
296
284
297
Please update your Pipfile to use a valid Python version and
285
298
then run 'pipenv lock' to regenerate Pipfile.lock.
286
299
287
- We strongly recommend that you use the major version form
288
- instead of pinning to an exact version, since it will allow
289
- your app to receive Python security updates.
300
+ We strongly recommend that you don't specify the Python patch
301
+ version number, since it will pin your app to an exact Python
302
+ version and so stop your app from receiving security updates
303
+ each time it builds.
290
304
291
305
For more information, see:
292
306
https://pipenv.pypa.io/en/stable/specifiers.html#specifying-versions-of-python
@@ -329,12 +343,21 @@ function python_version::resolve_python_version() {
329
343
Please upgrade to at least Python 3.${OLDEST_SUPPORTED_PYTHON_3_MINOR_VERSION} by configuring an
330
344
explicit Python version for your app.
331
345
332
- Create a .python-version file in the root directory of your
333
- app, that contains a Python version like:
334
- 3.${NEWEST_SUPPORTED_PYTHON_3_MINOR_VERSION}
346
+ Create a new file in the root directory of your app named:
347
+ .python-version
348
+
349
+ Make sure to include the '.' character at the start of the
350
+ filename. Don't add a file extension such as '.txt'.
351
+
352
+ In the new file, specify the new major Python version number
353
+ only. Don't include quotes or a 'python-' prefix.
335
354
336
- When creating this file make sure to include the '.' at the
337
- start of the filename.
355
+ For example, to request the latest version of Python 3.${OLDEST_SUPPORTED_PYTHON_3_MINOR_VERSION} ,
356
+ update your .python-version file so it contains exactly:
357
+ 3.${OLDEST_SUPPORTED_PYTHON_3_MINOR_VERSION}
358
+
359
+ If possible, we recommend upgrading all the way to Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
360
+ since it contains many performance and usability improvements.
338
361
EOF
339
362
else
340
363
output::error << -EOF
@@ -349,6 +372,9 @@ function python_version::resolve_python_version() {
349
372
350
373
Please upgrade to at least Python 3.${OLDEST_SUPPORTED_PYTHON_3_MINOR_VERSION} by changing the
351
374
version in your ${python_version_origin} file.
375
+
376
+ If possible, we recommend upgrading all the way to Python ${DEFAULT_PYTHON_MAJOR_VERSION} ,
377
+ since it contains many performance and usability improvements.
352
378
EOF
353
379
fi
354
380
meta_set " failure_reason" " python-version::eol"
@@ -464,7 +490,7 @@ function python_version::warn_if_patch_update_available() {
464
490
465
491
Update your ${python_version_origin} file to use the new version.
466
492
467
- We strongly recommend that you do not pin your app to an
493
+ We strongly recommend that you don't pin your app to an
468
494
exact Python version such as ${python_full_version} , and instead only specify
469
495
the major Python version of ${python_major_version} in your ${python_version_origin} file.
470
496
This will allow your app to receive the latest available Python
0 commit comments