From af0f9fa26b02fd8c5808d89a3781d3777f8c0d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Kemetm=C3=BCller?= Date: Thu, 15 Mar 2018 19:49:09 +0100 Subject: [PATCH] pythonPackages.tkinter: fix darwin build --- .../python/cpython/2.7/default.nix | 2 + .../2.7/use-correct-tcl-tk-on-darwin.patch | 48 +++++++++++++++++++ .../python/cpython/3.4/default.nix | 2 + .../3.4/use-correct-tcl-tk-on-darwin.patch | 48 +++++++++++++++++++ .../python/cpython/3.5/default.nix | 2 + .../3.5/use-correct-tcl-tk-on-darwin.patch | 48 +++++++++++++++++++ .../python/cpython/3.6/default.nix | 2 + .../3.6/use-correct-tcl-tk-on-darwin.patch | 48 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 5 +- 9 files changed, 202 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/interpreters/python/cpython/2.7/use-correct-tcl-tk-on-darwin.patch create mode 100644 pkgs/development/interpreters/python/cpython/3.4/use-correct-tcl-tk-on-darwin.patch create mode 100644 pkgs/development/interpreters/python/cpython/3.5/use-correct-tcl-tk-on-darwin.patch create mode 100644 pkgs/development/interpreters/python/cpython/3.6/use-correct-tcl-tk-on-darwin.patch diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index 61f17a959bd9..a934d6c3bcf2 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -60,6 +60,8 @@ let ./properly-detect-curses.patch + ] ++ optionals (x11Support && stdenv.isDarwin) [ + ./use-correct-tcl-tk-on-darwin.patch ] ++ optionals stdenv.isLinux [ # Disable the use of ldconfig in ctypes.util.find_library (since diff --git a/pkgs/development/interpreters/python/cpython/2.7/use-correct-tcl-tk-on-darwin.patch b/pkgs/development/interpreters/python/cpython/2.7/use-correct-tcl-tk-on-darwin.patch new file mode 100644 index 000000000000..b73f62b97ec5 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/2.7/use-correct-tcl-tk-on-darwin.patch @@ -0,0 +1,48 @@ +diff --git a/setup.py b/setup.py +index 2779658..902d0eb 100644 +--- a/setup.py ++++ b/setup.py +@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without +@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): + if dir not in include_dirs: + include_dirs.append(dir) + +- # Check for various platform-specific directories +- if host_platform == 'sunos5': +- include_dirs.append('/usr/openwin/include') +- added_lib_dirs.append('/usr/openwin/lib') +- elif os.path.exists('/usr/X11R6/include'): +- include_dirs.append('/usr/X11R6/include') +- added_lib_dirs.append('/usr/X11R6/lib64') +- added_lib_dirs.append('/usr/X11R6/lib') +- elif os.path.exists('/usr/X11R5/include'): +- include_dirs.append('/usr/X11R5/include') +- added_lib_dirs.append('/usr/X11R5/lib') +- else: +- # Assume default location for X11 +- include_dirs.append('/usr/X11/include') +- added_lib_dirs.append('/usr/X11/lib') +- + # If Cygwin, then verify that X is installed before proceeding + if host_platform == 'cygwin': + x11_inc = find_file('X11/Xlib.h', [], include_dirs) +@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): + if host_platform in ['aix3', 'aix4']: + libs.append('ld') + +- # Finally, link with the X11 libraries (not appropriate on cygwin) +- if host_platform != "cygwin": +- libs.append('X11') +- + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)] + defs, + include_dirs = include_dirs, diff --git a/pkgs/development/interpreters/python/cpython/3.4/default.nix b/pkgs/development/interpreters/python/cpython/3.4/default.nix index 4c0979ca0e3c..d4391d873af7 100644 --- a/pkgs/development/interpreters/python/cpython/3.4/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.4/default.nix @@ -67,6 +67,8 @@ in stdenv.mkDerivation { patches = [ ./no-ldconfig.patch ./ld_library_path.patch + ] ++ optionals (x11Support && stdenv.isDarwin) [ + ./use-correct-tcl-tk-on-darwin.patch ]; postPatch = '' diff --git a/pkgs/development/interpreters/python/cpython/3.4/use-correct-tcl-tk-on-darwin.patch b/pkgs/development/interpreters/python/cpython/3.4/use-correct-tcl-tk-on-darwin.patch new file mode 100644 index 000000000000..b73f62b97ec5 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.4/use-correct-tcl-tk-on-darwin.patch @@ -0,0 +1,48 @@ +diff --git a/setup.py b/setup.py +index 2779658..902d0eb 100644 +--- a/setup.py ++++ b/setup.py +@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without +@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): + if dir not in include_dirs: + include_dirs.append(dir) + +- # Check for various platform-specific directories +- if host_platform == 'sunos5': +- include_dirs.append('/usr/openwin/include') +- added_lib_dirs.append('/usr/openwin/lib') +- elif os.path.exists('/usr/X11R6/include'): +- include_dirs.append('/usr/X11R6/include') +- added_lib_dirs.append('/usr/X11R6/lib64') +- added_lib_dirs.append('/usr/X11R6/lib') +- elif os.path.exists('/usr/X11R5/include'): +- include_dirs.append('/usr/X11R5/include') +- added_lib_dirs.append('/usr/X11R5/lib') +- else: +- # Assume default location for X11 +- include_dirs.append('/usr/X11/include') +- added_lib_dirs.append('/usr/X11/lib') +- + # If Cygwin, then verify that X is installed before proceeding + if host_platform == 'cygwin': + x11_inc = find_file('X11/Xlib.h', [], include_dirs) +@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): + if host_platform in ['aix3', 'aix4']: + libs.append('ld') + +- # Finally, link with the X11 libraries (not appropriate on cygwin) +- if host_platform != "cygwin": +- libs.append('X11') +- + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)] + defs, + include_dirs = include_dirs, diff --git a/pkgs/development/interpreters/python/cpython/3.5/default.nix b/pkgs/development/interpreters/python/cpython/3.5/default.nix index a8519a76a232..4f9e79c1d5f0 100644 --- a/pkgs/development/interpreters/python/cpython/3.5/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.5/default.nix @@ -67,6 +67,8 @@ in stdenv.mkDerivation { patches = [ ./no-ldconfig.patch ./ld_library_path.patch + ] ++ optionals (x11Support && stdenv.isDarwin) [ + ./use-correct-tcl-tk-on-darwin.patch ]; postPatch = '' diff --git a/pkgs/development/interpreters/python/cpython/3.5/use-correct-tcl-tk-on-darwin.patch b/pkgs/development/interpreters/python/cpython/3.5/use-correct-tcl-tk-on-darwin.patch new file mode 100644 index 000000000000..b73f62b97ec5 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.5/use-correct-tcl-tk-on-darwin.patch @@ -0,0 +1,48 @@ +diff --git a/setup.py b/setup.py +index 2779658..902d0eb 100644 +--- a/setup.py ++++ b/setup.py +@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without +@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): + if dir not in include_dirs: + include_dirs.append(dir) + +- # Check for various platform-specific directories +- if host_platform == 'sunos5': +- include_dirs.append('/usr/openwin/include') +- added_lib_dirs.append('/usr/openwin/lib') +- elif os.path.exists('/usr/X11R6/include'): +- include_dirs.append('/usr/X11R6/include') +- added_lib_dirs.append('/usr/X11R6/lib64') +- added_lib_dirs.append('/usr/X11R6/lib') +- elif os.path.exists('/usr/X11R5/include'): +- include_dirs.append('/usr/X11R5/include') +- added_lib_dirs.append('/usr/X11R5/lib') +- else: +- # Assume default location for X11 +- include_dirs.append('/usr/X11/include') +- added_lib_dirs.append('/usr/X11/lib') +- + # If Cygwin, then verify that X is installed before proceeding + if host_platform == 'cygwin': + x11_inc = find_file('X11/Xlib.h', [], include_dirs) +@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): + if host_platform in ['aix3', 'aix4']: + libs.append('ld') + +- # Finally, link with the X11 libraries (not appropriate on cygwin) +- if host_platform != "cygwin": +- libs.append('X11') +- + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)] + defs, + include_dirs = include_dirs, diff --git a/pkgs/development/interpreters/python/cpython/3.6/default.nix b/pkgs/development/interpreters/python/cpython/3.6/default.nix index fb58d0871ecb..317a335b3448 100644 --- a/pkgs/development/interpreters/python/cpython/3.6/default.nix +++ b/pkgs/development/interpreters/python/cpython/3.6/default.nix @@ -69,6 +69,8 @@ in stdenv.mkDerivation { patches = [ ./no-ldconfig.patch + ] ++ optionals (x11Support && stdenv.isDarwin) [ + ./use-correct-tcl-tk-on-darwin.patch ]; postPatch = '' diff --git a/pkgs/development/interpreters/python/cpython/3.6/use-correct-tcl-tk-on-darwin.patch b/pkgs/development/interpreters/python/cpython/3.6/use-correct-tcl-tk-on-darwin.patch new file mode 100644 index 000000000000..b73f62b97ec5 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.6/use-correct-tcl-tk-on-darwin.patch @@ -0,0 +1,48 @@ +diff --git a/setup.py b/setup.py +index 2779658..902d0eb 100644 +--- a/setup.py ++++ b/setup.py +@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext): + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. +- if (host_platform == 'darwin' and +- self.detect_tkinter_darwin(inc_dirs, lib_dirs)): +- return + + # Assume we haven't found any of the libraries or include files + # The versions with dots are used on Unix, and the versions without +@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext): + if dir not in include_dirs: + include_dirs.append(dir) + +- # Check for various platform-specific directories +- if host_platform == 'sunos5': +- include_dirs.append('/usr/openwin/include') +- added_lib_dirs.append('/usr/openwin/lib') +- elif os.path.exists('/usr/X11R6/include'): +- include_dirs.append('/usr/X11R6/include') +- added_lib_dirs.append('/usr/X11R6/lib64') +- added_lib_dirs.append('/usr/X11R6/lib') +- elif os.path.exists('/usr/X11R5/include'): +- include_dirs.append('/usr/X11R5/include') +- added_lib_dirs.append('/usr/X11R5/lib') +- else: +- # Assume default location for X11 +- include_dirs.append('/usr/X11/include') +- added_lib_dirs.append('/usr/X11/lib') +- + # If Cygwin, then verify that X is installed before proceeding + if host_platform == 'cygwin': + x11_inc = find_file('X11/Xlib.h', [], include_dirs) +@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext): + if host_platform in ['aix3', 'aix4']: + libs.append('ld') + +- # Finally, link with the X11 libraries (not appropriate on cygwin) +- if host_platform != "cygwin": +- libs.append('X11') +- + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)] + defs, + include_dirs = include_dirs, diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8acec15fd71e..8e4da97d3d43 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -16394,15 +16394,14 @@ in { # Move the tkinter module mkdir -p $out/${py.sitePackages} mv lib/${py.libPrefix}/lib-dynload/_tkinter* $out/${py.sitePackages}/ + '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' # Update the rpath to point to python without x11Support old_rpath=$(patchelf --print-rpath $out/${py.sitePackages}/_tkinter*) new_rpath=$(sed "s#${py}#${python}#g" <<< "$old_rpath" ) patchelf --set-rpath $new_rpath $out/${py.sitePackages}/_tkinter* ''; - meta = py.meta // { - platforms = platforms.linux; - }; + meta = py.meta; }; tlslite = buildPythonPackage rec {