forked from actions/python-versions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntu-python-builder.psm1
87 lines (69 loc) · 2.72 KB
/
ubuntu-python-builder.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using module "./nix-python-builder.psm1"
class UbuntuPythonBuilder : NixPythonBuilder {
<#
.SYNOPSIS
Ubuntu Python builder class.
.DESCRIPTION
Contains methods that required to build Ubuntu Python artifact from sources. Inherited from base NixPythonBuilder.
.PARAMETER platform
The full name of platform for which Python should be built.
.PARAMETER version
The version of Python that should be built.
#>
UbuntuPythonBuilder(
[semver] $version,
[string] $architecture,
[string] $platform
) : Base($version, $architecture, $platform) { }
[void] Configure() {
<#
.SYNOPSIS
Execute configure script with required parameters.
#>
$pythonBinariesLocation = $this.GetFullPythonToolcacheLocation()
### To build Python with SO, passing relative path W.r.t to the binary location.
$env:LIBS = "-Wl,--enable-new-dtags,-rpath='`$`$ORIGIN/../lib'"
$configureString = "./configure"
$configureString += " --prefix=$pythonBinariesLocation"
$configureString += " --enable-shared"
$configureString += " --enable-optimizations"
### Compile with support of loadable sqlite extensions.
### Link to documentation (https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension)
$configureString += " --enable-loadable-sqlite-extensions"
Write-Host "The passed configure options are: "
Write-Host $configureString
Write-Host "LIBS: $env:LIBS"
Execute-Command -Command $configureString
}
[void] PrepareEnvironment() {
<#
.SYNOPSIS
Prepare system environment by installing dependencies and required packages.
#>
if ($this.Version -lt "3.5.3") {
Write-Host "Python versions lower than 3.5.3 are not supported"
exit 1
}
### Compile with tkinter support
$tkinterInstallString = "sudo apt-get install -y --allow-downgrades python3-tk tk-dev"
Execute-Command -Command "sudo apt-get update"
Execute-Command -Command $tkinterInstallString
### Install dependent packages
@(
"make",
"build-essential",
"libssl-dev",
"zlib1g-dev",
"libbz2-dev",
"libsqlite3-dev",
"libncursesw5-dev",
"libreadline-dev",
"libgdbm-dev",
"liblzma-dev"
) | ForEach-Object {
Execute-Command -Command "sudo apt install -y $_"
}
### On Ubuntu-1804, libgdbm-compat-dev has older modules that are no longer in libgdbm-dev
Execute-Command -Command "sudo apt install -y libgdbm-compat-dev"
}
}