Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at haskell-updates 119 lines 3.3 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 broken = pythonOlder "3.12"; # tommath.h: No such file or directory 90 # Based on first sentence from https://docs.python.org/3/library/tkinter.html 91 description = "Standard Python interface to the Tcl/Tk GUI toolkit"; 92 longDescription = '' 93 The tkinter package (Tk interface) is the standard Python interface to 94 the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix 95 platforms, including macOS, as well as on Windows systems. 96 97 Running python -m tkinter from the command line should open a window 98 demonstrating a simple Tk interface, letting you know that tkinter is 99 properly installed on your system, and also showing what version of 100 Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to 101 that version. 102 103 Tkinter supports a range of Tcl/Tk versions, built either with or without 104 thread support. The official Python binary release bundles Tcl/Tk 8.6 105 threaded. See the source code for the _tkinter module for more 106 information about supported versions. 107 108 Tkinter is not a thin wrapper, but adds a fair amount of its own logic to 109 make the experience more pythonic. This documentation will concentrate on 110 these additions and changes, and refer to the official Tcl/Tk 111 documentation for details that are unchanged. 112 ''; 113 homepage = "https://docs.python.org/3/library/tkinter.html"; 114 inherit (python.meta) 115 license 116 maintainers 117 ; 118 }; 119}