Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python@3.12 python-gdbm@3.12 python-tk@3.12 3.12.0 #149142

Merged
merged 7 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Formula/p/python-gdbm@3.12.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class PythonGdbmAT312 < Formula
desc "Python interface to gdbm"
homepage "https://www.python.org/"
url "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz"
sha256 "51412956d24a1ef7c97f1cb5f70e185c13e3de1f50d131c0aac6338080687afb"
license "Python-2.0"

livecheck do
formula "python@3.12"
end

depends_on "gdbm"
depends_on "python@3.12"

resource "setuptools" do
url "https://files.pythonhosted.org/packages/ef/cc/93f7213b2ab5ed383f98ce8020e632ef256b406b8569606c3f160ed8e1c9/setuptools-68.2.2.tar.gz"
sha256 "4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"
end

def python3
"python3.12"
end

def install
ENV.append_path "PYTHONPATH", buildpath/Language::Python.site_packages(python3)
resource("setuptools").stage do
system python3, "-m", "pip", "install", *std_pip_args(prefix: buildpath), "."
end

cd "Modules" do
(Pathname.pwd/"setup.py").write <<~EOS
from setuptools import setup, Extension

setup(name="gdbm",
description="#{desc}",
version="#{version}",
ext_modules = [
Extension("_gdbm", ["_gdbmmodule.c"],
include_dirs=["#{Formula["gdbm"].opt_include}"],
libraries=["gdbm"],
library_dirs=["#{Formula["gdbm"].opt_lib}"])
]
)
EOS
system python3, *Language::Python.setup_install_args(libexec, python3),
"--install-lib=#{libexec}"
rm_r libexec.glob("*.egg-info")
end
end

test do
testdb = testpath/"test.db"
system python3, "-c", <<~EOS
import dbm.gnu

with dbm.gnu.open("#{testdb}", "n") as db:
db["testkey"] = "testvalue"

with dbm.gnu.open("#{testdb}", "r") as db:
assert db["testkey"] == b"testvalue"
EOS
end
end
67 changes: 67 additions & 0 deletions Formula/p/python-tk@3.12.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
class PythonTkAT312 < Formula
desc "Python interface to Tcl/Tk"
homepage "https://www.python.org/"
url "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz"
sha256 "51412956d24a1ef7c97f1cb5f70e185c13e3de1f50d131c0aac6338080687afb"
license "Python-2.0"

livecheck do
formula "python@3.12"
end

depends_on "python@3.12"
depends_on "tcl-tk"

resource "setuptools" do
url "https://files.pythonhosted.org/packages/ef/cc/93f7213b2ab5ed383f98ce8020e632ef256b406b8569606c3f160ed8e1c9/setuptools-68.2.2.tar.gz"
sha256 "4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"
end

def python3
"python3.12"
end

def install
ENV.append_path "PYTHONPATH", buildpath/Language::Python.site_packages(python3)
resource("setuptools").stage do
system python3, "-m", "pip", "install", *std_pip_args(prefix: buildpath), "."
end

xy = Language::Python.major_minor_version python3
python_include = if OS.mac?
Formula["python@#{xy}"].opt_frameworks/"Python.framework/Versions/#{xy}/include/python#{xy}"
else
Formula["python@#{xy}"].opt_include/"python#{xy}"
end

cd "Modules" do
tcltk_version = Formula["tcl-tk"].any_installed_version.major_minor
(Pathname.pwd/"setup.py").write <<~EOS
from setuptools import setup, Extension

setup(name="tkinter",
description="#{desc}",
version="#{version}",
ext_modules = [
Extension("_tkinter", ["_tkinter.c", "tkappinit.c"],
define_macros=[("WITH_APPINIT", 1)],
include_dirs=["#{python_include}/internal", "#{Formula["tcl-tk"].opt_include/"tcl-tk"}"],
libraries=["tcl#{tcltk_version}", "tk#{tcltk_version}"],
library_dirs=["#{Formula["tcl-tk"].opt_lib}"])
]
)
EOS
system python3, *Language::Python.setup_install_args(libexec, python3),
"--install-lib=#{libexec}"
rm_r libexec.glob("*.egg-info")
end
end

test do
system python3, "-c", "import tkinter"

return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]

system python3, "-c", "import tkinter; root = tkinter.Tk()"
end
end
Loading