Package: eccodes / 2.12.0-1

py3-fixes.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Index: eccodes-2.12.0/python/CMakeLists.txt
===================================================================
--- eccodes-2.12.0.orig/python/CMakeLists.txt
+++ eccodes-2.12.0/python/CMakeLists.txt
@@ -1,9 +1,9 @@
 if( HAVE_PYTHON )
 
-    #find_package( SWIG )
-    #if( SWIG_FOUND )
-    #    include( ${SWIG_USE_FILE} )
-    #endif()
+    find_package( SWIG )
+    if( SWIG_FOUND )
+        include( ${SWIG_USE_FILE} )
+    endif()
 
     # preparing for generating setup.py
     if( HAVE_LIBJASPER )
Index: eccodes-2.12.0/python/gribapi_swig.i
===================================================================
--- eccodes-2.12.0.orig/python/gribapi_swig.i
+++ eccodes-2.12.0/python/gribapi_swig.i
@@ -17,14 +17,17 @@
 import_array();
 %}
 
-/* Converts a PyFile instance to a stdio FILE* */
+
+ /* FIXME: Can we make this ro/rw ? */
 %typemap(in) FILE* {
-    if ( PyFile_Check($input) ){
-        $1 = PyFile_AsFile($input);
-    } else {
-        PyErr_SetString(PyExc_TypeError, "$1_name must be a file type.");
-        return NULL;
-    }
+  int fd;
+  fd = PyObject_AsFileDescriptor($input);
+  if ( fd >= 0 ) {
+    $1 = fopen(fd, "r+"); 
+  } else {
+    PyErr_SetString(PyExc_TypeError, "$1_name must be a file type.");
+    return NULL;
+  }
 }
 
 %pointer_class(int, intp);
@@ -67,6 +70,7 @@ int grib_c_count_in_file(FILE* f,int* OU
 // grib handle operations
 int grib_c_release(int* gid);
 int grib_c_write(int* gid, FILE* f);
+
 int grib_c_get_size_long(int* gid, char* key, long* OUTPUT);
 int grib_c_get_string_length(int* gid, char* key, size_t* OUTPUT);
 int grib_c_clone(int* gid,int* INOUT);
@@ -77,9 +81,9 @@ int grib_c_get_native_type(int* gid, cha
 // ---
 
 // multi support
+int grib_c_multi_write(int* gid, FILE* f);
 int grib_c_multi_new(int* OUTPUT);
 int grib_c_multi_support_on(void);
-int grib_c_multi_write(int* gid, FILE* f);
 int grib_c_multi_support_off(void);
 int grib_c_multi_release(int* gid);
 int grib_c_multi_append(int* INPUT, int* INPUT,int* INPUT);
Index: eccodes-2.12.0/python/eccodes/high_level/codesfile.py
===================================================================
--- eccodes-2.12.0.orig/python/eccodes/high_level/codesfile.py
+++ eccodes-2.12.0/python/eccodes/high_level/codesfile.py
@@ -6,9 +6,9 @@ Author: Daniel Lee, DWD, 2016
 """
 
 from .. import eccodes
+from io import IOBase
 
-
-class CodesFile(file):
+class CodesFile(IOBase):
 
     """
     An abstract class to specify and/or implement common behaviour that files
Index: eccodes-2.12.0/python/gribapi/gribapi.py
===================================================================
--- eccodes-2.12.0.orig/python/gribapi/gribapi.py
+++ eccodes-2.12.0/python/gribapi/gribapi.py
@@ -22,15 +22,15 @@ When this is enabed, then the system Pyt
     - NumPy
 
 """
-import gribapi_swig as _internal
-from gribapi import gribapi_swig as _internal
+# import gribapi_swig as _internal
+from . import gribapi_swig as _internal
 import types
 import sys
 import os
 from functools import wraps
 # import inspect
 from . import errors
-from errors import *  # noqa
+from .errors import *  # noqa
 
 try:
     type(file)
Index: eccodes-2.12.0/python/gribapi/errors.py
===================================================================
--- eccodes-2.12.0.orig/python/gribapi/errors.py
+++ eccodes-2.12.0/python/gribapi/errors.py
@@ -2,7 +2,7 @@
 Exception class hierarchy
 """
 
-import gribapi_swig as _internal
+from . import gribapi_swig as _internal
 
 
 class GribInternalError(Exception):