-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathxtkinter.py
More file actions
124 lines (96 loc) · 3.74 KB
/
xtkinter.py
File metadata and controls
124 lines (96 loc) · 3.74 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
Building Tcl/Tk statically is **best-effort** only, Tcl/Tk is hard to compile... especially on linux
It is also unclear what version to use, which build docs to follow etc.
Contributions are welcome!
"""
from typing import ClassVar
import runez
from portable_python import ModuleBuilder, PPG
class Tcl(ModuleBuilder):
"""
Known issues:
- macos: Symbol not found: _CGAffineTransformIdentity
- linux: needs X11 libs? xproto?
"""
m_build_cwd = "unix"
@property
def url(self):
return f"https://prdownloads.sourceforge.net/tcl/tcl{self.version}-src.tar.gz"
def _prepare(self):
for path in runez.ls_dir(self.m_src_build / "pkgs"):
if path.name.startswith(("sqlite", "tdbc")): # pragma: no cover, tcl/tk is "best effort"
# Remove packages we don't care about and can pull in unwanted symbols
runez.delete(path)
def _do_linux_compile(self):
self.run_configure("./configure", "--enable-shared=no", "--enable-threads")
self.run_make()
self.run_make("install")
self.run_make("install-private-headers")
class Tk(ModuleBuilder):
m_build_cwd = "unix"
@property
def url(self):
return f"https://prdownloads.sourceforge.net/tcl/tk{self.version}-src.tar.gz"
# noinspection PyPep8Naming
# noinspection PyMethodMayBeStatic
def xenv_CFLAGS(self):
yield f"-I{self.deps}/include"
def c_configure_args(self):
yield "--enable-shared=no"
yield "--enable-threads"
yield f"--with-tcl={self.deps_lib_dir}"
yield "--without-x"
if PPG.target.is_macos: # pragma: no cover, tcl/tk is "best effort"
yield "--enable-aqua=yes"
def _do_linux_compile(self):
self.run_configure("./configure", self.c_configure_args())
self.run_make()
runez.touch("wish")
self.run_make("install")
self.run_make("install-private-headers")
class Tix(ModuleBuilder):
"""
What is tix, and why is it needed?
"""
@property
def url(self):
return f"https://github.com/python/cpython-source-deps/archive/tix-{self.version}.tar.gz"
@property
def version(self):
# Effectively dead project, no updates expected
# Check https://github.com/python/cpython-source-deps (tix-* tags)
return self.cfg_version("8.4.3.6")
# noinspection PyPep8Naming
def xenv_CFLAGS(self):
# Needed to avoid error: Getting no member named 'result' in 'struct Tcl_Interp'
yield "-DUSE_INTERP_RESULT"
yield "-Wno-implicit-function-declaration" # Allows to not fail compilation due to missing 'panic' symbol
yield f"-I{self.deps}/include"
def c_configure_args(self):
yield "--enable-shared=no"
yield "--enable-threads"
yield f"--with-tcl={self.deps_lib_dir}"
yield f"--with-tk={self.deps_lib_dir}"
yield "--without-x"
def _do_linux_compile(self):
self.run_configure("/bin/sh configure", self.c_configure_args())
self.run_make()
self.run_make("install")
class TkInter(ModuleBuilder):
"""
Try and build tcl/tk
Known issues:
- macos: 8.6.10 seems to compile, but cpython ./configure script still picks up the macos shared tcl/tk libs
- linux: X11 required, not sure what else
"""
m_debian = "-tk-dev"
m_telltale: ClassVar[list] = ["{include}/tk", "{include}/tk.h"]
@classmethod
def candidate_modules(cls):
return [Tcl, Tk, Tix]
@property
def version(self):
# This is the Tcl/Tk version used by Tcl, Tk, and Tix sub-modules
# Staying on 8.6.x branch (9.0+ is a major rewrite)
# Check https://www.tcl-lang.org/software/tcltk/8.6.html
return self.cfg_version("8.6.17")