Skip to content

Commit 1e933f3

Browse files
authored
Merge pull request #43 from epics-modules/fix-pr-40
Combine all python/numpy support PRs, set minimum python version to 3.6
2 parents 7f9c592 + d4d1829 commit 1e933f3

File tree

14 files changed

+139
-31
lines changed

14 files changed

+139
-31
lines changed

.github/workflows/ci-scripts-build.yml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ env:
1111

1212
jobs:
1313
build-base:
14-
name: ${{ matrix.base }}/${{ matrix.os }}/${{ matrix.python }}/${{ matrix.extra }}
14+
name: ${{ matrix.base }}/${{ matrix.os }}/${{ matrix.profile }}/${{ matrix.python }}/${{ matrix.extra }}
1515
runs-on: ${{ matrix.os }}
16+
container: ${{ matrix.container }}
1617
# Set environment variables from matrix parameters
1718
env:
1819
CMP: ${{ matrix.cmp }}
@@ -33,6 +34,49 @@ jobs:
3334
base: "7.0"
3435
python: "3.7"
3536
profile: deb10
37+
container: "python:3.7"
38+
test: yes
39+
40+
- os: ubuntu-latest
41+
cmp: gcc
42+
configuration: default
43+
base: "7.0"
44+
python: "3.9"
45+
profile: deb11
46+
test: yes
47+
48+
- os: ubuntu-latest
49+
cmp: gcc
50+
configuration: default
51+
base: "7.0"
52+
python: "3.11"
53+
profile: deb12
54+
test: yes
55+
56+
- os: ubuntu-latest
57+
cmp: gcc
58+
configuration: default
59+
base: "7.0"
60+
python: "3.13"
61+
profile: deb13
62+
test: yes
63+
64+
- os: ubuntu-latest
65+
cmp: gcc
66+
configuration: default
67+
base: "7.0"
68+
python: "3.6"
69+
container: "python:3.6"
70+
profile: latest
71+
test: yes
72+
73+
- os: ubuntu-latest
74+
cmp: gcc
75+
configuration: default
76+
base: "7.0"
77+
python: "3.7"
78+
container: "python:3.7"
79+
profile: latest
3680
test: yes
3781

3882
- os: ubuntu-latest
@@ -59,6 +103,30 @@ jobs:
59103
profile: latest
60104
test: yes
61105

106+
- os: ubuntu-latest
107+
cmp: gcc
108+
configuration: default
109+
base: "7.0"
110+
python: "3.11"
111+
profile: latest
112+
test: yes
113+
114+
- os: ubuntu-latest
115+
cmp: gcc
116+
configuration: default
117+
base: "7.0"
118+
python: "3.12"
119+
profile: latest
120+
test: yes
121+
122+
- os: ubuntu-latest
123+
cmp: gcc
124+
configuration: default
125+
base: "7.0"
126+
python: "3.13"
127+
profile: latest
128+
test: yes
129+
62130
- os: macos-latest
63131
cmp: gcc
64132
configuration: default
@@ -72,20 +140,31 @@ jobs:
72140
configuration: default
73141
base: "3.15"
74142
python: "3.7"
143+
container: "python:3.7"
75144
profile: deb10
76145
test: yes
77146

147+
- os: ubuntu-latest
148+
cmp: gcc
149+
configuration: default
150+
base: "3.15"
151+
python: "3.13"
152+
profile: deb13
153+
test: yes
154+
78155
- os: ubuntu-latest
79156
cmp: gcc
80157
configuration: default
81158
base: "3.14"
82159
python: "3.7"
160+
container: "python:3.7"
83161
profile: deb10
84162
steps:
85163
- uses: actions/checkout@v3
86164
with:
87165
submodules: true
88166
- name: Set up Python ${{ matrix.python }}
167+
if: ${{ !matrix.container }}
89168
uses: actions/setup-python@v4
90169
with:
91170
python-version: ${{ matrix.python }}

devsupApp/src/dbapi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ static struct PyMethodDef dbapimethod[] = {
289289

290290
#if PY_MAJOR_VERSION >= 3
291291
static struct PyModuleDef dbapimodule = {
292-
PyModuleDef_HEAD_INIT,
292+
PyModuleDef_HEAD_INIT,
293293
"devsup._dbapi",
294294
NULL,
295295
-1,
296-
&dbapimethod
296+
dbapimethod
297297
};
298298
#endif
299299

devsupApp/src/dbfield.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ static const int dbf2np_map[DBF_MENU+1] = {
4040
NPY_INT16, // DBF_MENU
4141
};
4242
static PyArray_Descr* dbf2np[DBF_MENU+1];
43+
#if NPY_ABI_VERSION < 0x02000000
44+
#define PyDataType_ELSIZE(descr) ((descr)->elsize)
45+
#define PyDataType_SET_ELSIZE(descr, size) (descr)->elsize = size
46+
#endif
4347
#endif
4448

4549
typedef struct {
@@ -98,10 +102,10 @@ static PyObject* build_array(PyObject* obj, void *data, unsigned short ftype, un
98102

99103
desc = dbf2np[ftype];
100104
if(ftype==DBF_STRING) {
101-
desc->elsize = MAX_STRING_SIZE;
105+
PyDataType_SET_ELSIZE(desc, MAX_STRING_SIZE);
102106
}
103107

104-
Py_XINCREF(desc);
108+
Py_XINCREF(desc); // take a reference for PyArray_NewFromDescr() to steal
105109
return PyArray_NewFromDescr(&PyArray_Type, desc, ndims, dims, NULL, data, flags, (PyObject*)obj);
106110
#else
107111
PyErr_SetNone(PyExc_NotImplementedError);
@@ -115,22 +119,25 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
115119
void *rawfield = paddr->pfield;
116120
rset *prset;
117121
PyObject *aval;
122+
PyArrayObject *array = (PyArrayObject *)arr;
118123
unsigned elemsize = dbValueSize(paddr->field_type);
119124
unsigned long maxlen = paddr->no_elements, insize;
120125
PyArray_Descr *desc = dbf2np[paddr->field_type];
121126

122127
if(paddr->field_type==DBF_STRING &&
123-
(PyArray_NDIM(arr)!=2 || PyArray_DIM(arr,0)>maxlen || PyArray_DIM(arr,1)!=MAX_STRING_SIZE))
128+
(PyArray_NDIM(array) != 2 ||
129+
PyArray_DIM(array, 0) > (npy_intp) maxlen ||
130+
PyArray_DIM(array, 1) != MAX_STRING_SIZE))
124131
{
125132
PyErr_Format(PyExc_ValueError, "String array has incorrect shape or is too large");
126133
return 1;
127134

128-
} else if(PyArray_NDIM(arr)!=1 || PyArray_DIM(arr,0)>maxlen) {
135+
} else if(PyArray_NDIM(array) != 1 || PyArray_DIM(array, 0) > (npy_intp) maxlen) {
129136
PyErr_Format(PyExc_ValueError, "Array has incorrect shape or is too large");
130137
return 1;
131138
}
132139

133-
insize = PyArray_DIM(arr, 0);
140+
insize = PyArray_DIM(array, 0);
134141

135142
if(paddr->special==SPC_DBADDR &&
136143
(prset=dbGetRset(paddr)) &&
@@ -152,16 +159,17 @@ static int assign_array(DBADDR *paddr, PyObject *arr)
152159
}
153160

154161
Py_XINCREF(desc);
155-
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_CARRAY, arr)))
162+
if(!(aval = PyArray_FromAny(arr, desc, 1, 2, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE, arr)))
156163
return 1;
157164

158-
if(elemsize!=PyArray_ITEMSIZE(aval)) {
165+
if(elemsize!=PyArray_ITEMSIZE((PyArrayObject *)aval)) {
159166
PyErr_Format(PyExc_AssertionError, "item size mismatch %u %u",
160-
elemsize, (unsigned)PyArray_ITEMSIZE(aval) );
167+
elemsize, (unsigned)PyArray_ITEMSIZE((PyArrayObject *)aval));
168+
Py_DECREF(aval);
161169
return 1;
162170
}
163171

164-
memcpy(rawfield, PyArray_GETPTR1(aval, 0), insize*elemsize);
172+
memcpy(rawfield, PyArray_GETPTR1((PyArrayObject *)aval, 0), insize*elemsize);
165173

166174
Py_DECREF(aval);
167175

@@ -207,7 +215,7 @@ static PyObject* pyField_getval(pyField *self)
207215

