python@3.9: move tkinter into separate formula

master
Bo Anderson 2021-03-22 17:33:59 +00:00
parent 0a0b8fedc3
commit 80412c2807
1 changed files with 13 additions and 9 deletions

View File

@ -1,10 +1,11 @@
class PythonAT39 < Formula
desc "Interpreted, interactive, object-oriented programming language"
homepage "https://www.python.org/"
# Keep in sync with python-tk@3.9.
url "https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tar.xz"
sha256 "3c2034c54f811448f516668dce09d24008a0716c3a794dd8639b5388cbde247d"
license "Python-2.0"
revision 2
revision 3
livecheck do
url "https://www.python.org/ftp/python/"
@ -37,7 +38,6 @@ class PythonAT39 < Formula
depends_on "openssl@1.1"
depends_on "readline"
depends_on "sqlite"
depends_on "tcl-tk"
depends_on "xz"
uses_from_macos "bzip2"
@ -168,8 +168,8 @@ class PythonAT39 < Formula
# Avoid linking to libgcc https://mail.python.org/pipermail/python-dev/2012-February/116205.html
args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
args << "--with-tcltk-includes=-I#{Formula["tcl-tk"].opt_include}"
args << "--with-tcltk-libs=-L#{Formula["tcl-tk"].opt_lib} -ltcl8.6 -ltk8.6"
# Disable _tkinter - this is built in a separate formula python-tk
inreplace "setup.py", "DISABLED_MODULE_LIST = []", "DISABLED_MODULE_LIST = ['_tkinter']"
# We want our readline! This is just to outsmart the detection code,
# superenv makes cc always find includes/libs!
@ -380,9 +380,9 @@ class PythonAT39 < Formula
# Help distutils find brewed stuff when building extensions
include_dirs = [HOMEBREW_PREFIX/"include", Formula["openssl@1.1"].opt_include,
Formula["sqlite"].opt_include, Formula["tcl-tk"].opt_include]
Formula["sqlite"].opt_include]
library_dirs = [HOMEBREW_PREFIX/"lib", Formula["openssl@1.1"].opt_lib,
Formula["sqlite"].opt_lib, Formula["tcl-tk"].opt_lib]
Formula["sqlite"].opt_lib]
cfg = lib_cellar/"distutils/distutils.cfg"
@ -457,6 +457,9 @@ class PythonAT39 < Formula
They will install into the site-package directory
#{HOMEBREW_PREFIX/"lib/python#{version.major_minor}/site-packages"}
tkinter is no longer included with this formula, but it is available separately:
brew install python-tk@#{version.major_minor}
See: https://docs.brew.sh/Homebrew-and-Python
EOS
end
@ -475,9 +478,10 @@ class PythonAT39 < Formula
system "#{bin}/python#{version.major_minor}", "-c", "import _gdbm"
system "#{bin}/python#{version.major_minor}", "-c", "import pyexpat"
system "#{bin}/python#{version.major_minor}", "-c", "import zlib"
on_macos do
system "#{bin}/python#{version.major_minor}", "-c", "import tkinter; root = tkinter.Tk()"
end
# tkinter is provided in a separate formula
assert_match "ModuleNotFoundError: No module named '_tkinter'",
shell_output("#{bin}/python#{version.major_minor} -c 'import tkinter' 2>&1", 1)
# Verify that the selected DBM interface works
(testpath/"dbm_test.py").write <<~EOS