From 24d65e10bee5b68751dc36e2ee7e6d6ed35751e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 27 May 2023 07:11:24 +0200
Subject: [PATCH] =?UTF-8?q?Call=20distutils'=20finalize=5Foptions()=20earl?=
 =?UTF-8?q?y=20to=20fix=20build=5Fext=20-j=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Call the `finalize_options()` method of overridden distutils commands
before running the `configure` command, in order to fix errors due
to unconfigured `--jobs` option.  This can be reproduced by running:

    $ python setup.py build_ext -j12
    […]
    error: '<' not supported between instances of 'str' and 'int'

    Fatal: Falling back on bundled libzmq, but config has explicitly prohibited building the libzmq extension.
---
 setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index c52723d1..a4f8b4e3 100755
--- a/setup.py
+++ b/setup.py
@@ -1107,9 +1107,9 @@ class CheckingBuildExt(build_ext):
         patch_lib_paths(ext_path, self.compiler.library_dirs)
 
     def finalize_options(self):
+        super().finalize_options()
         # check version, to prevent confusing undefined constant errors
         self.distribution.run_command("configure")
-        return super().finalize_options()
 
 
 class ConstantsCommand(Command):
@@ -1258,8 +1258,8 @@ else:
             patch_lib_paths(ext_path, self.compiler.library_dirs)
 
         def finalize_options(self):
+            super().finalize_options()
             self.distribution.run_command("configure")
-            return super().finalize_options()
 
     cmdclass["cython"] = CythonCommand
     cmdclass["build_ext"] = zbuild_ext
-- 
2.40.1

