From 764665fb080e5aec235a64029246cb58becf5591 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Sat, 7 May 2022 12:44:31 -0400
Subject: [PATCH 1/1] FIX: skip version update on `build_ext` if .py does not
 exist

Upstream versioneer commit 280fb6ce89af73ac6ced3c66354a16506a57fc6c
ported to cvxopt's bundled copy. See also:

  https://github.com/python-versioneer/python-versioneer/issues/296
---
 versioneer.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/versioneer.py b/versioneer.py
index 414cb9d..47bdd40 100644
--- a/versioneer.py
+++ b/versioneer.py
@@ -1847,6 +1847,11 @@ def get_cmdclass(cmdclass=None):
             # it with an updated value
             target_versionfile = os.path.join(self.build_lib,
                                               cfg.versionfile_build)
+            if not os.path.exists(target_versionfile):
+                print(f"Warning: {target_versionfile} does not exist, skipping "
+                      "version update. This can happen if you are running build_ext "
+                      "without first running build_py.")
+                return
             print("UPDATING %s" % target_versionfile)
             write_to_version_file(target_versionfile, versions)
     cmds["build_ext"] = cmd_build_ext
-- 
2.35.1

