4 examples of 'compile python' in Python

Every line of 'compile python' 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
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'))
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))
113def compile(self, display=0):
114 tree = self._get_tree()
115 gen = ModuleCodeGenerator(tree)
116 if display:
117 import pprint
118 print(pprint.pprint(tree))
119 self.code = gen.getCode()
56def get_code(module):
57 """
58 Compile and return a Module's code object.
59 """
60 fp = open(module.path, 'rb')
61 try:
62 return compile(fp.read(), str(module.name), 'exec')
63 finally:
64 fp.close()

Related snippets