Skip to content

Commit

Permalink
Merge pull request #89 from xylar/fix-esmpy-8.4.x
Browse files Browse the repository at this point in the history
Patch to fix esmpy import for esmpy >= 8.4.0
  • Loading branch information
xylar committed Aug 2, 2023
2 parents bec0cb7 + 957e5bb commit 5afc8b6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .azure-pipelines/azure-pipelines-linux.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .ci_support/migrations/jasper4.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .ci_support/migrations/libnetcdf491.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .ci_support/migrations/libnetcdf492.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .scripts/run_osx_build.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions recipe/0013-esmpy-imports.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff -ruN cdms-3.1.5/regrid2/Lib/esmf.py cdms-3.1.5-patch/regrid2/Lib/esmf.py
--- cdms-3.1.5/regrid2/Lib/esmf.py 2020-07-31 03:01:33.000000000 +0200
+++ cdms-3.1.5-patch/regrid2/Lib/esmf.py 2023-08-01 09:02:26.554853011 +0200
@@ -15,7 +15,10 @@
import time
import numpy
from regrid2 import RegridError
-import ESMF
+try:
+ import esmpy as ESMF
+except ImportError:
+ import ESMF
from functools import reduce

# constants
diff -ruN cdms-3.1.5/regrid2/Lib/__init__.py cdms-3.1.5-patch/regrid2/Lib/__init__.py
--- cdms-3.1.5/regrid2/Lib/__init__.py 2020-07-31 03:01:33.000000000 +0200
+++ cdms-3.1.5-patch/regrid2/Lib/__init__.py 2023-08-01 09:01:50.815080096 +0200
@@ -14,7 +14,10 @@
from .mvGenericRegrid import GenericRegrid # noqa
from .mvLibCFRegrid import LibCFRegrid # noqa
try:
- import ESMF
+ try:
+ import esmpy as ESMF
+ except ImportError:
+ import ESMF
ESMF.deprecated.__globals__[
'warnings'].warn_explicit = ESMF.deprecated.__globals__['warnings'].formatwarning
from .mvESMFRegrid import ESMFRegrid # noqa
@@ -24,7 +27,10 @@
ESMF_HAS_BEEN_INITIALIZED = False
if not ESMF_HAS_BEEN_INITIALIZED:
try:
- import ESMF
+ try:
+ import esmpy as ESMF
+ except ImportError:
+ import ESMF
ESMF.deprecated.__globals__[
'warnings'].warn_explicit = ESMF.deprecated.__globals__['warnings'].formatwarning
ESMF.Manager(debug=False)
diff -ruN cdms-3.1.5/regrid2/Lib/mvESMFRegrid.py cdms-3.1.5-patch/regrid2/Lib/mvESMFRegrid.py
--- cdms-3.1.5/regrid2/Lib/mvESMFRegrid.py 2020-07-31 03:01:33.000000000 +0200
+++ cdms-3.1.5-patch/regrid2/Lib/mvESMFRegrid.py 2023-08-01 09:02:26.538853112 +0200
@@ -12,7 +12,10 @@
import socket
import numpy

-import ESMF
+try:
+ import esmpy as ESMF
+except ImportError:
+ import ESMF
from . import esmf
from . import RegridError
from .mvGenericRegrid import GenericRegrid
diff -ruN cdms-3.1.5/regrid2/Lib/mytest.py cdms-3.1.5-patch/regrid2/Lib/mytest.py
--- cdms-3.1.5/regrid2/Lib/mytest.py 2020-07-31 03:01:33.000000000 +0200
+++ cdms-3.1.5-patch/regrid2/Lib/mytest.py 2023-08-01 09:04:07.634210699 +0200
@@ -1,2 +1,6 @@
-import ESMF # noqa
+try:
+ import esmpy as ESMF # noqa
+except ImportError:
+ import ESMF # noqa
+
from .mvESMFRegrid import ESMFRegrid # noqa
4 changes: 3 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ source:
- 0010-Adds-LongLong-type-for-CDML.patch
- 0011-remove-numpy-float-int.patch
- 0012-remove-libdrs-rename-libgrib2c.patch
- 0013-esmpy-imports.patch

build:
number: 20
number: 21
skip: True # [win]

requirements:
Expand Down Expand Up @@ -69,6 +70,7 @@ test:
- python -c 'import regrid2'
- python -c 'import regrid2._regrid'
- python -c 'import regrid2._scrip'
- python -c 'from regrid2 import ESMFRegrid'
- cdscan --help

about:
Expand Down

0 comments on commit 5afc8b6

Please sign in to comment.