mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 07:26:03 -06:00
36 lines
848 B
Python
36 lines
848 B
Python
#!/usr/bin/env python
|
|
import py_compile
|
|
import os
|
|
import os.path
|
|
import sys
|
|
|
|
# Small 'python compiler' used in the build system for ert. The
|
|
# commandline arguments should be:
|
|
#
|
|
# cmake_pyc.py src1.py src2.py src3.py /path/to/pyc/files
|
|
#
|
|
# The input source files can contain a path component like
|
|
# path/src1.py, but the path will not be recreated in the target
|
|
# domain.
|
|
|
|
|
|
def compile_file(src_file , target_file):
|
|
path = os.path.dirname( target_file )
|
|
if not os.path.exists( path ):
|
|
os.makedirs( path )
|
|
try:
|
|
py_compile.compile( src_file , cfile = target_file , doraise = True)
|
|
except Exception,error:
|
|
sys.exit(1)
|
|
|
|
|
|
target_path = sys.argv[-1]
|
|
for src_file in sys.argv[1:-1]:
|
|
compile_file( src_file , "%s/%sc" % (target_path , os.path.basename(src_file)))
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|