@@ -4,6 +4,7 @@ class PythonGdbmAT314 < Formula
44 url "https://www.python.org/ftp/python/3.14.4/Python-3.14.4.tgz"
55 sha256 "b4c059d5895f030e7df9663894ce3732bfa1b32cd3ab2883980266a45ce3cb3b"
66 license "Python-2.0"
7+ revision 1
78
89 livecheck do
910 formula "python@3.14"
@@ -51,6 +52,16 @@ def install
5152 library-dirs = ["#{ Formula [ "gdbm" ] . opt_lib } "]
5253 TOML
5354
55+ ( buildpath /"Modules/pyproject.toml" ) . append_lines <<~TOML if OS . linux?
56+ [[tool.setuptools.ext-modules]]
57+ name = "_dbm"
58+ sources = ["_dbmmodule.c"]
59+ include-dirs = ["#{ Formula [ "gdbm" ] . opt_include } ", "#{ python_include } /internal"]
60+ libraries = ["gdbm_compat"]
61+ library-dirs = ["#{ Formula [ "gdbm" ] . opt_lib } "]
62+ extra-compile-args = ["-DUSE_GDBM_COMPAT", "-DHAVE_GDBM_DASH_NDBM_H"]
63+ TOML
64+
5465 system python3 , "-m" , "pip" , "install" , *std_pip_args ( prefix : false , build_isolation : true ) ,
5566 "--target=#{ libexec } " , "./Modules"
5667 rm_r libexec . glob ( "*.dist-info" )
@@ -67,5 +78,19 @@ def install
6778 with dbm.gnu.open("#{ testdb } ", "r") as db:
6879 assert db["testkey"] == b"testvalue"
6980 PYTHON
81+
82+ return unless OS . linux?
83+
84+ ( testpath /"dbm_test.py" ) . write <<~PYTHON
85+ import dbm
86+
87+ with dbm.ndbm.open("test", "c") as db:
88+ db[b"foo \\ xbd"] = b"bar \\ xbd"
89+ with dbm.ndbm.open("test", "r") as db:
90+ assert list(db.keys()) == [b"foo \\ xbd"]
91+ assert b"foo \\ xbd" in db
92+ assert db[b"foo \\ xbd"] == b"bar \\ xbd"
93+ PYTHON
94+ system python3 , "dbm_test.py"
7095 end
7196end
0 commit comments