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 2 commits
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
7 changes: 5 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ ignore =
# Useful to ignore for "import keras.backend as K"
N812

#imported but unused in __init__.py, that's ok.
per-file-ignores = **/__init__.py:F401
per-file-ignores =
# imported but unused in __init__.py, that's ok.
**/__init__.py:F401
# import not at top okay due to TF installation check
tensorflow_addons/__init__.py:F401,E402
1 change: 1 addition & 0 deletions build_deps/build-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.1.0
gabrieldemarmiesse marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion build_deps/check_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def check_dependencies(requirement_file_name):
except DistributionNotFound as e:
print(e)
sys.exit(1)
sys.exit(0)


if __name__ == "__main__":
check_dependencies("requirements.txt")
check_dependencies("build_deps/build-requirements.txt")
sys.exit(0)
seanpmorgan marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 9 additions & 13 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def generate_shared_lib_name(namespec):
print()
print("Configuring TensorFlow Addons to be built from source...")

_PIP_INSTALL_OPTS = "--upgrade"
_PIP_INSTALL_OPTS = ["--upgrade"]
parser = argparse.ArgumentParser()
parser.add_argument("--quiet", action="store_true", help="Give less output.")
args = parser.parse_args()
if args.quiet:
_PIP_INSTALL_OPTS += " --quiet"
_PIP_INSTALL_OPTS.append("--quiet")

# Any python git package would be preferable
# _BRANCH=subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode('UTF-8').strip()
Expand All @@ -100,6 +100,9 @@ def generate_shared_lib_name(namespec):
with open("requirements.txt") as f:
_REQUIRED_PKG = f.read().splitlines()

with open("build_deps/build-requirements.txt") as f:
_REQUIRED_PKG.extend(f.read().splitlines())

seanpmorgan marked this conversation as resolved.
Show resolved Hide resolved
print()
print("> TensorFlow Addons will link to the framework in a pre-installed TF pacakge...")
print("> Checking installed packages in {}".format(_PYTHON_PATH))
Expand All @@ -112,17 +115,10 @@ def generate_shared_lib_name(namespec):
)
if reply in ("y", "Y"):
print("> Installing...")
subprocess.check_call(
[
_PYTHON_PATH,
"-m",
"pip",
"install",
_PIP_INSTALL_OPTS,
"-r",
"requirements.txt",
]
)
install_cmd = [_PYTHON_PATH, "-m", "pip", "install"]
install_cmd.extend(_PIP_INSTALL_OPTS)
install_cmd.extend(_REQUIRED_PKG)
subprocess.check_call(install_cmd)
else:
print("> Exiting...")
sys.exit()
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
tensorflow==2.1.0
typeguard
41 changes: 41 additions & 0 deletions tensorflow_addons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,47 @@
# ==============================================================================
"""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.
"""
try:
import tensorflow as tf
except ImportError:
# Print more informative error message, then reraise.
print(
gabrieldemarmiesse marked this conversation as resolved.
Show resolved Hide resolved
"\n\nFailed to import TensorFlow. Please note that TensorFlow is"
" not installed by default when you install TensorFlow Addons.\n\n"
)
raise

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__
)
)


_ensure_tf_install()

# Local project imports
from tensorflow_addons import activations
from tensorflow_addons import callbacks
Expand Down