in configure.py [0:0]
def create_build_configuration():
"""Main function to create build configuration."""
if os.path.isfile(_BAZELRC):
os.remove(_BAZELRC)
if os.path.isfile(_BAZEL_QUERY):
os.remove(_BAZEL_QUERY)
if os.path.isfile(_PYTHON_BIN_PATH):
os.remove(_PYTHON_BIN_PATH)
environ_cp = dict(os.environ)
setup_python(environ_cp)
print()
print('Configuring BigQuery ML Utils to be built from source...')
pip_install_options = ['--upgrade']
parser = argparse.ArgumentParser()
parser.add_argument('--quiet', action='store_true', help='Give less output.')
parser.add_argument(
'--no-deps',
action='store_true',
help='Do not check and install Python dependencies.',
)
args = parser.parse_args()
if args.quiet:
pip_install_options.append('--quiet')
with open('requirements.txt') as f:
required_packages = f.read().splitlines()
print()
if args.no_deps:
print('> Using pre-installed Tensorflow.')
else:
print('> Installing', required_packages)
install_cmd = [environ_cp['PYTHON_BIN_PATH'], '-m', 'pip', 'install']
install_cmd.extend(pip_install_options)
install_cmd.extend(required_packages)
subprocess.check_call(install_cmd)
logging.disable(logging.WARNING)
import tensorflow.compat.v2 as tf # pylint: disable=g-import-not-at-top
# pylint: disable=invalid-name
_TF_CFLAGS = tf.sysconfig.get_compile_flags()
_TF_LFLAGS = tf.sysconfig.get_link_flags()
_TF_CXX11_ABI_FLAG = tf.sysconfig.CXX11_ABI_FLAG
_TF_SHARED_LIBRARY_NAME = generate_shared_lib_name(_TF_LFLAGS)
_TF_HEADER_DIR = _TF_CFLAGS[0][2:]
_TF_SHARED_LIBRARY_DIR = _TF_LFLAGS[0][2:]
# pylint: enable=invalid-name
write_action_env('TF_HEADER_DIR', _TF_HEADER_DIR)
write_action_env('TF_SHARED_LIBRARY_DIR', _TF_SHARED_LIBRARY_DIR)
write_action_env('TF_SHARED_LIBRARY_NAME', _TF_SHARED_LIBRARY_NAME)
write_action_env('TF_CXX11_ABI_FLAG', _TF_CXX11_ABI_FLAG)
write_action_env('BAZEL_CXXOPTS', '-std=c++17')
write_to_bazelrc('build --spawn_strategy=standalone')
write_to_bazelrc('build --strategy=Genrule=standalone')
write_to_bazelrc('build --experimental_repo_remote_exec')
write_to_bazelrc('build --experimental_cc_shared_library')
write_to_bazelrc('build -c opt')
print()
print('Build configurations successfully written to', _BAZELRC)
print()
with open(_BAZEL_QUERY, 'a') as f:
f.write('bazel query "$@"')