summaryrefslogtreecommitdiff
path: root/config/software/asdf_python.rb
blob: 68cfd689e7beb51a3a57588f77abb07db5b37e72 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
# frozen_string_literal: true

name "asdf_python"
default_version "3.8.5"

dependency "bzip2"
dependency "libffi"
dependency "liblzma"
dependency "libsqlite3"
dependency "libuuid"
dependency "libyaml"
dependency "ncurses"
dependency "openssl"
dependency "zlib"

source url: "https://python.org/ftp/python/#{version}/Python-#{version}.tar.xz"
relative_path "Python-#{version}"

version("3.8.5") { source md5: "35b5a3d0254c1c59be9736373d429db7" }
version("3.8.4") { source md5: "e16df33cd7b58702e57e137f8f5d13e7" }
version("3.8.3") { source md5: "3000cf50aaa413052aef82fd2122ca78" }
version("3.8.2") { source md5: "e9d6ebc92183a177b8e8a58cad5b8d67" }
version("3.8.1") { source md5: "b3fb85fd479c0bf950c626ef80cacb57" }
version("3.8.0") { source md5: "dbac8df9d8b9edc678d0f4cacdb7dbb0" }
version("3.7.7") { source md5: "172c650156f7bea68ce31b2fd01fa766" }
version("3.7.6") { source md5: "c08fbee72ad5c2c95b0f4e44bf6fd72c" }
version("3.7.5") { source md5: "08ed8030b1183107c48f2092e79a87e2" }
version("3.7.4") { source md5: "d33e4aae66097051c2eca45ee3604803" }
version("3.7.3") { source md5: "93df27aec0cd18d6d42173e601ffbbfd" }
version("3.7.2") { source md5: "df6ec36011808205beda239c72f947cb" }
version("3.7.1") { source md5: "0a57e9022c07fad3dadb2eef58568edb" }
version("3.7.0") { source md5: "eb8c2a6b1447d50813c02714af4681f3" }
version("3.6.11") { source md5: "8f91c770b546a4938efbdb3064796c6c" }
version("3.5.9") { source md5: "ef7f82485e83c7f8f8bcb920a9c2457b" }
version("3.4.10") { source md5: "f88a98bce17a03c43a6a5f8a66ab2e62" }
version("3.3.7") { source md5: "84e2f12f044ca53b577f6224c53f82ac" }
version("3.2.6") { source md5: "e0ba4360dfcb4aec735e666cc0ae7b0e" }
version("3.1.5") { source md5: "20dd2b7f801dc97db948dd168df4dd52" }
version("3.0.1") { source md5: "7291eac6a9a7a3642e309c78b8d744e5" }

version("2.7.18") { source md5: "fd6cc8ec0a78c44036f825e739f36e5a" }

build do
  env = with_standard_compiler_flags(with_embedded_path)
  configure_command = [
    "--enable-shared",
    "--enable-ipv6",
    "--prefix=#{install_dir}/embedded",
    "--with-ssl=#{install_dir}/embedded",
    "--with-dbmliborder=",
    "--without-dtrace",
    "--without-valgrind"
  ]
  configure(*configure_command, env: env)
  make "-j #{workers}", env: env
  make "-j #{workers} install", env: env
  command "ln -s #{install_dir}/embedded/bin #{install_dir}/bin", env: env

  if version.start_with?('3.')
    command "ln -s #{install_dir}/bin/python3 #{install_dir}/bin/python", env: env
    command "ln -s #{install_dir}/bin/pip3 #{install_dir}/bin/pip", env: env
  end

  case version
  when /^3\.3\./
    command "curl https://bootstrap.pypa.io/3.3/get-pip.py -o #{project_dir}/get-pip.py", env: env
    command "#{install_dir}/bin/python #{project_dir}/get-pip.py \"pip==10.0.1\"", env: env
    command "#{install_dir}/bin/pip install pipenv virtualenv", env: env
  when /^3\.4\./
    command "#{install_dir}/bin/pip install pipenv==11.1.6 virtualenv", env: env
  when /^2\.7\./
    command "curl https://bootstrap.pypa.io/2.6/get-pip.py -o #{project_dir}/get-pip.py", env: env
    command "#{install_dir}/bin/python #{project_dir}/get-pip.py \"pip<20.0\"", env: env
    command "#{install_dir}/bin/pip install pipenv virtualenv", env: env
  else
    command "#{install_dir}/bin/pip install pipenv virtualenv", env: env
  end

  if version == default_version
    command "#{install_dir}/bin/pip install conan", env: env
    command "#{install_dir}/bin/conan --version", env: env
  end
  command "#{install_dir}/bin/pip --version", env: env
  command "#{install_dir}/bin/pipenv --version", env: env
  command "#{install_dir}/bin/virtualenv --version", env: env
end

build do
  command "find #{install_dir} -type f -name '*.exe' -exec rm {} +"
  command "find #{install_dir} -type d -name '__pycache__' -exec rm -r {} +"
  command "find #{install_dir} -type d -name 'test' -exec rm -r {} +"
  command "find #{install_dir} -type d -name 'tests' -exec rm -r {} +"
  delete "#{install_dir}/embedded/bin/sqlite3"
  delete "#{install_dir}/embedded/lib/python*/unittest"
  delete "#{install_dir}/embedded/lib/python*/lib-dynload/_bsddb*"
  delete "#{install_dir}/embedded/lib/python*/lib-dynload/readline*"
  delete "#{install_dir}/embedded/man"
  delete "#{install_dir}/embedded/share"
end