Skip to content

Commit 8787f88

Browse files
committed
linux: build _tkinter extension
The last commit did the heavy lifting of getting tcl/tk built from source. This commit puts the final touches on things so we can enable the _tkinter extension module. We had to tweak the tcl/tk build settings a bit. We also defined missing license annotations for those packages. With this commit `import tkinter` works from a standalone executable! Although there may be some paths leaking into the binary creating problems for compatibility on different distros. But at least we're past the milestone of building the extension!
1 parent 27bd3fa commit 8787f88

File tree

7 files changed

+60
-4
lines changed

7 files changed

+60
-4
lines changed

LICENSE.tcl.txt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This software is copyrighted by the Regents of the University of
2+
California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
3+
Corporation and other parties. The following terms apply to all files
4+
associated with the software unless explicitly disclaimed in
5+
individual files.
6+
7+
The authors hereby grant permission to use, copy, modify, distribute,
8+
and license this software and its documentation for any purpose, provided
9+
that existing copyright notices are retained in all copies and that this
10+
notice is included verbatim in any distributions. No written agreement,
11+
license, or royalty fee is required for any of the authorized uses.
12+
Modifications to this software may be copyrighted by their authors
13+
and need not follow the licensing terms described here, provided that
14+
the new terms are clearly indicated on the first page of each file where
15+
they apply.
16+
17+
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
18+
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
19+
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
20+
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
21+
POSSIBILITY OF SUCH DAMAGE.
22+
23+
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
24+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
26+
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
27+
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
28+
MODIFICATIONS.
29+
30+
GOVERNMENT USE: If you are acquiring this software on behalf of the
31+
U.S. government, the Government shall have only "Restricted Rights"
32+
in the software and related documentation as defined in the Federal
33+
Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
34+
are acquiring the software on behalf of the Department of Defense, the
35+
software shall be classified as "Commercial Computer Software" and the
36+
Government shall have only "Restricted Rights" as defined in Clause
37+
252.227-7014 (b) (3) of DFARs. Notwithstanding the foregoing, the
38+
authors grant the U.S. Government and others acting in its behalf
39+
permission to use and distribute the software in accordance with the
40+
terms specified in this license.

cpython-linux/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,16 @@ PYTHON_DEPENDS := \
171171
$(OUTDIR)/gdbm-$(GDBM_VERSION)-$(PLATFORM).tar \
172172
$(OUTDIR)/libedit-$(LIBEDIT_VERSION)-$(PLATFORM).tar \
173173
$(OUTDIR)/libffi-$(LIBFFI_VERSION)-$(PLATFORM).tar \
174+
$(OUTDIR)/libX11-$(LIBX11_VERSION)-$(PLATFORM).tar \
175+
$(OUTDIR)/libXau-$(LIBXAU_VERSION)-$(PLATFORM).tar \
176+
$(OUTDIR)/libxcb-$(LIBXCB_VERSION)-$(PLATFORM).tar \
174177
$(OUTDIR)/ncurses-$(NCURSES_VERSION)-$(PLATFORM).tar \
175178
$(OUTDIR)/readline-$(READLINE_VERSION)-$(PLATFORM).tar \
176179
$(OUTDIR)/sqlite-$(SQLITE_VERSION)-$(PLATFORM).tar \
177180
$(OUTDIR)/tcl-$(TCL_VERSION)-$(PLATFORM).tar \
178181
$(OUTDIR)/tk-$(TK_VERSION)-$(PLATFORM).tar \
179182
$(OUTDIR)/uuid-$(UUID_VERSION)-$(PLATFORM).tar \
183+
$(OUTDIR)/xorgproto-$(XORGPROTO_VERSION)-$(PLATFORM).tar \
180184
$(OUTDIR)/xz-$(XZ_VERSION)-$(PLATFORM).tar \
181185
$(OUTDIR)/zlib-$(ZLIB_VERSION)-$(PLATFORM).tar \
182186
$(HERE)/static-modules \

cpython-linux/build-tcl.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig:/tools/deps/lib/pkgconfig
1313
tar -xf tcl8.6.9-src.tar.gz
1414
pushd tcl8.6.9/unix
1515
CFLAGS="-fPIC -I/tools/deps/include" ./configure \
16-
--prefix=/tools/deps
16+
--prefix=/tools/deps \
17+
--enable-shared=no
18+
1719
make -j `nproc`
1820
make -j `nproc` install DESTDIR=/build/out

