diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 481a822..a0648f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 767d25b..77bd054 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'", diff --git a/setup.py b/setup.py index 57af131..a348dba 100755 --- a/setup.py +++ b/setup.py @@ -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 @@ -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, @@ -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'], }, diff --git a/src/p4p.h b/src/p4p.h index 6504706..285a499 100644 --- a/src/p4p.h +++ b/src/p4p.h @@ -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 { diff --git a/src/p4p/version.py b/src/p4p/version.py index 23c763b..a24f069 100644 --- a/src/p4p/version.py +++ b/src/p4p/version.py @@ -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') diff --git a/src/pvxs_value.cpp b/src/pvxs_value.cpp index 4ab07a8..0052cad 100644 --- a/src/pvxs_value.cpp +++ b/src/pvxs_value.cpp @@ -4,14 +4,10 @@ #include #include <_p4p.h> +// import handled by cython #define NO_IMPORT_ARRAY -//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include -#ifndef NPY_ARRAY_FORCECAST -# define NPY_ARRAY_FORCECAST (0) -#endif - namespace p4p { int except_map() @@ -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(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()); @@ -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");