From 3760d31545ed9c6004cc7c6036fcffca3ebcb9a4 2011-10-24 20:45:10
From: MinRK <benjaminrk@gmail.com>
Date: 2011-10-24 20:45:10
Subject: [PATCH] protect record_commit_info from configparser error

---

diff --git a/setupbase.py b/setupbase.py
index ffa26f7..0113f6d 100644
--- a/setupbase.py
+++ b/setupbase.py
@@ -370,6 +370,10 @@ def record_commit_info(pkg_dir, build_cmd=build_py):
             # We write the installation commit even if it's empty
             cfg_parser = ConfigParser()
             cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini'))
+            if not cfg_parser.has_section('commit hash'):
+                # just in case the ini file is empty or doesn't exist, somehow
+                # we don't want the next line to raise
+                cfg_parser.add_section('commit hash')
             cfg_parser.set('commit hash', 'install_hash', repo_commit.decode('ascii'))
             out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini')
             out_file = open(out_pth, 'wt')