From e21b2c93b2359cd6fc2b0fca6ee785c5b5147216 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph.weston08@gmail.com>
Date: Wed, 14 Jun 2017 18:57:03 +0200
Subject: [PATCH] make setup.py stop with an error if config file cannot be
 found

This is the only sane behaviour, otherwise we don't know if our
build is misconfigured because 'build.conf' was silently used instead.

Fixes #133.
---
 setup.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/setup.py b/setup.py
index 5888879b..48e7289c 100755
--- a/setup.py
+++ b/setup.py
@@ -45,10 +45,12 @@ def configure_extensions(exts, aliases=(), build_summary=None):
 
     #### Determine the name of the configuration file.
     config_file_option = '--configfile'
+    config_file_option_present = False
     # Handle command line option
     for i, opt in enumerate(sys.argv):
         if not opt.startswith(config_file_option):
             continue
+        config_file_option_present = True
         l, _, config_file = opt.partition('=')
         if l != config_file_option or not config_file:
             print('Error: Expecting {}=PATH'.format(config_file_option),
@@ -66,6 +68,10 @@ def configure_extensions(exts, aliases=(), build_summary=None):
             configs.read_file(f)
     except IOError:
         config_file_present = False
+        if config_file_option_present:
+            print("Error: '{}' option was provided, but '{}' does not exist"
+                  .format(config_file_option, config_file))
+            sys.exit(1)
     else:
         config_file_present = True
 
-- 
GitLab