Skip to content

Commit 246de64

Browse files
Merge pull request #25 from FluidityProject/noble
Changes required for Noble. Spud and diamond appear to work with python 3.12-14 now...
2 parents 0f2d365 + be5d444 commit 246de64

File tree

6 files changed

+27
-26
lines changed

6 files changed

+27
-26
lines changed

debian/changelog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
spud (1.2.2) UNRELEASED; urgency=medium
2+
3+
* fixes for diamond and python libspud with python 3.12
4+
5+
-- Stephan Kramer <s.kramer@imperial.ac.uk> Fri, 07 Nov 2025 16:36:21 +0000
6+
7+
spud (1.2.1) noble; urgency=medium
8+
9+
* noble build: fix issue with lingering .pybuild/ dir
10+
11+
-- Stephan Kramer <s.kramer@imperial.ac.uk> Sat, 17 Aug 2024 15:18:51 +0100
12+
113
spud (1.2) UNRELEASED; urgency=medium
214

315
* Rewrite Debian/Ubuntu packaging

debian/rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ PYTHON_DIRS=diamond dxdiff python
1313
override_dh_auto_build:
1414
dh_auto_build -- libspud.la
1515
for i in $(PYTHON_DIRS); do PYBUILD_NAME=$$i; dh_auto_build --buildsystem=pybuild --sourcedir=$$i; done
16+
rm -rf .pybuild/ # this should have been removed by pybuild, but doesn't https://bugs-devel.debian.org/cgi-bin/bugreport.cgi?bug=1056291
1617

1718
# instead of a single "make install" into debian/tmp
1819
# only use makefile for install-libspud and install-spudtools
1920
# and use pybuild to install python packages
2021
override_dh_auto_install:
2122
make install-libspud install-spudtools DESTDIR=debian/tmp/
2223
for i in $(PYTHON_DIRS); do PYBUILD_NAME=$$i; dh_auto_install --buildsystem=pybuild --sourcedir=$$i; done
24+
rm -rf .pybuild/ # this should have been removed by pybuild, but doesn't https://bugs-devel.debian.org/cgi-bin/bugreport.cgi?bug=1056291

diamond/diamond/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
if "DIAMOND_CONFIG_PATH" in os.environ:
3131
dirs += reversed(os.environ["DIAMOND_CONFIG_PATH"].split(":"))
3232

33-
config = configparser.SafeConfigParser()
33+
config = configparser.ConfigParser()
3434
config.read([os.path.join(path, "settings") for path in reversed(dirs)]) #reversed to load usr last
3535

3636
try:

diamond/diamond/preprocess.py.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ from . import debug
2222
import sys
2323
import copy
2424

25-
from future.standard_library import install_aliases
26-
install_aliases()
2725
import urllib.request, urllib.error, urllib.parse
2826

2927
def preprocess(schemafile):

diamond/diamond/scherror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def errlist_is_open(self):
195195
return self.listview.get_property("visible")
196196

197197
def get_elem_name(self, line):
198-
xml = re.compile("<([/?!]?\w+)", re.VERBOSE)
198+
xml = re.compile(r"<([/?!]?\w+)", re.VERBOSE)
199199
matches = xml.findall(line)
200200
return matches[0]
201201

python/libspud.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55

66
#define MAXLENGTH 2048
77

