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

Patch to fix esmpy import for esmpy >= 8.4.0 #89

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chengzhuzhang, hopefully this check will prevent issues like E3SM-Project/e3sm_diags#711 from happening in the future.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like regridding behavior gets back to normal with this fix!

- cdscan --help

about:
Expand Down