From 44d86637c99a4daba81b663445e239625784f05b Mon Sep 17 00:00:00 2001 From: daminaka Date: Fri, 18 Jan 2019 13:30:05 -0800 Subject: [PATCH 1/3] installation on current python environment --- build_ngtf.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/build_ngtf.py b/build_ngtf.py index b26ab30f..c9d11857 100755 --- a/build_ngtf.py +++ b/build_ngtf.py @@ -241,10 +241,11 @@ def build_tensorflow(venv_dir, src_dir, artifacts_dir, target_arch, verbosity): os.chdir(pwd) -def install_tensorflow(venv_dir, artifacts_dir): +def install_tensorflow(venv_dir, artifacts_dir, system): - # Load the virtual env - load_venv(venv_dir) + if system: + # Load the virtual env + load_venv(venv_dir) # Install tensorflow pip tf_pip = os.path.join(os.path.abspath(artifacts_dir), "tensorflow") @@ -278,8 +279,9 @@ def build_ngraph_tf(artifacts_location, ngtf_src_loc, venv_dir, cmake_flags, verbose): pwd = os.getcwd() - # Load the virtual env - load_venv(venv_dir) + if not system: + # Load the virtual env + load_venv(venv_dir) command_executor(["pip", "list"]) @@ -340,9 +342,10 @@ def build_ngraph_tf(artifacts_location, ngtf_src_loc, venv_dir, cmake_flags, return output_wheel -def install_ngraph_tf(venv_dir, ngtf_pip_whl): - # Load the virtual env - load_venv(venv_dir) +def install_ngraph_tf(venv_dir, ngtf_pip_whl, system): + if not system: + # Load the virtual env + load_venv(venv_dir) command_executor(["pip", "install", "-U", ngtf_pip_whl]) @@ -413,6 +416,11 @@ def main(): help="Builds a distributed version of the nGraph components\n", action="store_true") + parser.add_argument( + '--system', + help="install on system (or current) python environment\n" + action="store_true") + arguments = parser.parse_args() if (arguments.debug_build): @@ -423,6 +431,10 @@ def main(): print("Building in with VERBOSE output messages\n") verbosity = True + system = False + if arguments.system: + print("use system (or current venv) Python for install target\n") + system = True #------------------------------- # Recipe #------------------------------- @@ -455,12 +467,13 @@ def main(): artifacts_location = os.path.abspath(artifacts_location) print("ARTIFACTS location: " + artifacts_location) - if not use_prebuilt_binaries: + if not use_prebuilt_binaries or system: #install virtualenv install_virtual_env(venv_dir) # Load the virtual env - load_venv(venv_dir) + if not system: + load_venv(venv_dir) if not use_prebuilt_binaries: # Setup the virtual env @@ -484,7 +497,7 @@ def main(): target_arch, verbosity) # Install tensorflow - cxx_abi = install_tensorflow(venv_dir, artifacts_location) + cxx_abi = install_tensorflow(venv_dir, artifacts_location, system) else: print("Skipping the TensorFlow build") import tensorflow as tf @@ -545,12 +558,12 @@ def main(): # Now build the bridge ng_tf_whl = build_ngraph_tf(artifacts_location, "../", venv_dir, - ngraph_tf_cmake_flags, verbosity) + ngraph_tf_cmake_flags, verbosity, system) print("SUCCESSFULLY generated wheel: %s" % ng_tf_whl) # Run a quick test - install_ngraph_tf(venv_dir, os.path.join(artifacts_location, ng_tf_whl)) + install_ngraph_tf(venv_dir, os.path.join(artifacts_location, ng_tf_whl), system) os.chdir(pwd) From 4e70754213788472b15d247939c740092df2798e Mon Sep 17 00:00:00 2001 From: daminaka Date: Fri, 18 Jan 2019 13:30:05 -0800 Subject: [PATCH 2/3] installation on current python environment --- build_ngtf.py | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/build_ngtf.py b/build_ngtf.py index b26ab30f..abc2c627 100755 --- a/build_ngtf.py +++ b/build_ngtf.py @@ -241,10 +241,11 @@ def build_tensorflow(venv_dir, src_dir, artifacts_dir, target_arch, verbosity): os.chdir(pwd) -def install_tensorflow(venv_dir, artifacts_dir): +def install_tensorflow(venv_dir, artifacts_dir, system): - # Load the virtual env - load_venv(venv_dir) + if not system: + # Load the virtual env + load_venv(venv_dir) # Install tensorflow pip tf_pip = os.path.join(os.path.abspath(artifacts_dir), "tensorflow") @@ -278,8 +279,9 @@ def build_ngraph_tf(artifacts_location, ngtf_src_loc, venv_dir, cmake_flags, verbose): pwd = os.getcwd() - # Load the virtual env - load_venv(venv_dir) + if not system: + # Load the virtual env + load_venv(venv_dir) command_executor(["pip", "list"]) @@ -340,9 +342,10 @@ def build_ngraph_tf(artifacts_location, ngtf_src_loc, venv_dir, cmake_flags, return output_wheel -def install_ngraph_tf(venv_dir, ngtf_pip_whl): - # Load the virtual env - load_venv(venv_dir) +def install_ngraph_tf(venv_dir, ngtf_pip_whl, system): + if not system: + # Load the virtual env + load_venv(venv_dir) command_executor(["pip", "install", "-U", ngtf_pip_whl]) @@ -413,6 +416,11 @@ def main(): help="Builds a distributed version of the nGraph components\n", action="store_true") + parser.add_argument( + '--system', + help="install on system (or current) python environment\n" + action="store_true") + arguments = parser.parse_args() if (arguments.debug_build): @@ -423,6 +431,10 @@ def main(): print("Building in with VERBOSE output messages\n") verbosity = True + system = False + if arguments.system: + print("use system (or current venv) Python for install target\n") + system = True #------------------------------- # Recipe #------------------------------- @@ -455,12 +467,13 @@ def main(): artifacts_location = os.path.abspath(artifacts_location) print("ARTIFACTS location: " + artifacts_location) - if not use_prebuilt_binaries: + if not use_prebuilt_binaries or not system: #install virtualenv install_virtual_env(venv_dir) # Load the virtual env - load_venv(venv_dir) + if not system: + load_venv(venv_dir) if not use_prebuilt_binaries: # Setup the virtual env @@ -484,7 +497,7 @@ def main(): target_arch, verbosity) # Install tensorflow - cxx_abi = install_tensorflow(venv_dir, artifacts_location) + cxx_abi = install_tensorflow(venv_dir, artifacts_location, system) else: print("Skipping the TensorFlow build") import tensorflow as tf @@ -545,12 +558,12 @@ def main(): # Now build the bridge ng_tf_whl = build_ngraph_tf(artifacts_location, "../", venv_dir, - ngraph_tf_cmake_flags, verbosity) + ngraph_tf_cmake_flags, verbosity, system) print("SUCCESSFULLY generated wheel: %s" % ng_tf_whl) # Run a quick test - install_ngraph_tf(venv_dir, os.path.join(artifacts_location, ng_tf_whl)) + install_ngraph_tf(venv_dir, os.path.join(artifacts_location, ng_tf_whl), system) os.chdir(pwd) From c08f93e5817d181433e7582b74c2213b2f5b0e93 Mon Sep 17 00:00:00 2001 From: daminaka Date: Fri, 18 Jan 2019 15:07:35 -0800 Subject: [PATCH 3/3] run setup_env for system --- build_ngtf.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build_ngtf.py b/build_ngtf.py index 0e42a1d6..cbae2ab7 100755 --- a/build_ngtf.py +++ b/build_ngtf.py @@ -111,8 +111,9 @@ def load_venv(venv_dir): return venv_dir -def setup_venv(venv_dir): - load_venv(venv_dir) +def setup_venv(venv_dir, system): + if not system: + load_venv(venv_dir) print("PIP location") call(['which', 'pip']) @@ -475,9 +476,9 @@ def main(): if not system: load_venv(venv_dir) - if not use_prebuilt_binaries and not system: + if not use_prebuilt_binaries: # Setup the virtual env - setup_venv(venv_dir) + setup_venv(venv_dir, system) target_arch = 'native' if (arguments.target_arch):