From 2f565c7544c71c4ee73d8d24167f546ca9aac363 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Fri, 15 Mar 2024 05:28:58 -0300 Subject: [PATCH] Handle module __builtins__ both as dict or module (#1107) --- setup.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3672550e1..a38ed32ca 100644 --- a/setup.py +++ b/setup.py @@ -51,12 +51,21 @@ sys.exit(1) +def set_builtin(name, value): + if isinstance(__builtins__, dict): + __builtins__[name] = value + else: + # to support https://github.com/pypa/build + # see https://github.com/jopohl/urh/issues/1106 + setattr(__builtins__, name, value) + + class build_ext(_build_ext): def finalize_options(self): print("Finalizing options") _build_ext.finalize_options(self) # Prevent numpy from thinking it is still in its setup process: - __builtins__.__NUMPY_SETUP__ = False + set_builtin("__NUMPY_SETUP__", False) import numpy self.include_dirs.append(numpy.get_include())