Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: Remove hard installation dep #974

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move to utils
  • Loading branch information
seanpmorgan committed Jan 30, 2020
commit cd288fdf99b0517658893bc53dd0ccf7144cf2ce
31 changes: 1 addition & 30 deletions tensorflow_addons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,7 @@
# limitations under the License.
# ==============================================================================
"""Useful extra functionality for TensorFlow maintained by SIG-addons."""


# Ensure TensorFlow is importable and its version is sufficiently recent. This
# needs to happen before anything else, since the imports below will try to
# import tensorflow, too.
def _ensure_tf_install():
"""Attempt to import tensorflow, and ensure its version is sufficient.
Raises:
ImportError: if either tensorflow is not importable or its version is
inadequate.
"""
import tensorflow as tf
import distutils.version

#
# Update this whenever we need to depend on a newer TensorFlow release.
#
required_tensorflow_version = "2.1.0"

if distutils.version.LooseVersion(tf.__version__) < distutils.version.LooseVersion(
required_tensorflow_version
):
raise ImportError(
"This version of TensorFlow Addons requires TensorFlow "
"version >= {required}; Detected an installation of version "
"{present}. Please upgrade TensorFlow to proceed.".format(
required=required_tensorflow_version, present=tf.__version__
)
)

from tensorflow_addons.utils.ensure_tf_install import _ensure_tf_install

_ensure_tf_install()

Expand Down
43 changes: 43 additions & 0 deletions tensorflow_addons/utils/ensure_tf_install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================


# Ensure TensorFlow is importable and its version is sufficiently recent. This
# needs to happen before anything else, since the imports below will try to
# import tensorflow, too.
def _ensure_tf_install():
"""Attempt to import tensorflow, and ensure its version is sufficient.
Raises:
ImportError: if either tensorflow is not importable or its version is
inadequate.
"""
import tensorflow as tf
import distutils.version

#
# Update this whenever we need to depend on a newer TensorFlow release.
#
required_tensorflow_version = "2.1.0"

if distutils.version.LooseVersion(tf.__version__) < distutils.version.LooseVersion(
required_tensorflow_version
):
raise ImportError(
"This version of TensorFlow Addons requires TensorFlow "
"version >= {required}; Detected an installation of version "
"{present}. Please upgrade TensorFlow to proceed.".format(
required=required_tensorflow_version, present=tf.__version__
)
)