8000 Remove EOL Python code, set 3.9 as base, add 3.14 stdlib module (#317) · actions/python-versions@d5e8ad6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5e8ad6

Browse files
authored
Remove EOL Python code, set 3.9 as base, add 3.14 stdlib module (#317)
* Remove redundant Python 2 code * Use Python 3.2 as base version * Use Python 3.3 as base version * Use Python 3.4 as base version * Use Python 3.5 as base version * Use Python 3.6 as base version * Use Python 3.7 as base version * Use Python 3.8 as base version * Use Python 3.9 as base version * Add annotationlib for Python 3.14 * Fix syntax error
1 parent 5c01d17 commit d5e8ad6

File tree

8 files changed

+39
-155
lines changed

8 files changed

+39
-155
lines changed

builders/macos-python-builder.psm1

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ class macOSPythonBuilder : NixPythonBuilder {
3131
.SYNOPSIS
3232
Prepare system environment by installing dependencies and required packages.
3333
#>
34-
35-
if ($this.Version -eq "3.7.17") {
36-
# We have preinstalled ncurses and readLine on the hoster runners. But we need to install bzip2 for
37-
# setting up an environemnt
38-
# If we get any issues realted to ncurses or readline we can try to run this command
39-
# brew install ncurses readline
40-
Execute-Command -Command "brew install bzip2"
41-
}
4234
}
4335

4436
[void] Configure() {
@@ -58,46 +50,20 @@ class macOSPythonBuilder : NixPythonBuilder {
5850
### will never be used itself by a Github Actions runner but using a universal2 Python is the only way to build
5951
### universal2 C extensions and wheels. This is supported by Python >= 3.10 and was backported to Python >=
6052
### 3.9.1 and >= 3.8.10.
61-
### Disabled, discussion: https://github.com/actions/python-versions/pull/114
62-
# if ($this.Version -ge "3.8.10" -and $this.Version -ne "3.8.13" -and $this.Version -ne "3.9.0" ) {
63-
# $configureString += " --enable-universalsdk --with-universal-archs=universal2"
64-
# }
6553

6654
### OS X 10.11, Apple no longer provides header files for the deprecated system version of OpenSSL.
6755
### Solution is to install these libraries from a third-party package manager,
6856
### and then add the appropriate paths for the header and library files to configure command.
6957
### Link to documentation (https://cpython-devguide.readthedocs.io/setup/#build-dependencies)
70-
if ($this.Version -lt "3.7.0") {
71-
$env:LDFLAGS = "-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/zlib/lib"
72-
$env:CFLAGS = "-I/usr/local/opt/openssl@3/include -I/usr/local/opt/zlib/include"
73-
} else {
74-
$configureString += " --with-openssl=/usr/local/opt/openssl@3"
75-
76-
# For Python 3.7.2 and 3.7.3 we need to provide PATH for zlib to pack it properly. Otherwise the build will fail
77-
# with the error: zipimport.ZipImportError: can't decompress data; zlib not available
78-
if ($this.Version -eq "3.7.2" -or $this.Version -eq "3.7.3" -or $this.Version -eq "3.7.17") {
79-
$env:LDFLAGS = "-L/usr/local/opt/zlib/lib"
80-
$env:CFLAGS = "-I/usr/local/opt/zlib/include"
81-
}
82-
83-
# if ($this.Version -gt "3.7.12") {
84-
$configureString += " --with-tcltk-includes='-I /usr/local/opt/tcl-tk/include/tcl-tk' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
85-
# }
86-
87-
if ($this.Version -eq "3.7.17") {
88-
$env:LDFLAGS += " -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib"
89-
$env:CFLAGS += " -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(brew --prefix ncurses)/include"
90-
}
91-
}
58+
$configureString += " --with-openssl=/usr/local/opt/openssl@3"
59+
$configureString += " --with-tcltk-includes='-I /usr/local/opt/tcl-tk/include/tcl-tk' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
9260

93-
### Compile with support of loadable sqlite extensions. Unavailable for Python 2.*
61+
### Compile with support of loadable sqlite extensions.
9462
### Link to documentation (https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension)
95-
if ($this.Version -ge "3.2.0") {
96-
$configureString += " --enable-loadable-sqlite-extensions"
97-
$env:LDFLAGS += " -L$(brew --prefix sqlite3)/lib"
98-
$env:CFLAGS += " -I$(brew --prefix sqlite3)/include"
99-
$env:CPPFLAGS += "-I$(brew --prefix sqlite3)/include"
100-
}
63+
$configureString += " --enable-loadable-sqlite-extensions"
64+
$env:LDFLAGS += " -L$(brew --prefix sqlite3)/lib"
65+
$env:CFLAGS += " -I$(brew --prefix sqlite3)/include"
66+
$env:CPPFLAGS += "-I$(brew --prefix sqlite3)/include"
10167

10268
Write-Host "The passed configure options are: "
10369
Write-Host $configureString

builders/nix-python-builder.psm1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class NixPythonBuilder : PythonBuilder {
6161
Return name of Python binary.
6262
#>
6363

64-
if ($this.Version.Major -eq 2) { $pythonBinary = "python" } else { $pythonBinary = "python3" }
65-
return $pythonBinary
64+
return "python3"
6665
}
6766

6867
[string] Download() {

builders/ubuntu-python-builder.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class UbuntuPythonBuilder : NixPythonBuilder {
6161
Prepare system environment by installing dependencies and required packages.
6262
#>
6363

64-
if ($this.Version -lt "3.5.3") {
65-
Write-Host "Python versions lower than 3.5.3 are not supported"
64+
if ($this.Version -lt "3.9.0") {
65+
Write-Host "Python versions lower than 3.9.0 are not supported"
6666
exit 1
6767
}
6868

builders/win-python-builder.psm1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class WinPythonBuilder : PythonBuilder {
4242
Return extension for required version of Python executable.
4343
#>
4444

45-
$extension = if ($this.Version -lt "3.5" -and $this.Version -ge "2.5") { ".msi" } else { ".exe" }
46-
47-
return $extension
45+
return ".exe"
4846
}
4947

5048
[string] GetArchitectureExtension() {
@@ -55,11 +53,7 @@ class WinPythonBuilder : PythonBuilder {
5553

5654
$ArchitectureExtension = ""
5755
if ($this.GetHardwareArchitecture() -eq "x64") {
58-
if ($this.Version -ge "3.5") {
59-
$ArchitectureExtension = "-amd64"
60-
} else {
61-
$ArchitectureExtension = ".amd64"
62-
}
56+
$ArchitectureExtension = "-amd64"
6357
} elseif ($this.GetHardwareArchitecture() -eq "arm64") {
6458
$ArchitectureExtension = "-arm64"
6559
}

installers/win-setup-template.ps1

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ function Get-RegistryVersionFilter {
1111
)
1212

1313
$archFilter = if ($Architecture -eq 'x86') { "32-bit" } else { "64-bit" }
14-
### Python 2.7 x86 have no architecture postfix
15-
if (($Architecture -eq "x86") -and ($MajorVersion -eq 2)) {
16-
"Python $MajorVersion.$MinorVersion.\d+$"
17-
} else {
18-
"Python $MajorVersion.$MinorVersion.*($archFilter)"
19-
}
14+
"Python $MajorVersion.$MinorVersion.*($archFilter)"
2015
}
2116

2217
function Remove-RegistryEntries {
@@ -143,9 +138,7 @@ if ($IsFreeThreaded) {
143138
}
144139

145140
Write-Host "Create `python3` symlink"
146-
if ($MajorVersion -ne "2") {
147-
New-Item -Path "$PythonArchPath\python3.exe" -ItemType SymbolicLink -Value "$PythonArchPath\python.exe"
148-
}
141+
New-Item -Path "$PythonArchPath\python3.exe" -ItemType SymbolicLink -Value "$PythonArchPath\python.exe"
149142

150143
Write-Host "Install and upgrade Pip"
151144
$Env:PIP_ROOT_USER_ACTION = "ignore"

tests/python-tests.ps1

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Describe "Tests" {
6060
# }
6161
# }
6262

63-
if (($Version -ge "3.2.0") -and ($Version -lt "3.11.0") -and (($Platform -ne "darwin") -or ($HardwareArchitecture -ne "arm64"))) {
63+
if (($Version -lt "3.11.0") -and (($Platform -ne "darwin") -or ($HardwareArchitecture -ne "arm64"))) {
6464
It "Check if sqlite3 module is installed" {
6565
"python ./sources/python-sqlite3.py" | Should -ReturnZeroExitCode
6666
}
@@ -92,16 +92,6 @@ Describe "Tests" {
9292
}
9393
}
9494

95-
# Pyinstaller 3.5 does not support Python 3.8.0. Check issue https://github.com/pyinstaller/pyinstaller/issues/4311
96-
if ($Version -lt "3.8.0" -and $Version.Major -ne "2") {
97-
It "Validate Pyinstaller" {
98-
"pip install pyinstaller" | Should -ReturnZeroExitCode
99-
"pyinstaller --onefile ./sources/simple-test.py" | Should -ReturnZeroExitCode
100-
$distPath = [IO.Path]::Combine($pwd, "dist", "simple-test")
101-
"$distPath" | Should -ReturnZeroExitCode
102-
}
103-
}
104-
10595
It "Check urlopen with HTTPS works" {
10696
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
10797
}

tests/sources/python-modules.py

Lines changed: 23 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
This is needed for Linux since we build from source.
44
"""
55

6-
from __future__ import print_function
7-
86
import importlib
97
import sys
108

11-
# The Python standard library as of Python 3.0
9+
# The Python standard library as of Python 3.9
1210
standard_library = [
1311
'abc',
1412
'aifc',
@@ -17,6 +15,7 @@
1715
'ast',
1816
'asynchat',
1917
'asyncore',
18+
'asyncio',
2019
'base64',
2120
'bdb',
2221
'binhex',
@@ -34,24 +33,29 @@
3433
'collections',
3534
'colorsys',
3635
'compileall',
36+
'concurrent',
3737
'configparser',
3838
'contextlib',
39+
'contextvars',
3940
'copy',
4041
'copyreg',
4142
'crypt',
4243
'csv',
4344
'ctypes',
4445
'curses',
46+
'dataclasses',
4547
'datetime',
4648
'dbm',
4749
'decimal',
4850
'difflib',
4951
'dis',
5052
'distutils',
5153
'doctest',
52-
'dummy_threading',
5354
'email',
5455
'encodings',
56+
'ensurepip',
57+
'enum',
58+
'faulthandler',
5559
'filecmp',
5660
'fileinput',
5761
'fnmatch',
@@ -77,13 +81,14 @@
7781
'importlib',
7882
'inspect',
7983
'io',
84+
'ipaddress',
8085
'json',
8186
'keyword',
8287
'lib2to3',
8388
'linecache',
8489
'locale',
8590
'logging',
86-
'macpath',
91+
'lzma',
8792
'mailbox',
8893
'mailcap',
8994
'mimetypes',
@@ -98,6 +103,7 @@
98103
'operator',
99104
'optparse',
100105
'os',
106+
'pathlib',
101107
'pdb',
102108
'pickle',
103109
'pickletools',
@@ -124,6 +130,8 @@
124130
'rlcompleter',
125131
'runpy',
126132
'sched',
133+
'secrets',
134+
'selectors',
127135
'shelve',
128136
'shlex',
129137
'shutil',
@@ -141,6 +149,7 @@
141149
'ssl',
142150
'_ssl',
143151
'stat',
152+
'statistics',
144153
'string',
145154
'stringprep',
146155
'struct',
@@ -163,14 +172,17 @@
163172
'tokenize',
164173
'trace',
165174
'traceback',
175+
'tracemalloc',
166176
'tty',
167177
'turtle',
168178
'turtledemo',
169179
'types',
180+
'typing',
170181
'unittest',
171182
'urllib',
172183
'uu',
173184
'uuid',
185+
'venv',
174186
'warnings',
175187
'wave',
176188
'weakref',
@@ -179,83 +191,12 @@
179191
'xdrlib',
180192
'xml',
181193
'xmlrpc',
194+
'zipapp',
182195
'zipfile'
183196
]
184197

185-
# Modules that had different names in Python 2
186-
if sys.version_info.major == 2:
187-
def replace(lst, old, new):
188-
lst[lst.index(old)] = new
189-
190-
# Keys are the Python 2 names
191-
# Values are the Python 3 names
192-
renames = {
193-
'ConfigParser': 'configparser',
194-
'copy_reg': 'copyreg',
195-
'HTMLParser': 'html',
196-
'httplib': 'http',
197-
'Queue': 'queue',
198-
'repr': 'reprlib',
199-
'SocketServer': 'socketserver',
200-
'xmlrpclib': 'xmlrpc',
201-
'Tkinter': 'tkinter'
202-
}
203-
204-
# All of the Python 3 names should be in the list
205-
for python2name, python3name in renames.items():
206-
replace(standard_library, python3name, python2name)
207-
208198
# Add new modules
209199
# See https://docs.python.org/3/whatsnew/index.html
210-
if sys.version_info >= (3, 2):
211-
standard_library.extend([
212-
'concurrent',
213-
])
214-
215-
if sys.version_info >= (3, 3):
216-
standard_library.extend([
217-
'ipaddress',
218-
'faulthandler',
219-
'lzma',
220-
'venv',
221-
])
222-
223-
if sys.version_info >= (3, 4):
224-
standard_library.extend([
225-
'asyncio',
226-
'ensurepip',
227-
'enum',
228-
'pathlib',
229-
'selectors',
230-
'statistics',
231-
'tracemalloc',
232-
])
233-
234-
if sys.version_info >= (3, 5):
235-
standard_library.extend([
236-
'typing',
237-
'zipapp',
238-
])
239-
240-
if sys.version_info >= (3, 6):
241-
standard_library.extend([
242-
'secrets',
243-
])
244-
245-
if sys.version_info >= (3, 7):
246-
standard_library.extend([
247-
'contextvars',
248-
'dataclasses',
249-
])
250-
251-
# 'macpath' module has been removed from Python 3.8
252-
if sys.version_info > (3, 7):
253-
standard_library.remove('macpath')
254-
255-
# 'dummy_threading' module has been removed from Python 3.9
256-
if sys.version_info > (3, 8):
257-
standard_library.remove('dummy_threading')
258-
259200
# 'symbol' and 'formatter' modules have been removed from Python 3.10
260201
if sys.version_info >= (3, 10):
261202
standard_library.remove('symbol')
@@ -295,6 +236,11 @@ def replace(lst, old, new):
295236
standard_library.remove('uu')
296237
standard_library.remove('xdrlib')
297238

239+
if sys.version_info >= (3, 14):
240+
standard_library.extend([
241+
'annotationlib',
242+
])
243+
298244
# Remove tkinter and Easter eggs
299245
excluded_modules = [
300246
'antigravity',

tests/sources/python-urlopen-https.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import sys
2-
3-
if sys.version_info[0] == 2:
4-
from urllib2 import urlopen
5-
else:
6-
from urllib.request import urlopen
2+
from urllib.request import urlopen
73

84
response = urlopen("https://raw.githubusercontent.com/actions/python-versions/c641695f6a07526c18f10e374e503e649fef9427/.gitignore")
95
data = response.read()

0 commit comments

Comments
 (0)
0