title: Extracting 7z Console SFX (.exe) files using Python without using a subprocess?
body: <p>I am using python 3.4</p>
  
  <p>I have a crawler that is extracting 7z Console SFX files and I wish to extract them programmatically.  </p>
  
  <p>Currently I have only been able to do so with a subprocess call:</p>
  
  <pre><code>import subprocess
  seven_zip = r"C:\Program Files\7-Zip\7z.exe"
  tempfile = r"temp.exe" # SFX Archive
  subprocess.call(seven_zip + ' x ' + tempfile + ' -aoa')
  </code></pre>
  
  <p>This is problematic because users of this script may not have 7zip installed, or may have it installed in a different directory.  Further, running a subprocess doesn't give me direct access to the extracted items like running a normal zFile extraction would.  I can workaround this by extracting to a temporary directory then parsing the files in said directory, but that is cumbersome.</p>
  
  <p>I am thinking there's got to be a way of extracting the 7z Console SFX files with Python (maybe something with <a href="https://github.com/fancycode/pylzma" rel="nofollow">pylzma</a>?), but I can't seem to find any questions on the subject here.</p>
  
  <p><strong>Update:</strong> I've still had limited success using py7zlib. Again I note that this is intended for extracting SFX (executable) archives, and not a .7z archive.  Perhaps there is an application for py7zlib for such files, but I'm unable to find any examples.</p>