def get_repo_revision(): path = os.path # shortcut gitdir = path.normpath(path.join(path.dirname(os.path.abspath(__file__)), '..', '..', '.git')) cwd = os.path.dirname(gitdir) if not path.exists(gitdir): try: from PyInstaller.utils._gitrevision import rev if not rev.startswith('$'): # the format specifier has been substituted return '+' + rev except ImportError: pass return '' try: # need to update index first to get reliable state exec_command_rc('git', 'update-index', '-q', '--refresh', cwd=cwd) recent = exec_command('git', 'describe', '--long', '--dirty', '--tag', cwd=cwd).strip() if recent.endswith('-dirty'): tag, changes, rev, dirty = recent.rsplit('-', 3) rev = rev + '.mod' else: tag, changes, rev = recent.rsplit('-', 2) if changes == '0': return '' # According to PEP440, local version identifier starts with '+'. return '+' + rev except (FileNotFoundError, WindowsError): # Be silent when git command is not found. pass return ''
def mac_strip_signature(libname, distname): """ On macOS, strip away the signature from the binary file. As we may not be collecting all components from a signed framework bundle, the collection may invalidate the existing signature on a collected shared library, which will prevent the latter from being loaded. """ from PyInstaller.compat import exec_command_rc # For now, limit this only to Python shared library. Other shared # library files from Python.framework bundle also seem to be signed, # but their signature is not invalidated by partial collection like # it is for Python library... if os.path.basename(libname) != 'Python': return if not mac_is_binary_signed(libname): return # Run codesign --remove-signature libname try: logger.debug("Removing signature from %s", libname) result = exec_command_rc('codesign', '--remove-signature', libname) except Exception as e: logger.warning( "Failed to run 'codesign' to remove signature from %s: %r", libname, e) return if result != 0: logger.warning( "'codesign --remove-signature %s' returned non-zero status %d", libname, result)
def get_repo_revision(): path = os.path # shortcut gitdir = path.normpath(path.join(path.dirname(__file__), '..','..', '.git')) if not path.exists(gitdir): return '' try: rev = compat.exec_command('git', 'rev-parse', '--short', 'HEAD').strip() if rev: # need to update index first to get reliable state compat.exec_command_rc('git', 'update-index', '-q', '--refresh') changed = compat.exec_command_rc('git', 'diff-index', '--quiet', 'HEAD') if changed: rev = rev + '-mod' return rev except: pass return ''
def get_repo_revision(): path = os.path # shortcut gitdir = path.normpath( path.join(path.dirname(__file__), '..', '..', '.git')) if not path.exists(gitdir): return '' try: rev = compat.exec_command('git', 'rev-parse', '--short', 'HEAD').strip() if rev: # need to update index first to get reliable state compat.exec_command_rc('git', 'update-index', '-q', '--refresh') changed = compat.exec_command_rc('git', 'diff-index', '--quiet', 'HEAD') if changed: rev = rev + '-mod' return rev except: pass return ''
def test_exe(test, testdir=None): _msg("EXECUTING TEST", testdir + '/' + test) # Run the test in a clean environment to make sure they're # really self-contained path = compat.getenv("PATH") compat.unsetenv("PATH") prog = find_exepath(test, 'dist') if prog is None: print "ERROR: no file generated by PyInstaller found!" compat.setenv("PATH", path) return 1 else: print "RUNNING:", prog tmp = compat.exec_command_rc(prog) compat.setenv("PATH", path) return tmp
def main(): for pkg in _PACKAGES: print('Installing module...', pkg) retcode = compat.exec_command_rc('pip', 'install', pkg) if retcode: print(' ', pkg, 'installation failed')