From 0a958b9d697df62df0206e5e76665ee72e95aed9 Mon Sep 17 00:00:00 2001 From: Nick Felt <nickfelt@google.com> Date: Fri, 11 Jan 2019 19:11:17 -0800 Subject: [PATCH] fix logic adding generated API directory to tensorflow.__path__ --- tensorflow/api_template_v1.__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py index b293d0f1534..eeca8f0d566 100644 --- a/tensorflow/api_template_v1.__init__.py +++ b/tensorflow/api_template_v1.__init__.py @@ -62,12 +62,15 @@ if '__all__' in vars(): vars()['__all__'].append('contrib') from tensorflow.python.platform import flags # pylint: disable=g-import-not-at-top -from tensorflow.python.platform import app # pylint: disable=g-import-not-at-top -app.flags = flags +# The 'app' module will be imported as part of the placeholder section above. +app.flags = flags # pylint: disable=undefined-variable + +# Also use 'app' module (choice is arbitrary) to derive the API directory below. +_API_MODULE = app # pylint: disable=undefined-variable # Make sure directory containing top level submodules is in # the __path__ so that "from tensorflow.foo import bar" works. -_tf_api_dir = _os.path.dirname(_os.path.dirname(app.__file__)) # pylint: disable=undefined-variable +_tf_api_dir = _os.path.dirname(_os.path.dirname(_API_MODULE.__file__)) # pylint: disable=undefined-variable if not hasattr(_current_module, '__path__'): __path__ = [_tf_api_dir] elif _tf_api_dir not in __path__: