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

Update Numpy and Cython for Python 3.10 and 3.11 builds #152

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
pyver: cp38-cp38
piparch: manylinux1_x86_64
numpy: numpy==1.17.3
cython: Cython==0.29.2
cython: Cython==0.29.14

- name: linux 3.9 amd64
os: ubuntu-latest
Expand All @@ -101,15 +101,15 @@ jobs:
os: ubuntu-latest
pyver: cp310-cp310
piparch: manylinux2014_x86_64
numpy: numpy==1.22.0
cython: Cython==0.29.23
numpy: numpy==2.0.1
cython: Cython==3.0.10

- name: linux 3.11 amd64
os: ubuntu-latest
pyver: cp311-cp311
piparch: manylinux2014_x86_64
numpy: numpy==1.23.5
cython: Cython==0.29.35
numpy: numpy==2.0.1
cython: Cython==3.0.10

- name: linux 3.12 amd64
os: ubuntu-latest
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
pyver: cp38-cp38
piparch: manylinux1_i686
numpy: numpy==1.19.5
cython: Cython==0.29.2
cython: Cython==0.29.14
pre: linux32
skip_cothread: yes

Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
python: "3.8"
piparch: macosx_11_0_universal2
numpy: numpy==1.24.4
cython: Cython==0.29.2
cython: Cython==0.29.15
skip_cothread: yes

- name: osx 3.9 arm64
Expand Down Expand Up @@ -248,56 +248,64 @@ jobs:
os: windows-2019
python: "3.5"
piparch: win_amd64
profile: latest
numpy: numpy==1.12.1
cython: Cython==0.29.2
skip_cothread: yes

- name: win64 3.6
os: windows-latest
python: "3.6"
piparch: win_amd64
profile: latest
numpy: numpy==1.12.1
cython: Cython==0.29.2
skip_cothread: yes

- name: win64 3.7
os: windows-latest
python: "3.7"
piparch: win_amd64
profile: latest
numpy: numpy==1.16.2
cython: Cython==0.29.2
skip_cothread: yes

- name: win64 3.8
os: windows-latest
python: "3.8"
piparch: win_amd64
profile: latest
numpy: numpy==1.19.5
cython: Cython==0.29.14
skip_cothread: yes

- name: win64 3.9
os: windows-latest
python: "3.9"
piparch: win_amd64
profile: latest
numpy: numpy==1.19.5
cython: Cython==0.29.23
skip_cothread: yes

- name: win64 3.10
os: windows-latest
python: "3.10"
piparch: win_amd64
profile: latest
numpy: numpy==1.21.3
cython: Cython==0.29.23
skip_cothread: yes

- name: win64 3.11
os: windows-latest
python: "3.11"
piparch: win_amd64
profile: latest
numpy: numpy==1.23.2
cython: Cython==3.0.10
skip_cothread: yes

- name: win64 3.12
os: windows-latest
python: "3.12"
piparch: win_amd64
profile: latest
numpy: numpy==1.26.0
cython: Cython==3.0.10
skip_cothread: yes

