[pyferret] 58/110: [WIP]: Now compiles both python2 and python3. test
Alastair McKinstry
mckinstry at moszumanska.debian.org
Fri Jul 28 08:42:01 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository pyferret.
commit 8d8db9804e2666e0604caae184b16c8fd9aae439
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Fri Aug 12 12:31:42 2016 +0100
[WIP]: Now compiles both python2 and python3. test
---
debian/patches/python3.patch | 564 +++++++++++++++++++++++++++++++++++++-
debian/patches/reproducible.patch | 10 +-
debian/rules | 15 +-
3 files changed, 569 insertions(+), 20 deletions(-)
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
index 184e318..b27d347 100644
--- a/debian/patches/python3.patch
+++ b/debian/patches/python3.patch
@@ -3617,14 +3617,574 @@ Index: pyferret-1.2.0/pyfermod/libpyferret.c
===================================================================
--- pyferret-1.2.0.orig/pyfermod/libpyferret.c
+++ pyferret-1.2.0/pyfermod/libpyferret.c
-@@ -42,6 +42,10 @@
+@@ -42,6 +42,13 @@
#include <stdlib.h>
#include <string.h>
+#if PY_MAJOR_VERSION >= 3
-+#define PyInt_AsLong PyLong_AsLong
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#define PyString_AsString(x) PyUnicode_AsUTF8(x)
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#define PyString_FromStringAndSize(x,y) PyUnicode_FromStringAndSize(x,y)
+#endif
+
#include "ferret.h"
#include "ferret_shared_buffer.h"
#include "EF_Util.h"
+@@ -49,6 +56,35 @@
+ #include "pyferret.h"
+ #include "pplmem.h"
+
++struct pyferret_module {
++ /* Flag of this Ferret's start/stop state */
++ int initialized;
++ /*
++ * for memory management in this module
++ * double *, instead of DFTYPE *, is used for ferMemory
++ * to create a warning if DFTYPE is not double.
++ */
++ size_t ferMemSize;
++ double *ferMemory;
++ float *pplMemory;
++ /* TODO: Merge errors to use this */
++ PyObject *error;
++};
++
++/* In Python3, we shouldn't have a global variable for module state; all the state should be via
++ * a struct (pyferret_module)
++ * In practice we still have a hacky need due to reallo_ppl_memory() so we have pyf_module below
++ */
++#if PY_MAJOR_VERSION >= 3
++#define MODULE_STATE(m) ((struct pyferret_module*)PyModule_GetState(m))
++#else
++#define MODULE_STATE(m) (&_state)
++static struct pyferret_module _state;
++#endif
++
++/* Hack. See if we can remove this static later */
++static struct pyferret_module *pyf_module = NULL;
++
+ /* global pyferret Python module object used for readline */
+ PyObject *pyferret_module_pyobject = NULL;
+
+@@ -67,17 +103,9 @@ PyObject *pyferret_graphbind_module_pyob
+ /* Length given to the abstract axis */
+ #define ABSTRACT_AXIS_LEN 9999999
+
+-/* Flag of this Ferret's start/stop state */
+-static int ferretInitialized = 0;
+
+-/*
+- * for memory management in this module
+- * double *, instead of DFTYPE *, is used for ferMemory
+- * to create a warning if DFTYPE is not double.
+- */
+-static size_t ferMemSize;
+-static double *ferMemory = NULL;
+-static float *pplMemory = NULL;
++
++
+
+ /* for recovering from seg faults */
+ static void (*segv_handler)(int);
+@@ -158,9 +186,11 @@ static PyObject *pyferretStart(PyObject
+ int ttoutLun = TTOUT_LUN;
+ int one_cmnd_mode_int;
+ PyObject *modulename;
+-
++ struct pyferret_module *module;
++
++ module = MODULE_STATE(self);
+ /* If already initialized, return False */
+- if ( ferretInitialized ) {
++ if ( module->initialized ) {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
+@@ -207,23 +237,23 @@ static PyObject *pyferretStart(PyObject
+
+ /* Initial allocation of PPLUS memory */
+ pplMemSize = 0.5 * 1.0E6;
+- pplMemory = (float *) PyMem_Malloc((size_t)pplMemSize * (size_t)sizeof(float));
+- if ( pplMemory == NULL )
++ module->pplMemory = (float *) PyMem_Malloc((size_t)pplMemSize * (size_t)sizeof(float));
++ if ( module->pplMemory == NULL )
+ return PyErr_NoMemory();
+- set_ppl_memory(pplMemory, pplMemSize);
++ set_ppl_memory(module->pplMemory, pplMemSize);
+
+ /* Initial allocation of Ferret memory - multiples of 100 PMAX_MEM_BLKS */
+ blksiz = (size_t) ((mwMemSize * 1.0E6 + (double)PMAX_MEM_BLKS - 1.0) / (double)PMAX_MEM_BLKS);
+ blksiz = (blksiz + 99) / 100;
+ blksiz *= 100;
+- ferMemSize = blksiz * (size_t)PMAX_MEM_BLKS;
++ module->ferMemSize = blksiz * (size_t)PMAX_MEM_BLKS;
+ /* Check for overflow */
+- if ( blksiz != ferMemSize / (size_t)PMAX_MEM_BLKS )
++ if ( blksiz != module->ferMemSize / (size_t)PMAX_MEM_BLKS )
+ return PyErr_NoMemory();
+- ferMemory = (double *) PyMem_Malloc(ferMemSize * (size_t)sizeof(double));
+- if ( ferMemory == NULL )
++ module->ferMemory = (double *) PyMem_Malloc( module->ferMemSize * (size_t)sizeof(double));
++ if ( module->ferMemory == NULL )
+ return PyErr_NoMemory();
+- set_fer_memory(ferMemory, ferMemSize);
++ set_fer_memory(module->ferMemory, module->ferMemSize);
+
+ if ( (metaname != NULL) || (unmappedFlag != 0) ) {
+ /*
+@@ -294,7 +324,10 @@ static PyObject *pyferretStart(PyObject
+ set_one_cmnd_mode_(&one_cmnd_mode_int);
+
+ /* Success - return True */
+- ferretInitialized = 1;
++ module->initialized = 1;
++
++ pyf_module = module;
++
+ Py_INCREF(Py_True);
+ return Py_True;
+ }
+@@ -306,7 +339,7 @@ static PyObject *pyferretStart(PyObject
+ * blksiz * PMAX_MEM_BLKS (defined in ferret.h as 2000)
+ * Returns: zero if fails, non-zero if successful
+ */
+-static int resizeFerretMemory(int blksiz)
++static int resizeFerretMemory(struct pyferret_module *module, int blksiz)
+ {
+ size_t actual_blksiz;
+ size_t newFerMemSize;
+@@ -325,20 +358,20 @@ static int resizeFerretMemory(int blksiz
+ * realloc since the contents of the old memory isn't needed.
+ * This could also result in a better garbage collection.
+ */
+- PyMem_Free(ferMemory);
+- ferMemory = (double *) PyMem_Malloc(newFerMemSize * (size_t)sizeof(double));
+- if ( ferMemory == NULL ) {
+- ferMemory = (double *) PyMem_Malloc(ferMemSize * (size_t)sizeof(double));
+- if ( ferMemory == NULL ) {
+- fprintf(stderr, "**ERROR: Unable to restore Ferret's memory cache of %f Mdoubles\n", (double)ferMemSize / 1.0E6);
++ PyMem_Free(module->ferMemory);
++ module->ferMemory = (double *) PyMem_Malloc(newFerMemSize * (size_t)sizeof(double));
++ if ( module->ferMemory == NULL ) {
++ module->ferMemory = (double *) PyMem_Malloc(module->ferMemSize * (size_t)sizeof(double));
++ if ( module->ferMemory == NULL ) {
++ fprintf(stderr, "**ERROR: Unable to restore Ferret's memory cache of %f Mdoubles\n", (double)module->ferMemSize / 1.0E6);
+ exit(1);
+ }
+ return 0;
+ }
+
+ /* Reallocation successful; assign the new memory */
+- ferMemSize = newFerMemSize;
+- set_fer_memory(ferMemory, ferMemSize);
++ module->ferMemSize = newFerMemSize;
++ set_fer_memory(module->ferMemory, module->ferMemSize);
+ return 1;
+ }
+
+@@ -348,14 +381,20 @@ static int resizeFerretMemory(int blksiz
+ */
+ void reallo_ppl_memory(int new_size)
+ {
+- if ( pplMemory != NULL )
+- PyMem_Free(pplMemory);
+- pplMemory = (float *) PyMem_Malloc((size_t)new_size * sizeof(float));
+- if ( pplMemory == NULL ) {
++
++ /* Horrible hack. Need to keep a global state var in libpyferret for reallo_ppl_memory
++ * to be free of tracking PyFerret module state
++ */
++ struct pyferret_module *module = pyf_module;
++
++ if ( module->pplMemory != NULL )
++ PyMem_Free(module->pplMemory);
++ module->pplMemory = (float *) PyMem_Malloc((size_t)new_size * sizeof(float));
++ if ( module->pplMemory == NULL ) {
+ printf("Unable to allocate the requested %d words of PLOT memory.\n", new_size);
+ exit(1);
+ }
+- set_ppl_memory(pplMemory, new_size);
++ set_ppl_memory(module->pplMemory, new_size);
+ }
+
+
+@@ -381,8 +420,9 @@ static PyObject *pyferretResizeMemory(Py
+ static char *argNames[] = {"memsize", NULL};
+ double mwMemSize;
+
++ struct pyferret_module *module = MODULE_STATE(self);
+ /* If not initialized, raise a MemoryError */
+- if ( ! ferretInitialized ) {
++ if ( ! module->initialized ) {
+ PyErr_SetString(PyExc_MemoryError, "Ferret not started");
+ return NULL;
+ }
+@@ -392,7 +432,7 @@ static PyObject *pyferretResizeMemory(Py
+ return NULL;
+
+ /* Reallocate the new amount of memory for Ferret */
+- if ( resizeFerretMemory((int) ((mwMemSize * 1.0E6 + (double)PMAX_MEM_BLKS - 1.0) / (double)PMAX_MEM_BLKS)) == 0 ) {
++ if ( resizeFerretMemory(module, (int) ((mwMemSize * 1.0E6 + (double)PMAX_MEM_BLKS - 1.0) / (double)PMAX_MEM_BLKS)) == 0 ) {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
+@@ -437,9 +477,11 @@ static PyObject *pyferretRunCommand(PyOb
+ int cmnd_stack_level;
+ char errmsg[2112];
+ int errval;
+-
++ struct pyferret_module *module;
++
++ module = MODULE_STATE(self);
+ /* If not initialized, raise a MemoryError */
+- if ( ! ferretInitialized ) {
++ if ( ! module->initialized ) {
+ PyErr_SetString(PyExc_MemoryError, "Ferret not started");
+ return NULL;
+ }
+@@ -470,15 +512,15 @@ static PyObject *pyferretRunCommand(PyOb
+ do {
+ cmnd_stack_level = 0;
+ /* Run the Ferret command */
+- ferret_dispatch_c(ferMemory, iter_command, sBuffer);
++ ferret_dispatch_c(module->ferMemory, iter_command, sBuffer);
+
+ if ( sBuffer->flags[FRTN_ACTION] == FACTN_MEM_RECONFIGURE ) {
+ /* resize, then re-enter if not single-command mode */
+- if ( resizeFerretMemory(sBuffer->flags[FRTN_IDATA1]) == 0 ) {
++ if ( resizeFerretMemory(module, sBuffer->flags[FRTN_IDATA1]) == 0 ) {
+ printf("Unable to resize Ferret's memory cache to %f Mdoubles\n",
+ (double)(sBuffer->flags[FRTN_IDATA1]) * (double)PMAX_MEM_BLKS / 1.0E6);
+ printf("Ferret's memory cache remains at %f Mdoubles\n",
+- (double)(ferMemSize) / 1.0E6);
++ (double)(module->ferMemSize) / 1.0E6);
+ }
+ cmnd_stack_level = sBuffer->flags[FRTN_IDATA2];
+ }
+@@ -580,9 +622,12 @@ static PyObject *pyferretGetData(PyObjec
+ char axis_units[MAX_FERRET_NDIM][64];
+ char axis_names[MAX_FERRET_NDIM][64];
+ CALTYPE calendar_type;
++ struct pyferret_module *module;
+
++ module = MODULE_STATE(self);
++
+ /* If not initialized, raise a MemoryError */
+- if ( ! ferretInitialized ) {
++ if ( ! module->initialized ) {
+ PyErr_SetString(PyExc_MemoryError, "Ferret not started");
+ return NULL;
+ }
+@@ -603,7 +648,7 @@ static PyObject *pyferretGetData(PyObjec
+ * Retrieve the memory parameters describing the data array requested.
+ * Assumes Unix standard for passing strings to Fortran (appended array lengths).
+ */
+- get_data_array_params_(dataname, &lendataname, ferMemory, &arraystart, memlo, memhi,
++ get_data_array_params_(dataname, &lendataname, module->ferMemory, &arraystart, memlo, memhi,
+ steplo, stephi, incr, dataunit, &lendataunit, axis_types,
+ &badval, errmsg, &lenerrmsg, 1024, 64, 2112);
+ if ( lenerrmsg > 0 ) {
+@@ -642,7 +687,7 @@ static PyObject *pyferretGetData(PyObjec
+ * Assign the data in the new ndarray.
+ * Note: if MAX_FERRET_NDIM changes, this needs editing.
+ */
+- ferdata = ferMemory + arraystart;
++ ferdata = module->ferMemory + arraystart;
+ npydata = PyArray_DATA(data_ndarray);
+ q = 0;
+ for (n = 0; n < (int)(shape[5]); n++) {
+@@ -875,7 +920,7 @@ static PyObject *pyferretPutData(PyObjec
+ int len_errmsg;
+
+ /* If not initialized, raise a MemoryError */
+- if ( ! ferretInitialized ) {
++ if ( ! MODULE_STATE(self)->initialized ) {
+ PyErr_SetString(PyExc_MemoryError, "Ferret not started");
+ return NULL;
+ }
+@@ -1143,14 +1188,16 @@ static char pyferretStopDocstring[] =
+
+ static PyObject *pyferretStop(PyObject *self)
+ {
++ struct pyferret_module *module = MODULE_STATE(self);
+ /* If not initialized, return False */
+- if ( ! ferretInitialized ) {
++ if ( ! module->initialized ) {
+ Py_INCREF(Py_False);
+ return Py_False;
+ }
+
+ /* Set to uninitialized */
+- ferretInitialized = 0;
++ module->initialized = 0;
++ pyf_module = NULL;
+
+ /* Release the references to the pyferret and pyferret.graphbind modules */
+ Py_DECREF(pyferret_graphbind_module_pyobject);
+@@ -1159,24 +1206,24 @@ static PyObject *pyferretStop(PyObject *
+ pyferret_module_pyobject = NULL;
+
+ /* Run commands to clear/reset Ferret's state */
+- ferret_dispatch_c(ferMemory, "SET GRID ABSTRACT", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL WINDOW /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL VARIABLE /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL SYMBOL /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL DATA /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL REGION /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "CANCEL MEMORY /ALL", sBuffer);
+- ferret_dispatch_c(ferMemory, "EXIT /PROGRAM", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "SET GRID ABSTRACT", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL WINDOW /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL VARIABLE /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL SYMBOL /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL DATA /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL REGION /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "CANCEL MEMORY /ALL", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "EXIT /PROGRAM", sBuffer);
+
+ /* Free memory allocated inside Ferret */
+ finalize_();
+
+ /* Free memory allocated for Ferret */
+- PyMem_Free(ferMemory);
+- ferMemory = NULL;
+- ferMemSize = 0;
+- PyMem_Free(pplMemory);
+- pplMemory = NULL;
++ PyMem_Free(module->ferMemory);
++ module->ferMemory = NULL;
++ module->ferMemSize = 0;
++ PyMem_Free(module->pplMemory);
++ module->pplMemory = NULL;
+
+ /* Return True */
+ Py_INCREF(Py_True);
+@@ -1200,14 +1247,15 @@ static char pyferretQuitDocstring[] =
+
+ static PyObject *pyferretQuit(PyObject *self)
+ {
++ struct pyferret_module *module = MODULE_STATE(self);
+ /* If not initialized, nothing to do; just return None */
+- if ( ! ferretInitialized ) {
++ if ( ! module->initialized ) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ /* Set to uninitialized */
+- ferretInitialized = 0;
++ module->initialized = 0;
+
+ /* Release the references to the pyferret and pyferret.graphbind modules */
+ Py_DECREF(pyferret_graphbind_module_pyobject);
+@@ -1216,17 +1264,17 @@ static PyObject *pyferretQuit(PyObject *
+ pyferret_module_pyobject = NULL;
+
+ /* Let Ferret do its orderly shutdown - including closing viewers */
+- ferret_dispatch_c(ferMemory, "EXIT /PROGRAM", sBuffer);
++ ferret_dispatch_c(module->ferMemory, "EXIT /PROGRAM", sBuffer);
+
+ /* Free memory allocated inside Ferret */
+ finalize_();
+
+ /* Free memory allocated for Ferret */
+- PyMem_Free(ferMemory);
+- ferMemory = NULL;
+- ferMemSize = 0;
+- PyMem_Free(pplMemory);
+- pplMemory = NULL;
++ PyMem_Free(module->ferMemory);
++ module->ferMemory = NULL;
++ module->ferMemSize = 0;
++ PyMem_Free(module->pplMemory);
++ module->pplMemory = NULL;
+
+ /* Return None */
+ Py_INCREF(Py_None);
+@@ -1791,8 +1839,37 @@ static struct PyMethodDef pyferretMethod
+ static char pyferretModuleDocstring[] =
+ "An extension module enabling the use of Ferret from Python \n";
+
++
++#if PY_MAJOR_VERSION >= 3
++
++static int pyferretTraverse(PyObject *m, visitproc visit, void *arg) {
++ Py_VISIT(MODULE_STATE(m)->error);
++ return 0;
++}
++
++static int pyferretClear(PyObject *m) {
++ Py_CLEAR(MODULE_STATE(m)->error);
++ return 0;
++}
++
++static struct PyModuleDef moduledef = {
++ PyModuleDef_HEAD_INIT,
++ "libpyferret",
++ NULL,
++ sizeof(struct pyferret_module),
++ pyferretMethods,
++ NULL,
++ pyferretTraverse,
++ pyferretClear,
++ NULL
++};
++
++
++PyMODINIT_FUNC PyInit_libpyferret(void)
++#else /* !python3 */
+ /* For the libpyferret module, this function must be named initlibpyferret */
+ PyMODINIT_FUNC initlibpyferret(void)
++#endif
+ {
+ char names[64][32];
+ int values[64];
+@@ -1800,7 +1877,11 @@ PyMODINIT_FUNC initlibpyferret(void)
+ int k;
+
+ /* Create the module with the indicated methods */
++#if PY_MAJOR_VERSION >= 3
++ PyObject *mod = PyModule_Create(&moduledef);
++#else
+ PyObject *mod = Py_InitModule3("libpyferret", pyferretMethods, pyferretModuleDocstring);
++#endif
+
+ /* Add ferret parameter values */
+ get_ferret_params_(names, values, &numvals);
+@@ -1851,5 +1932,10 @@ PyMODINIT_FUNC initlibpyferret(void)
+
+ /* Private parameter return value from libpyferret._run indicating the program should shut down */
+ PyModule_AddIntConstant(mod, "_FERR_EXIT_PROGRAM", FERR_EXIT_PROGRAM);
++
++
++#if PY_MAJOR_VERSION >= 3
++ return mod;
++#endif
+ }
+
+Index: pyferret-1.2.0/pyfermod/pyefcn_result_limits.c
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyefcn_result_limits.c
++++ pyferret-1.2.0/pyfermod/pyefcn_result_limits.c
+@@ -39,6 +39,11 @@
+ #include "pyferret.h"
+ #include "EF_Util.h"
+
++#if PY_MAJOR_VERSION >=3
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#endif
++
+ static const char *AXIS_NAMES[MAX_FERRET_NDIM] = { "X", "Y", "Z", "T", "E", "F" };
+
+ /*
+Index: pyferret-1.2.0/fer/grdel/window.c
+===================================================================
+--- pyferret-1.2.0.orig/fer/grdel/window.c
++++ pyferret-1.2.0/fer/grdel/window.c
+@@ -24,6 +24,9 @@
+ #include "cferbind.h"
+ #include "pyferret.h"
+
++#if PY_MAJOR_VERSION >=3
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#endif
+
+ #ifdef VERBOSEDEBUG
+ #include <stdio.h>
+Index: pyferret-1.2.0/pyfermod/pyefcn_compute.c
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyefcn_compute.c
++++ pyferret-1.2.0/pyfermod/pyefcn_compute.c
+@@ -42,6 +42,12 @@
+ #include "pyferret.h"
+ #include "EF_Util.h"
+
++#if PY_MAJOR_VERSION >= 3
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#define PyInt_FromLong(x) PyLong_FromLong(x)
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#endif
++
+ /*
+ * See pyferret.h for information on this function
+ */
+Index: pyferret-1.2.0/pyfermod/pyefcn_init.c
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyefcn_init.c
++++ pyferret-1.2.0/pyfermod/pyefcn_init.c
+@@ -39,6 +39,12 @@
+ #include "pyferret.h"
+ #include "EF_Util.h"
+
++#if PY_MAJOR_VERSION >=3
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#define PyString_AsString(x) PyUnicode_AsUTF8(x)
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#endif
++
+ static const char *AXIS_NAMES[MAX_FERRET_NDIM] = { "X", "Y", "Z", "T", "E", "F" };
+
+ /*
+Index: pyferret-1.2.0/pyfermod/pyefcn_get_error.c
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyefcn_get_error.c
++++ pyferret-1.2.0/pyfermod/pyefcn_get_error.c
+@@ -35,6 +35,10 @@
+ #include <Python.h>
+ #include "pyferret.h"
+
++#if PY_MAJOR_VERSION >=3
++#define PyString_AsString(x) PyUnicode_AsUTF8(x)
++#endif
++
+ /*
+ * See pyferret.h for information on this function
+ */
+Index: pyferret-1.2.0/pyfermod/pyefcn_custom_axes.c
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyefcn_custom_axes.c
++++ pyferret-1.2.0/pyfermod/pyefcn_custom_axes.c
+@@ -39,6 +39,11 @@
+ #include "pyferret.h"
+ #include "EF_Util.h"
+
++#if PY_MAJOR_VERSION >= 3
++#define PyString_AsString(x) PyUnicode_AsUTF8(x)
++#define PyString_FromString(x) PyUnicode_FromString(x)
++#endif
++
+ static const char *AXIS_NAMES[MAX_FERRET_NDIM] = { "X", "Y", "Z", "T", "E", "F" };
+
+ /*
+Index: pyferret-1.2.0/pyfermod/pyferret.h
+===================================================================
+--- pyferret-1.2.0.orig/pyfermod/pyferret.h
++++ pyferret-1.2.0/pyfermod/pyferret.h
+@@ -1,8 +1,6 @@
+ #ifndef PYFERRET_H_
+ #define PYFERRET_H_
+
+-/* Python.h should already have been included */
+-
+ /* Ferret memory cache */
+ extern double *memory;
+
+Index: pyferret-1.2.0/setup.py
+===================================================================
+--- pyferret-1.2.0.orig/setup.py
++++ pyferret-1.2.0/setup.py
+@@ -56,7 +56,11 @@ lib_list.extend(fer_lib_list)
+ lib_list.extend(fer_lib_list)
+ lib_list.extend(fer_lib_list)
+ # Add required system libraries to the list to link in
+-lib_list.append("python%i.%i" % sys.version_info[:2])
++ver = sys.version_info[:2]
++if ver[0] == 2:
++ lib_list.append("python%i.%i" % ver)
++else:
++ lib_list.append("python%i.%im" %ver)
+
+ # Linking in the rest of the system libraries were moved to addn_link_flags
+ # in order to make sure the appropriate netcdff, netcdf, hdf5_hl, hdf5, and
diff --git a/debian/patches/reproducible.patch b/debian/patches/reproducible.patch
index b5f0175..ac3ecfc 100644
--- a/debian/patches/reproducible.patch
+++ b/debian/patches/reproducible.patch
@@ -26,13 +26,13 @@ Index: pyferret-1.2.0/fer/grdel/window.c
===================================================================
--- pyferret-1.2.0.orig/fer/grdel/window.c
+++ pyferret-1.2.0/fer/grdel/window.c
-@@ -24,6 +24,9 @@
- #include "cferbind.h"
- #include "pyferret.h"
+@@ -54,6 +54,9 @@ static void openlogfile(void)
+ }
+ #endif /* VERBOSEDEBUG */
+#if PY_MAJOR_VERSION >=3
+#define PyString_FromString(x) PyUnicode_FromString(x)
+#endif
- #ifdef VERBOSEDEBUG
- #include <stdio.h>
+ static const char *grdelwindowid = "GRDEL_WINDOW";
+
diff --git a/debian/rules b/debian/rules
index 54b8568..eb801c4 100755
--- a/debian/rules
+++ b/debian/rules
@@ -16,29 +16,18 @@ LIBDIR:=/usr/lib/$(ARCH)
INSTALLDIR:=$(CURDIR)/debian/tmp
PY2VERS:=$(shell pyversions -r)
-# PY3VERS:=$(shell py3versions -r)
+PY3VERS:=$(shell py3versions -r)
override_dh_auto_build:
cp debian/platform_specific.mk.debian .
cp debian/ef_utility/platform_specific.mk.debian external_functions/ef_utility/platform_specific.mk.debian
- # Python2.7
sed -e 's%@ARCH@%${ARCH}%' \
- -e 's%@PYTHON@%${PY2VERS}%' \
-e 's%@LIBDIR@%${LIBDIR}%' \
-e 's%@CURDIR@%${CURDIR}%' \
-e 's%@INSTALLDIR@%${INSTALLDIR}%' \
< debian/site_specific.mk.in > site_specific.mk
cp site_specific.mk external_functions/ef_utility
- dh_auto_build
- # Python3
- #sed -e 's%@ARCH@%${ARCH}%' \
- -e 's%@PYTHON@%${PY3VERS}%' \
- -e 's%@LIBDIR@%${LIBDIR}%' \
- -e 's%@CURDIR@%${CURDIR}%' \
- -e 's%@INSTALLDIR@%${INSTALLDIR}%' \
- < debian/site_specific.mk.in > site_specific.mk
- #cp site_specific.mk external_functions/ef_utility
- #dh_auto_build
+ $(MAKE) HOSTTYPE=debian all
override_dh_auto_install:
for p in $(PY2VERS) $(PY3VERS) ; do \
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyferret.git
More information about the debian-science-commits
mailing list