python313Packages.tkinter: fix nix-shell usage

$NIX_BUILD_TOP was used inconsistently and the name of the Python source directory was assumed to have a certain pattern. These changes make the build work better in a nix-shell.
This commit is contained in:
Elliot Cameron
2026-01-28 22:04:08 -05:00
parent d243c7dd6a
commit bc5d961527
@@ -20,12 +20,14 @@ buildPythonPackage {
src = python.src;
prePatch = ''
mkdir $NIX_BUILD_TOP/tkinter
python_src=$PWD
tkinter_src=$PWD/../tkinter
mkdir -p "$tkinter_src"
# copy the module bits and pieces from the python source
cp -v Modules/{_tkinter.c,tkinter.h} ../tkinter/
cp -rv Modules/clinic ../tkinter/
cp -rv Lib/tkinter ../tkinter/
cp -v Modules/{_tkinter.c,tkinter.h} "$tkinter_src"
cp -rv Modules/clinic "$tkinter_src"
cp -rv Lib/tkinter "$tkinter_src"
# install our custom pyproject.toml
cp ${
@@ -33,11 +35,11 @@ buildPythonPackage {
python_version = python.version;
python_internal_dir = "${python}/include/${python.libPrefix}/internal";
}
} $NIX_BUILD_TOP/tkinter/pyproject.toml
} "$tkinter_src"/pyproject.toml
''
+ lib.optionalString (pythonOlder "3.13") ''
substituteInPlace "$NIX_BUILD_TOP/tkinter/tkinter/tix.py" --replace-fail \
substituteInPlace "$tkinter_src/tkinter/tix.py" --replace-fail \
"os.environ.get('TIX_LIBRARY')" \
"os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
'';
@@ -46,7 +48,7 @@ buildPythonPackage {
patches = lib.optional (pythonOlder "3.12") ./fix-ttk-notebook-test.patch;
preConfigure = ''
pushd $NIX_BUILD_TOP/tkinter
cd "$tkinter_src"
'';
build-system = [ setuptools ];
@@ -72,7 +74,7 @@ buildPythonPackage {
nativeCheckInputs = lib.optional stdenv.hostPlatform.isLinux xvfb-run;
preCheck = ''
cd $NIX_BUILD_TOP/Python-*/Lib
cd "$python_src"/Lib
export HOME=$TMPDIR
'';