steps:
Expand Down Expand Up @@ -350,9 +358,9 @@ jobs:
run: |
if [ "${{ matrix.profile }}" ]
then
python -m pip install -r requirements-${{ matrix.profile }}.txt
python -m pip install --only-binary numpy,numpy,Cython -r requirements-${{ matrix.profile }}.txt
else
python -m pip install --only-binary numpy nose2 ply ${{ matrix.numpy }} ${{ matrix.cython }}
python -m pip install --only-binary numpy,numpy,Cython nose2 ply ${{ matrix.numpy }} ${{ matrix.cython }}
fi
if [ "${{ matrix.skip_cothread }}" != "yes" ]
then
Expand Down Expand Up @@ -411,9 +419,9 @@ jobs:
python -m pip install --only-binary numpy $PRE setuptools-dso epicscorelibs pvxslibs
if [ "${{ matrix.profile }}" ]
then
python -m pip install --only-binary numpy -r requirements-${{ matrix.profile }}.txt
python -m pip install --only-binary numpy,numpy,Cython -r requirements-${{ matrix.profile }}.txt
else
python -m pip install --only-binary numpy nose2 ply ${{ matrix.numpy }} ${{ matrix.cython }}
python -m pip install --only-binary numpy,numpy,Cython nose2 ply ${{ matrix.numpy }} ${{ matrix.cython }}
fi
if [ "${{ matrix.skip_cothread }}" != "yes" ]
then
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ requires = [
"setuptools_dso>=2.7a1,<=2.10; python_version<='3.11'",
"setuptools_dso>=2.11a2; python_version>='3.12'",
"wheel",
"numpy",
"numpy>=2.0.1; python_version>='3.10'",
"numpy>=1.7",
"Cython>=0.20",
"epicscorelibs==7.0.7.99.0.2; python_version<='3.11'",
"epicscorelibs>=7.0.7.99.1.1a2; python_version>='3.12'",
Expand Down
28 changes: 18 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def get_numpy_include_dirs():
package_version = str(lcl['version'])
del lcl

cxxflags = ['-std=c++11']
cxxflags = []
if get_config_var('CMPLR_CLASS') in ('gcc', 'clang'):
cxxflags += ['-std=c++11']
ldflags = []
import sys
import platform
Expand Down Expand Up @@ -93,6 +95,20 @@ def get_numpy_include_dirs():
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as F:
long_description = F.read()

install_requires = [
epicscorelibs.version.abi_requires(),
pvxslibs.version.abi_requires(),
'nose2>=0.8.0',
'ply', # for asLib
]

if hasattr(numpy.lib, "NumpyVersion") and numpy.lib.NumpyVersion(numpy.__version__) >= '2.0.0b1':
install_requires += ['numpy >= 1.7', 'numpy < 3']
else:
# assume ABI forward compatibility as indicated by
# https://github.com/numpy/numpy/blob/master/numpy/core/setup_common.py#L28
install_requires += ['numpy >=%s'%numpy.version.short_version, 'numpy < 2']

setup(
name='p4p',
version=package_version,
Expand Down Expand Up @@ -131,15 +147,7 @@ def get_numpy_include_dirs():
package_dir={'':'src'},
package_data={'p4p': ['*.conf', '*.service']},
ext_modules = exts,
install_requires = [
epicscorelibs.version.abi_requires(),
pvxslibs.version.abi_requires(),
# assume ABI forward compatibility as indicated by
# https://github.com/numpy/numpy/blob/master/numpy/core/setup_common.py#L28
'numpy >=%s'%numpy.version.short_version,
'nose2>=0.8.0',
'ply', # for asLib
],
install_requires = install_requires,
extras_require={
'qt': ['qtpy'],
},
Expand Down
9 changes: 5 additions & 4 deletions src/p4p.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
# endif
#endif

// avoid numpy deprecation warnings when building with cython >= 3.0
#if CYTHON_HEX_VERSION>=0x03000000
# define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif
// this file must be included from all code using numpy APIs
// include cython generated code.
// minimum supported numpy version...
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#define NPY_TARGET_VERSION NPY_1_7_API_VERSION

namespace p4p {

Expand Down
2 changes: 1 addition & 1 deletion src/p4p/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def __ge__(self, o):
def __gt__(self, o):
return self._cmp(o)>0

version = Version('4.2.0a1')
version = Version('4.2.0a2')
10 changes: 3 additions & 7 deletions src/pvxs_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
#include <p4p.h>
#include <_p4p.h>

// import handled by cython
#define NO_IMPORT_ARRAY
//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/ndarrayobject.h>

#ifndef NPY_ARRAY_FORCECAST
# define NPY_ARRAY_FORCECAST (0)
#endif

namespace p4p {

int except_map()
Expand Down Expand Up @@ -159,7 +155,7 @@ PyObject* asPy(const Value& v, bool unpackstruct, bool unpackrecurse, PyObject*

PyRef pyarr(PyArray_New(&PyArray_Type, 1, &shape, ntype, nullptr,
const_cast<void*>(varr.data()), // should not actually be modifiable
esize, NPY_CARRAY_RO, nullptr));
esize, NPY_ARRAY_CARRAY_RO, nullptr));

#ifdef PyArray_SetBaseObject
PyArray_SetBaseObject((PyArrayObject*)pyarr.obj, holder.release());
Expand Down Expand Up @@ -530,7 +526,7 @@ void storePy(Value& v, PyObject* py, bool forceCast)
}

PyRef arr(PyArray_FromAny(py, PyArray_DescrFromType(ntype), 0, 0,
NPY_CARRAY_RO|NPY_ARRAY_FORCECAST, nullptr));
NPY_ARRAY_CARRAY_RO|NPY_ARRAY_FORCECAST, nullptr));

if(PyArray_NDIM((PyArrayObject*)arr.obj)!=1)
throw std::logic_error("Only 1-d array can be assigned");
Expand Down
Loading