8-
#if PY_MAJOR_VERSION >= 3
9-
#define PyInt_Type PyLong_Type
10-
#define PyInt_Check PyLong_Check
11-
#define PyString_Type PyUnicode_Type
12-
#define PyString_AsString PyUnicode_AsUTF8
13-
#define PyString_Check PyUnicode_Check
14-
#define PyString_GET_SIZE PyUnicode_GET_LENGTH
15-
#endif
16-
178
static PyObject *SpudError;
189
static PyObject *SpudTypeError;
1910
static PyObject *SpudKeyError;
@@ -229,15 +220,15 @@ libspud_get_option_type(PyObject *self, PyObject *args)
229220
return (PyObject*) &PyFloat_Type;
230221
}
231222
else if (type == SPUD_INT){
232-
Py_INCREF(&PyInt_Type);
233-
return (PyObject*) &PyInt_Type;
223+
Py_INCREF(&PyLong_Type);
224+
return (PyObject*) &PyLong_Type;
234225
}
235226
else if (type == SPUD_NONE){
236227
Py_RETURN_NONE;
237228
}
238229
else if (type == SPUD_STRING){
239-
Py_INCREF(&PyString_Type);
240-
return (PyObject*) &PyString_Type;
230+
Py_INCREF(&PyUnicode_Type);
231+
return (PyObject*) &PyUnicode_Type;
241232
}
242233

243234
PyErr_SetString(SpudError,"Error: Get option type function failed");
@@ -562,7 +553,7 @@ set_option_aux_list_doubles(PyObject *pylist, const char *key, int key_len, int
562553
static PyObject*
563554
set_option_aux_string(PyObject *pystring, const char *key, int key_len, int type, int rank, int *shape)
564555
{ // this function is for setting option when the second argument is of type string
565-
const char *val = PyString_AsString(pystring);
556+
const char *val = PyUnicode_AsUTF8(pystring);
566557
int outcomeSetOption = spud_set_option(key, key_len, val, type, rank, shape);
567558
return error_checking(outcomeSetOption, "set option aux string");
568559
}
@@ -702,18 +693,16 @@ libspud_set_option(PyObject *self, PyObject *args)
702693
int outcomeAddOption = spud_add_option(key, key_len);
703694
error_checking(outcomeAddOption, "set option");
704695
}
705-
706-
if (PyInt_Check(secondArg)){ //just an int
696+
if (PyLong_Check(secondArg)){ //just an int
707697
type = SPUD_INT;
708698
rank = 0;
709699
shape[0] = -1;
710700
shape[1] = -1;
711-
712701
}
713-
else if (PyString_Check(secondArg)){// a string
702+
else if (PyUnicode_Check(secondArg)){// a Unicode string
714703
type = SPUD_STRING;
715704
rank = 1;
716-
shape[0] = PyString_GET_SIZE(secondArg);
705+
shape[0] = PyUnicode_GET_LENGTH(secondArg);
717706
shape[1] = -1;
718707
}
719708
else if (PyFloat_Check(secondArg)){// a double
@@ -724,7 +713,7 @@ libspud_set_option(PyObject *self, PyObject *args)
724713
}
725714
else if (PyList_Check(secondArg)){
726715
PyObject* listElement = PyList_GetItem(secondArg, 0);
727-
if (PyInt_Check(listElement)){ //list of ints
716+
if (PyLong_Check(listElement)){ //list of ints
728717
type = SPUD_INT;
729718
rank = 1;
730719
shape[0] = 1;
@@ -740,7 +729,7 @@ libspud_set_option(PyObject *self, PyObject *args)
740729
int pylistSize = PyList_GET_SIZE(secondArg);
741730
int pysublistSize = PyList_GET_SIZE(listElement);
742731
PyObject* sublistElement = PyList_GetItem(listElement, 0);
743-
if (PyInt_Check(sublistElement)){ //list of lists of ints
732+
if (PyLong_Check(sublistElement)){ //list of lists of ints
744733
type = SPUD_INT;
745734
}
746735
else if (PyFloat_Check(sublistElement)){//list of lists of doubles
@@ -756,7 +745,7 @@ libspud_set_option(PyObject *self, PyObject *args)
756745
set_option_aux_scalar(secondArg, key, key_len, type, rank, shape);
757746
}
758747
else if (rank == 1){ // list or string
759-
if (PyString_Check(secondArg)){ // pystring
748+
if (PyUnicode_Check(secondArg)){ // pystring
760749
set_option_aux_string(secondArg, key, key_len, type, rank, shape);
761750
}
762751
else if (type == SPUD_INT) { // list of ints

0 commit comments

Comments
 (0)