From ca63cf788978db0bde2db4ce488e102c455da2e7 Mon Sep 17 00:00:00 2001 From: Jonas Eschle Date: Thu, 9 Jun 2022 14:18:41 +0200 Subject: [PATCH] fix: move openexr to runtime dependency --- .github/workflows/build.yml | 1 + .github/workflows/tfg-main-pypi.yml | 1 + .github/workflows/tfg-nightly-pypi.yml | 1 + .github/workflows/tfg-test-pypi.yml | 1 + requirements.txt | 1 - tensorflow_graphics/__init__.py | 2 +- tensorflow_graphics/io/exr.py | 14 +++++++++++++- 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 078af0570..7166f0985 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -U -r requirements.txt + pip install -U openexr pip install -U pytest coveralls pip install -U flake8 pip install -U setuptools wheel diff --git a/.github/workflows/tfg-main-pypi.yml b/.github/workflows/tfg-main-pypi.yml index 741dc116e..9e7b76a3f 100644 --- a/.github/workflows/tfg-main-pypi.yml +++ b/.github/workflows/tfg-main-pypi.yml @@ -21,6 +21,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -U -r requirements.txt + pip install -U openexr pip install -U pytest pip install -U setuptools wheel pip install -U twine diff --git a/.github/workflows/tfg-nightly-pypi.yml b/.github/workflows/tfg-nightly-pypi.yml index c77d40483..f2a974c19 100644 --- a/.github/workflows/tfg-nightly-pypi.yml +++ b/.github/workflows/tfg-nightly-pypi.yml @@ -25,6 +25,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -U -r requirements.txt + pip install -U openexr pip install -U pytest pip install -U setuptools wheel pip install -U twine diff --git a/.github/workflows/tfg-test-pypi.yml b/.github/workflows/tfg-test-pypi.yml index bd7496b0a..b9d615f25 100644 --- a/.github/workflows/tfg-test-pypi.yml +++ b/.github/workflows/tfg-test-pypi.yml @@ -21,6 +21,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -U -r requirements.txt + pip install -U openexr pip install -U pytest pip install -U setuptools wheel pip install -U twine diff --git a/requirements.txt b/requirements.txt index cb1a66eaf..9f345abbf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ numpy >= 1.15.4 psutil >= 5.7.0 scipy >= 1.1.0 tqdm >= 4.45.0 -OpenEXR >= 1.3.2 termcolor >= 1.1.0 trimesh >= 2.37.22 # Required by trimesh. diff --git a/tensorflow_graphics/__init__.py b/tensorflow_graphics/__init__.py index 063fb8005..985d6226f 100644 --- a/tensorflow_graphics/__init__.py +++ b/tensorflow_graphics/__init__.py @@ -49,4 +49,4 @@ __all__.remove("util") # pylint: enable=g-statement-before-imports,g-import-not-at-top -__version__ = "HEAD" +__version__ = "2022.6.9" diff --git a/tensorflow_graphics/io/exr.py b/tensorflow_graphics/io/exr.py index 9885a3af8..3c1481116 100644 --- a/tensorflow_graphics/io/exr.py +++ b/tensorflow_graphics/io/exr.py @@ -13,6 +13,7 @@ # limitations under the License. """Utility functions for reading and writing EXR image files as numpy arrays.""" + # pylint: disable=c-extension-no-member from __future__ import absolute_import @@ -21,7 +22,18 @@ import Imath import numpy as np -import OpenEXR +from packaging import version + +try: + import OpenEXR +except ImportError: + raise ImportError('OpenEXR is required for reading and writing EXR files, please install it.') +else: + _min_version_openexr = "1.3.2" + if not version.parse(OpenEXR.__version__.decode("utf-8")) > version.parse(_min_version_openexr): + raise ImportError( + f"OpenEXR version {_min_version_openexr} is required, please upgrade it." + ) from six.moves import range from six.moves import zip