208216
if(self->addr.no_elements>1) {
209217
return build_array((PyObject*)self, rawfield, self->addr.field_type,
210-
noe, NPY_CARRAY_RO);
218+
noe, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED);
211219
}
212220
}
213221

@@ -362,7 +370,7 @@ static PyObject *pyField_getarray(pyField *self)
362370
} else
363371
data = self->addr.pfield;
364372

365-
return build_array((PyObject*)self, data, self->addr.field_type, self->addr.no_elements, NPY_CARRAY);
373+
return build_array((PyObject*)self, data, self->addr.field_type, self->addr.no_elements, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_ALIGNED | NPY_ARRAY_WRITEABLE);
366374
}
367375

368376
static PyObject *pyField_getlen(pyField *self)

documentation/environment.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Runtime Environment
44
The pyDevSup module initializes the interpreter during the registration
55
phase of IOC startup with the *pySetupReg* registrar function. ::
66

7-
#!../../bin/linux-x86_64/softIocPy2.7
7+
#!../../bin/linux-x86_64/softIocPy3.6
88
# Interpreter not started
99
dbLoadDatabase("../../dbd/softIocPy.dbd",0,0)
1010
softIocPy_registerRecordDeviceDriver(pdbbase)
@@ -51,7 +51,7 @@ file. ::
5151

5252
The default or preferred Python version can be specificed in *configure/CONFIG_SITE* ::
5353

54-
PY_VER ?= 2.7
54+
PY_VER ?= 3.6
5555

5656
The following should be added to individual EPICS Makefiles. ::
5757

@@ -64,8 +64,8 @@ The following should be added to individual EPICS Makefiles. ::
6464

6565
This will add or amend several make variables. The ``USR_*FLAGS`` variables
6666
may be extended with appropriate flags for building python modules. The ``PY_VER``
67-
variable is defined with the Python version number found in install directories (eg "2.7").
68-
The ``PY_LD_VER`` variable is defined with the python library version number (eg "3.2mu"),
67+
variable is defined with the Python version number found in install directories (eg "3.6").
68+
The ``PY_LD_VER`` variable is defined with the python library version number (eg "3.6mu"),
6969
which may be the same as ``PY_VER``.
7070

7171
Include pyDevSup in your IOC
@@ -113,11 +113,11 @@ Installing for several Python versions
113113
The recipe for building and installing the pyDevSup module
114114
for several python version side by side is ::
115115

116-
make PY_VER=2.6
116+
make PY_VER=3.6
117117
make clean
118-
make PY_VER=2.7
118+
make PY_VER=3.10
119119
make clean
120-
make PY_VER=3.2
120+
make PY_VER=3.14
121121
make clean
122122

123123
The ``PYTHON`` make variable can be specified if the interpreter executable

documentation/gettingstarted.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The :py:meth:`process <DeviceSupport.process>` method increments the *VAL* field
2424

2525
Start this IOC with. ::
2626

27-
$ ./bin/linux-x86_64/softIocPy2.7 -d cntrec.db
27+
$ ./bin/linux-x86_64/softIocPy3.6 -d cntrec.db
2828
Starting iocInit
2929
...
3030
iocRun: All initialization complete

documentation/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pydevsup documentation
88

99
*pyDevSup* is a means of writing EPICS device support code in Python.
1010

11-
It currently supports EPICS >=3.14.12 and python versions: 2.7, and >=3.2.
11+
It currently supports EPICS >=3.14.12 and python versions >=3.6
1212
The numpy package is also required.
1313

1414
The source can be found at http://github.com/mdavidsaver/pyDevSup

iocBoot/iocapplmon/st.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!../../bin/linux-x86/softIocPy2.7
1+
#!../../bin/linux-x86/softIocPy3.6
22

33
< envPaths
44

iocBoot/iocarchivemon/st.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!../../bin/linux-x86/softIocPy2.7
1+
#!../../bin/linux-x86/softIocPy3.6
22

33
< envPaths
44

iocBoot/iocarchivemon/st.cmd.main

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!../../bin/linux-x86_64/softIocPy2.7
1+
#!../../bin/linux-x86_64/softIocPy3.6
22

33
< envPaths
44

0 commit comments

Comments
 (0)