at master 3.2 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 replaceVars, 5 setuptools, 6 python, 7 pythonOlder, 8 tcl, 9 tclPackages, 10 tk, 11 tkinter, 12 xvfb-run, 13}: 14 15buildPythonPackage { 16 pname = "tkinter"; 17 version = python.version; 18 pyproject = true; 19 20 src = python.src; 21 22 prePatch = '' 23 mkdir $NIX_BUILD_TOP/tkinter 24 25 # copy the module bits and pieces from the python source 26 cp -v Modules/{_tkinter.c,tkinter.h} ../tkinter/ 27 cp -rv Modules/clinic ../tkinter/ 28 cp -rv Lib/tkinter ../tkinter/ 29 30 pushd $NIX_BUILD_TOP/tkinter 31 32 # install our custom pyproject.toml 33 cp ${ 34 replaceVars ./pyproject.toml { 35 python_version = python.version; 36 python_internal_dir = "${python}/include/${python.libPrefix}/internal"; 37 } 38 } ./pyproject.toml 39 40 '' 41 + lib.optionalString (pythonOlder "3.13") '' 42 substituteInPlace "tkinter/tix.py" --replace-fail \ 43 "os.environ.get('TIX_LIBRARY')" \ 44 "os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'" 45 ''; 46 47 build-system = [ setuptools ]; 48 49 buildInputs = [ 50 tcl 51 tk 52 ]; 53 54 env = { 55 TCLTK_LIBS = toString [ 56 "-L${lib.getLib tcl}/lib" 57 "-L${lib.getLib tk}/lib" 58 "-l${tcl.libPrefix}" 59 "-l${tk.libPrefix}" 60 ]; 61 TCLTK_CFLAGS = toString [ 62 "-I${lib.getDev tcl}/include" 63 "-I${lib.getDev tk}/include" 64 ]; 65 }; 66 67 doCheck = false; 68 69 nativeCheckInputs = [ xvfb-run ]; 70 71 preCheck = '' 72 cd $NIX_BUILD_TOP/Python-*/Lib 73 export HOME=$TMPDIR 74 ''; 75 76 checkPhase = '' 77 runHook preCheck 78 xvfb-run -w 10 -s "-screen 0 1920x1080x24" \ 79 python -m unittest test.test_tkinter 80 81 runHook postCheck 82 ''; 83 84 passthru.tests.unittests = tkinter.overridePythonAttrs { doCheck = true; }; 85 86 pythonImportsCheck = [ "tkinter" ]; 87 88 meta = { 89 # Based on first sentence from https://docs.python.org/3/library/tkinter.html 90 description = "Standard Python interface to the Tcl/Tk GUI toolkit"; 91 longDescription = '' 92 The tkinter package (Tk interface) is the standard Python interface to 93 the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix 94 platforms, including macOS, as well as on Windows systems. 95 96 Running python -m tkinter from the command line should open a window 97 demonstrating a simple Tk interface, letting you know that tkinter is 98 properly installed on your system, and also showing what version of 99 Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to 100 that version. 101 102 Tkinter supports a range of Tcl/Tk versions, built either with or without 103 thread support. The official Python binary release bundles Tcl/Tk 8.6 104 threaded. See the source code for the _tkinter module for more 105 information about supported versions. 106 107 Tkinter is not a thin wrapper, but adds a fair amount of its own logic to 108 make the experience more pythonic. This documentation will concentrate on 109 these additions and changes, and refer to the official Tcl/Tk 110 documentation for details that are unchanged. 111 ''; 112 homepage = "https://docs.python.org/3/library/tkinter.html"; 113 inherit (python.meta) 114 license 115 maintainers 116 ; 117 }; 118}