3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 00:55:31 +00:00

First steps to a sane python build

This commit is contained in:
Andrew Dutcher 2016-08-25 19:25:12 -05:00
parent fa6cc19184
commit 0bbd172af3
9 changed files with 110 additions and 23 deletions

View file

@ -98,7 +98,7 @@ def mk_z3consts_py_internal(api_files, output_dir):
openbrace_pat = re.compile("{ *")
closebrace_pat = re.compile("}.*;")
z3consts = open(os.path.join(output_dir, 'z3consts.py'), 'w')
z3consts = open(os.path.join(output_dir, 'z3/z3consts.py'), 'w')
z3consts_output_path = z3consts.name
z3consts.write('# Automatically generated file\n\n')
for api_file in api_files:

View file

@ -2737,6 +2737,8 @@ def mk_def_files():
def cp_z3py_to_build():
mk_dir(BUILD_DIR)
z3py_dest = os.path.join(BUILD_DIR, 'z3.py')
z3py_src = os.path.join(Z3PY_SRC_DIR, 'z3')
# Erase existing .pyc files
for root, dirs, files in os.walk(Z3PY_SRC_DIR):
for f in files:
@ -2746,20 +2748,19 @@ def cp_z3py_to_build():
if compileall.compile_dir(Z3PY_SRC_DIR, force=1) != 1:
raise MKException("failed to compile Z3Py sources")
# Copy sources to build
for py in filter(lambda f: f.endswith('.py'), os.listdir(Z3PY_SRC_DIR)):
shutil.copyfile(os.path.join(Z3PY_SRC_DIR, py), os.path.join(BUILD_DIR, py))
if is_verbose():
print("Copied '%s'" % py)
shutil.copytree(z3py_src, z3py_dest)
if is_verbose():
print("Copied python bindings")
# Python 2.x support
for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(Z3PY_SRC_DIR)):
shutil.copyfile(os.path.join(Z3PY_SRC_DIR, pyc), os.path.join(BUILD_DIR, pyc))
for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(z3py_src)):
shutil.copyfile(os.path.join(z3py_src, pyc), os.path.join(z3py_dest, pyc))
if is_verbose():
print("Generated '%s'" % pyc)
# Python 3.x support
src_pycache = os.path.join(Z3PY_SRC_DIR, '__pycache__')
src_pycache = os.path.join(z3py_src, '__pycache__')
if os.path.exists(src_pycache):
for pyc in filter(lambda f: f.endswith('.pyc'), os.listdir(src_pycache)):
target_pycache = os.path.join(BUILD_DIR, '__pycache__')
target_pycache = os.path.join(z3py_dest, '__pycache__')
mk_dir(target_pycache)
shutil.copyfile(os.path.join(src_pycache, pyc), os.path.join(target_pycache, pyc))
if is_verbose():

View file

@ -1706,7 +1706,7 @@ def generate_files(api_files,
with mk_file_or_temp(api_output_dir, 'api_log_macros.h') as log_h:
with mk_file_or_temp(api_output_dir, 'api_log_macros.cpp') as log_c:
with mk_file_or_temp(api_output_dir, 'api_commands.cpp') as exe_c:
with mk_file_or_temp(z3py_output_dir, 'z3core.py') as core_py:
with mk_file_or_temp(z3py_output_dir, 'z3/z3core.py') as core_py:
# Write preambles
write_log_h_preamble(log_h)
write_log_c_preamble(log_c)