cpython-linux/build-tk.sh

+1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ CFLAGS="-fPIC" ./configure \
1919
--x-libraries=/tools/deps/lib \
2020
--with-tcl=/tools/deps/lib \
2121
--enable-shared=no
22+
2223
make -j `nproc`
2324
make -j `nproc` install DESTDIR=/build/out

cpython-linux/build.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,7 @@ def build_cpython(client, image, platform, debug=False, optimized=False, musl=Fa
666666

667667
setup = derive_setup_local(static_modules_lines, python_archive,
668668
python_version=entry['version'],
669-
musl=musl, debug=debug,
670-
disabled={b'_tkinter'})
669+
musl=musl, debug=debug)
671670

672671
config_c_in = parse_config_c(setup['config_c_in'].decode('utf-8'))
673672
setup_dist_content = setup['setup_dist']
@@ -686,6 +685,9 @@ def build_cpython(client, image, platform, debug=False, optimized=False, musl=Fa
686685
install_tools_archive(container, archive_path('bzip2', platform, musl=musl))
687686
install_tools_archive(container, archive_path('libedit', platform, musl=musl))
688687
install_tools_archive(container, archive_path('libffi', platform, musl=musl))
688+
install_tools_archive(container, archive_path('libX11', platform, musl=musl))
689+
install_tools_archive(container, archive_path('libXau', platform, musl=musl))
690+
install_tools_archive(container, archive_path('libxcb', platform, musl=musl))
689691
install_tools_archive(container, archive_path('ncurses', platform, musl=musl))
690692

691693
if libressl:
@@ -698,6 +700,7 @@ def build_cpython(client, image, platform, debug=False, optimized=False, musl=Fa
698700
install_tools_archive(container, archive_path('tcl', platform, musl=musl))
699701
install_tools_archive(container, archive_path('tk', platform, musl=musl))
700702
install_tools_archive(container, archive_path('uuid', platform, musl=musl))
703+
install_tools_archive(container, archive_path('xorgproto', platform, musl=musl))
701704
install_tools_archive(container, archive_path('xz', platform, musl=musl))
702705
install_tools_archive(container, archive_path('zlib', platform, musl=musl))
703706
#copy_rust(container)

cpython-linux/static-modules

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ _ssl _ssl.c -I/tools/deps/include -lssl -lcrypto
2828
_testbuffer _testbuffer.c
2929
_testimportmultiple _testimportmultiple.c
3030
_testmultiphase _testmultiphase.c
31-
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -I/tools/deps/include -I/usr/include/X11 -L/tools/deps/lib -ltcl8.6 -ltk8.6 -lX11
31+
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -I/tools/deps/include/X11 -L/tools/deps/lib -ltcl8.6 -ltk8.6 -lX11 -lxcb -lXau
3232
_uuid _uuidmodule.c -I/tools/deps/include/uuid -luuid
3333
_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
3434
ossaudiodev ossaudiodev.c

pythonbuild/downloads.py

+6
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,18 @@
330330
'size': 10000896,
331331
'sha256': 'ad0cd2de2c87b9ba8086b43957a0de3eb2eb565c7159d5f53ccbba3feb915f4e',
332332
'version': '8.6.9',
333+
'library_names': ['tcl8.6'],
334+
'licenses': ['TCL'],
335+
'license_file': 'LICENSE.tcl.txt',
333336
},
334337
'tk': {
335338
'url': 'https://prdownloads.sourceforge.net/tcl/tk8.6.9.1-src.tar.gz',
336339
'size': 4364603,
337340
'sha256': '8fcbcd958a8fd727e279f4cac00971eee2ce271dc741650b1fc33375fb74ebb4',
338341
'version': '8.6.9.1',
342+
'library_names': ['tk8.6'],
343+
'licenses': ['TCL'],
344+
'license_file': 'LICENSE.tcl.txt',
339345
},
340346
'tk-windows-bin': {
341347
'url': 'https://github.com/python/cpython-bin-deps/archive/86027ce3edda1284ae4bf6c2c580288366af4052.tar.gz',

0 commit comments

Comments
 (0)