class_docstr: Return extended build command class for recording commit
  
  The extended command tries to run git to find the current commit, getting
  the empty string if it fails.  It then writes the commit hash into a file
  in the `pkg_dir` path, named ``COMMIT_INFO.txt``.
  
  In due course this information can be used by the package after it is
  installed, to tell you what commit it was installed from if known.
  
  To make use of this system, you need a package with a COMMIT_INFO.txt file
  e.g. ``myproject/COMMIT_INFO.txt`` - that might well look like this::
  
      # This is an ini file that may contain information about the code state
      [commit hash]
      # The line below may contain a valid hash if it has been substituted
      # during 'git archive'
      archive_subst_hash=$Format:%h$
      # This line may be modified by the install process
      install_hash=
  
  The COMMIT_INFO file above is also designed to be used with git
  substitution - so you probably also want a ``.gitattributes`` file in the
  root directory of your working tree that contains something like this::
  
     myproject/COMMIT_INFO.txt export-subst
  
  That will cause the ``COMMIT_INFO.txt`` file to get filled in by ``git
  archive`` - useful in case someone makes such an archive - for example with
  via the github 'download source' button.
  
  Although all the above will work as is, you might consider having something
  like a ``get_info()`` function in your package to display the commit
  information at the terminal.  See the ``pkg_info.py`` module in the nipy
  package for an example.
code: def run(self):
      import subprocess
      import configparser
  
      build_py.run(self)
      proc = subprocess.Popen(
          "git rev-parse --short HEAD",
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          shell=True,
      )
      repo_commit = proc.communicate()[0].decode()
  
      # We write the installation commit even if it's empty
      cfg_parser = configparser.RawConfigParser()
      cfg_parser.read(pjoin("nipype", "COMMIT_INFO.txt"))
      cfg_parser.set("commit hash", "install_hash", repo_commit.strip())
      out_pth = pjoin(self.build_lib, "nipype", "COMMIT_INFO.txt")
      cfg_parser.write(open(out_pth, "w"))
  
imports: import os
  from os.path import join
  from setuptools.command.build_py import build_py
label_desc: Use image node_id 1 for calling the BuildWithCommitInfoCommand obj's underlying member method code with example usage: obj.run() without return types