Skip to content

Commit ad4b7a4

Browse files
committed
shiboken2@5.15.5 attempt to move inline patches to ext files
Closes #347. Signed-off-by: Chris <chris.r.jones.1983@gmail.com>
1 parent 8944b8b commit ad4b7a4

File tree

1 file changed

+12
-98
lines changed

1 file changed

+12
-98
lines changed

Formula/shiboken2@5.15.5.rb

Lines changed: 12 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Shiboken2AT5155 < Formula
22
desc "GeneratorRunner plugin that outputs C++ code for CPython extensions"
33
homepage "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/README.shiboken2-generator.md?h=5.15.2"
44
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"]
5+
revision 1
56
head "https://github.com/qt/qt5.git", branch: "dev", shallow: false
67

78
stable do
@@ -20,7 +21,17 @@ class Shiboken2AT5155 < Formula
2021
uses_from_macos "libxml2"
2122
uses_from_macos "libxslt"
2223

23-
patch :p0, :DATA
24+
# fix for numpy v1.23 API
25+
patch :p0 do
26+
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/8944b8b362c7fd87c515efb07eb0fb022e946610/patches/libshiboken-numpy-1.23.compat.patch"
27+
sha256 "e5a503eb5beb0f3e438559920081c28a7f663d79a34a9efb0a1459fa1ffb6f6a"
28+
end
29+
30+
# fix for python v3.10
31+
patch :p0 do
32+
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/8944b8b362c7fd87c515efb07eb0fb022e946610/patches/libshiboken2-python10-compat.patch"
33+
sha256 "bb234f9a37fd9af1d20ca4a90829580be1c0df2cb55061e350619fd3fb0c1e36"
34+
end
2435

2536
def install
2637
ENV["LLVM_INSTALL_DIR"] = Formula["llvm"].opt_prefix
@@ -49,100 +60,3 @@ def caveats
4960
system "#{bin}/shiboken2", "--version"
5061
end
5162
end
52-
53-
__END__
54-
--- sources/shiboken2/libshiboken/pep384impl.cpp.orig 2022-07-17 22:14:14.000000000 +0300
55-
+++ sources/shiboken2/libshiboken/pep384impl.cpp 2022-07-17 22:20:39.000000000 +0300
56-
@@ -707,6 +707,76 @@
57-
*
58-
*/
59-
60-
+#if PY_VERSION_HEX >= 0x03000000
61-
+PyObject *
62-
+_Py_Mangle(PyObject *privateobj, PyObject *ident)
63-
+{
64-
+ /* Name mangling: __private becomes _classname__private.
65-
+ This is independent from how the name is used. */
66-
+ PyObject *result;
67-
+ size_t nlen, plen, ipriv;
68-
+ Py_UCS4 maxchar;
69-
+ if (privateobj == NULL || !PyUnicode_Check(privateobj) ||
70-
+ PyUnicode_READ_CHAR(ident, 0) != '_' ||
71-
+ PyUnicode_READ_CHAR(ident, 1) != '_') {
72-
+ Py_INCREF(ident);
73-
+ return ident;
74-
+ }
75-
+ nlen = PyUnicode_GET_LENGTH(ident);
76-
+ plen = PyUnicode_GET_LENGTH(privateobj);
77-
+ /* Don't mangle __id__ or names with dots.
78-
+
79-
+ The only time a name with a dot can occur is when
80-
+ we are compiling an import statement that has a
81-
+ package name.
82-
+
83-
+ TODO(jhylton): Decide whether we want to support
84-
+ mangling of the module name, e.g. __M.X.
85-
+ */
86-
+ if ((PyUnicode_READ_CHAR(ident, nlen-1) == '_' &&
87-
+ PyUnicode_READ_CHAR(ident, nlen-2) == '_') ||
88-
+ PyUnicode_FindChar(ident, '.', 0, nlen, 1) != -1) {
89-
+ Py_INCREF(ident);
90-
+ return ident; /* Don't mangle __whatever__ */
91-
+ }
92-
+ /* Strip leading underscores from class name */
93-
+ ipriv = 0;
94-
+ while (PyUnicode_READ_CHAR(privateobj, ipriv) == '_')
95-
+ ipriv++;
96-
+ if (ipriv == plen) {
97-
+ Py_INCREF(ident);
98-
+ return ident; /* Don't mangle if class is just underscores */
99-
+ }
100-
+ plen -= ipriv;
101-
+
102-
+ if (plen + nlen >= PY_SSIZE_T_MAX - 1) {
103-
+ PyErr_SetString(PyExc_OverflowError,
104-
+ "private identifier too large to be mangled");
105-
+ return NULL;
106-
+ }
107-
+
108-
+ maxchar = PyUnicode_MAX_CHAR_VALUE(ident);
109-
+ if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar)
110-
+ maxchar = PyUnicode_MAX_CHAR_VALUE(privateobj);
111-
+
112-
+ result = PyUnicode_New(1 + nlen + plen, maxchar);
113-
+ if (!result)
114-
+ return 0;
115-
+ /* ident = "_" + priv[ipriv:] + ident # i.e. 1+plen+nlen bytes */
116-
+ PyUnicode_WRITE(PyUnicode_KIND(result), PyUnicode_DATA(result), 0, '_');
117-
+ if (PyUnicode_CopyCharacters(result, 1, privateobj, ipriv, plen) < 0) {
118-
+ Py_DECREF(result);
119-
+ return NULL;
120-
+ }
121-
+ if (PyUnicode_CopyCharacters(result, plen+1, ident, 0, nlen) < 0) {
122-
+ Py_DECREF(result);
123-
+ return NULL;
124-
+ }
125-
+ assert(_PyUnicode_CheckConsistency(result, 1));
126-
+ return result;
127-
+}
128-
+#endif
129-
+
130-
#ifdef Py_LIMITED_API
131-
// We keep these definitions local, because they don't work in Python 2.
132-
# define PyUnicode_GET_LENGTH(op) PyUnicode_GetLength((PyObject *)(op))
133-
--- sources/shiboken2/libshiboken/sbknumpyarrayconverter.cpp 2022-07-17 21:07:58.000000000 +0300
134-
+++ sources/shiboken2/libshiboken/sbknumpyarrayconverter.cpp 2022-07-17 21:08:50.000000000 +0300
135-
@@ -116,8 +116,13 @@
136-
str << " NPY_ARRAY_NOTSWAPPED";
137-
if ((flags & NPY_ARRAY_WRITEABLE) != 0)
138-
str << " NPY_ARRAY_WRITEABLE";
139-
+#if NPY_VERSION >= 0x00000010 // NPY_1_23_API_VERSION
140-
+ if ((flags & NPY_ARRAY_WRITEBACKIFCOPY) != 0)
141-
+ str << " NPY_ARRAY_WRITEBACKIFCOPY";
142-
+#else
143-
if ((flags & NPY_ARRAY_UPDATEIFCOPY) != 0)
144-
str << " NPY_ARRAY_UPDATEIFCOPY";
145-
+#endif
146-
} else {
147-
str << '0';
148-
}

0 commit comments

Comments
 (0)