Skip to content

Commit

Permalink
Conditional usage of numpy.distutils
Browse files Browse the repository at this point in the history
support py3.12.
numpy really really not conditional
  • Loading branch information
mdavidsaver committed Jan 20, 2024
1 parent 936b12a commit a03400e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
# used by .ci/build-deps.sh for Make builds
BRBASE: ${{ matrix.base }}
BRPVXS: ${{ matrix.pvxs }}
# cf. https://github.com/numpy/numpy/issues/22623
SETUPTOOLS_USE_DISTUTILS: stdlib
strategy:
fail-fast: false
matrix:
Expand Down
6 changes: 0 additions & 6 deletions configure/CONFIG_PY
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ PROD_DEPLIB_DIRS += $(PY_LIBDIRS)

INCLUDES += $(PY_INCDIRS:%=-I%)

ifeq ($(HAVE_NUMPY),YES)
TARGET_CPPFLAGS += -DHAVE_NUMPY
else
$(error numpy required)
endif

#LIB_SYS_LIBS += python$(PY_LD_VER)
#PROD_SYS_LIBS += python$(PY_LD_VER)

Expand Down
16 changes: 9 additions & 7 deletions makehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Emits something like the following
PY_OK := YES # indicates success of this script
HAVE_NUMPY := YES/NO
PY_VER := 2.6
PY_INCDIRS := /path ...
PY_LIBDIRS := /path ...
Expand All @@ -26,18 +25,22 @@
pass
out = open(sys.argv[1], 'w')

from distutils.sysconfig import get_config_var, get_python_inc
try:
from sysconfig import get_config_var, get_python_inc
except ImportError:
from distutils.sysconfig import get_config_var, get_python_inc

incdirs = [get_python_inc()]
libdir = get_config_var('LIBDIR') or ''

have_np='NO'
try:
from numpy.distutils.misc_util import get_numpy_include_dirs
incdirs = get_numpy_include_dirs()+incdirs
have_np='YES'
except ImportError:
pass
def get_numpy_include_dirs():
from numpy import get_include
return [get_include()]

incdirs = get_numpy_include_dirs()+incdirs

print('TARGET_CFLAGS +=',get_config_var('BASECFLAGS'), file=out)
print('TARGET_CXXFLAGS +=',get_config_var('BASECFLAGS'), file=out)
Expand All @@ -51,7 +54,6 @@
print('PY_LD_VER :=',ldver, file=out)
print('PY_INCDIRS :=',' '.join(incdirs), file=out)
print('PY_LIBDIRS :=',libdir, file=out)
print('HAVE_NUMPY :=',have_np, file=out)

try:
import asyncio
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from setuptools_dso import Extension, setup, cythonize

import numpy
from numpy.distutils.misc_util import get_numpy_include_dirs
try:
from numpy.distutils.misc_util import get_numpy_include_dirs
except ImportError:
def get_numpy_include_dirs():
return [numpy.get_include()]

import epicscorelibs.path
import epicscorelibs.version
Expand Down

0 comments on commit a03400e

Please sign in to comment.