1717from __future__ import division
1818from __future__ import print_function
1919
20- # We need to put some imports inside a function call below, and the function
21- # call needs to come before the *actual* imports that populate the
22- # tensorflow_probability namespace. Hence, we disable this lint check throughout
23- # the file.
24- #
25-
26-
27- # Ensure TensorFlow is importable and its version is sufficiently recent. This
28- # needs to happen before anything else, since the imports below will try to
29- # import tensorflow, too.
30- def _ensure_tf_install ():
31- """Attempt to import tensorflow, and ensure its version is sufficient.
32-
33- Raises:
34- ImportError: if either tensorflow is not importable or its version is
35- inadequate.
36- """
37- try :
38- import tensorflow as tf
39- except ImportError :
40- # Print more informative error message, then reraise.
41- print ("\n \n Failed to import TensorFlow. Please note that TensorFlow is"
42- " not installed by default when you install TensorFlow Addons."
43- " This is so that users can decide whether to install the"
44- " GPU-enabled TensorFlow package. To use TensorFlow Addons,"
45- " please install the most recent version of TensorFlow, by"
46- " following instructions at https://tensorflow.org/install.\n \n " )
47- raise
48-
49- import distutils .version
50-
51- #
52- # Update this whenever we need to depend on a newer TensorFlow release.
53- #
54- required_tensorflow_version = "2"
55-
56- if (distutils .version .LooseVersion (tf .__version__ ) <
57- distutils .version .LooseVersion (required_tensorflow_version )):
58- raise ImportError (
59- "This version of TensorFlow Addons requires TensorFlow "
60- "version >= {required}; Detected an installation of version "
61- "{present}. Please upgrade TensorFlow to proceed." .format (
62- required = required_tensorflow_version , present = tf .__version__ ))
63-
64-
65- _ensure_tf_install ()
66-
67- # Cleanup symbols to avoid polluting namespace.
68- del _ensure_tf_install
69- del absolute_import
70- del division
71- del print_function
72-
7320# Local project imports
7421from tensorflow_addons import activations
7522from tensorflow_addons import callbacks
@@ -83,3 +30,8 @@ def _ensure_tf_install():
8330from tensorflow_addons import text
8431
8532from tensorflow_addons .version import __version__
33+
34+ # Cleanup symbols to avoid polluting namespace.
35+ del absolute_import
36+ del division
37+ del print_function
0 commit comments