Is there an easy way to build a PyPi package that uses deprecated Numpy API in C?

46 views Asked by At

I'm trying to build K-Means 2, and have been trying to run the below setup.py file using python setup.py install, pip install kmc2, and pip install . from the source package. I have Numpy version 1.2X (higher than 1.7), but I am not sure how to include the #define X statements that others online as well as the warning have suggested when compiling the package setup C files.

"Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
import numpy as np
from setuptools import setup, Extension

module1 = Extension('kmc2', sources=['kmc2.c'], extra_compile_args=['-O3'])
setup(
    install_requires=["numpy", "scipy", "scikit-learn", "nose"],
    ext_modules=[module1],
    include_dirs=[".",np.get_include() ])

Help would be greatly appreciated. Thanks!

I have tried changing the sources to kmc2.pyx instead. Furthermore, I tried adding the macros as an option to the Extension() object using define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")], but this did not work either.

Trying to install Numpy 1.7 using pip also results in the same legacy-install-error and can't be built.

I am thinking the solution may come from editing the Numpy internal setup.py build file.

0

There are 0 answers