From 12d1ab5ae206564b78c124b669222b4872259ad3 Mon Sep 17 00:00:00 2001
From: Tianqi Chen <tqchen@users.noreply.github.com>
Date: Tue, 20 Feb 2018 16:56:59 -0800
Subject: [PATCH] [RUNTIME] More reliable runtime only detection (#914)

* [RUNTIME] More reliable runtime only detection

* fix lint
---
 python/tvm/_ffi/base.py    | 4 ++++
 python/tvm/build_module.py | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python/tvm/_ffi/base.py b/python/tvm/_ffi/base.py
index b17043c29..49348f311 100644
--- a/python/tvm/_ffi/base.py
+++ b/python/tvm/_ffi/base.py
@@ -41,6 +41,10 @@ def _load_lib():
 __version__ = libinfo.__version__
 # library instance of nnvm
 _LIB, _LIB_NAME = _load_lib()
+
+# Whether we are runtime only
+_RUNTIME_ONLY = "runtime" in _LIB_NAME
+
 # The FFI mode of TVM
 _FFI_MODE = os.environ.get("TVM_FFI", "auto")
 
diff --git a/python/tvm/build_module.py b/python/tvm/build_module.py
index 9c442a074..86d150c08 100755
--- a/python/tvm/build_module.py
+++ b/python/tvm/build_module.py
@@ -6,9 +6,9 @@ LoweredFunc and compiled Module.
 from __future__ import absolute_import as _abs
 import warnings
 import types
-import os
 
 from ._ffi.node import NodeBase, register_node
+from ._ffi.base import _RUNTIME_ONLY
 from . import api
 from . import tensor
 from . import schedule
@@ -226,7 +226,7 @@ def build_config(**kwargs):
             setattr(config, k, kwargs[k])
     return config
 
-if not os.environ.get("TVM_USE_RUNTIME_LIB", False):
+if not _RUNTIME_ONLY:
     # BuildConfig is not available in tvm_runtime
     BuildConfig.current = build_config()
 
-- 
GitLab