/python-parse-shebang

Parse shebangs so script-like files can be executed directly on Windows

Primary LanguagePythonMIT LicenseMIT

Parse Shebang

Parse shebangs so script-like files can be executed directly on Windows

On Windows, scripts are supposed to be registered with with their interpreters and placed into PATHEXT, but that information might not be available and the script still needs to be run. In that case, this module is useful, because it looks up the required information to run the script as best as possible.

Status

Travis CI (Ubuntu) AppVeyor (Windows) Coverage PyPI Licence
Travis AppVeyor Coveralls PyPIVersionPyPIPythons License

API Usage

shebang = parseshebang.parse(file_to_parse)
subprocess.check_call(shebang + ["/my_script.py"])

file_to_parse may be either an open file object, which supports seeking, or a file name. A list containing the shebang components is returned.