7 examples of 'compile python to exe' in Python

Every line of 'compile python to exe' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
22def compile(source_path, compiler_id, exec_path): #print("[log] compile:")
23 #print(COMPILER_LIST[compiler_id])
24 #print(source_path)
25 #print(COMPILER_OPTION_LIST[compiler_id])
26 proc = subprocess.Popen([COMPILER_LIST[compiler_id],
27 source_path,
28 *COMPILER_OPTION_LIST[compiler_id]],
29 cwd = exec_path,
30 stdout = subprocess.PIPE,
31 stderr = subprocess.PIPE)
32 try:
33 outs, err = proc.communicate(timeout = COMPILE_TIME_LIMIT)
34 returncode = proc.returncode
35 except:
36 proc.kill()
37 out, err = proc.communicate()
38 returncode = proc.returncode
39 return (returncode, exec_path + "/a.out", err.decode('utf-8'))
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

51def _exec_code(self, code):
52 if code:
53 code = compile(code, str(self.filename), 'exec', dont_inherit=True)
54 exec(code, vars(self.namespace))
89def exec_script(script_filename, env={}, *args):
90 """
91 Executes a Python script in an externally spawned interpreter, and
92 returns anything that was emitted in the standard output as a
93 single string.
94
95 To prevent missuse, the script passed to hookutils.exec_script
96 must be located in the `PyInstaller/utils/hooks/subproc` directory.
97 """
98 script_filename = os.path.basename(script_filename)
99 script_filename = os.path.join(os.path.dirname(__file__), 'subproc', script_filename)
100 if not os.path.exists(script_filename):
101 raise SystemError("To prevent missuse, the script passed to "
102 "hookutils.exec-script must be located in "
103 "the `PyInstaller/utils/hooks/subproc` directory.")
104
105 cmd = [script_filename]
106 cmd.extend(args)
107 return __exec_python_cmd(cmd, env=env)
30def execfile(filename, globals, locals):
31 """Python 3 replacement for ``execfile``."""
32 # Credit: 2to3 and this StackOverflow answer
33 # (http://stackoverflow.com/a/437857/841994) take similar
34 # approaches.
35 with open(filename) as f:
36 code = compile(f.read(), filename, 'exec')
37 exec(code, globals, locals)
76def eval_script(scriptfilename, *args):
77 txt = exec_script(scriptfilename, *args).strip()
78 if not txt:
79 # return an empty string which is "not true" but iterable
80 return ''
81 return eval(txt)
52def get_run_cmd(self, source_path):
53 return self.exec_string
64def BoostRunPythonScript(env, script):
65 return env.BoostRun(env.File(script), script.replace('.py', '.result'), '"${PYTHON}" $SOURCE')

Related snippets