Skip to content

DOC: ufunc instructions use deprecated distutils #22027

@oscarbenjamin

Description

@oscarbenjamin

Issue with current documentation:

While working on reducing warnings from SymPy I found myself looking at this page of the NumPy docs:
https://numpy.org/doc/stable/user/c-info.ufunc-tutorial.html

The code examples from there seem to be used more or less directly in SymPy:
https://github.com/sympy/sympy/blob/39de9a2698ad4bb90681c0fdb70b30a78233145f/sympy/utilities/autowrap.py#L702-L801

I found warnings from running this because of the usage of distutils and numpy.distutils. Since both types of distutils are deprecated I guess that the appropriate update would be to use setuptools.

Also compiling the examples from the docs page gives a warning:

/usr/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^

Idea or request for content:

For me on Ubuntu it seems to work fine to just use this setup.py with setuptools:

from setuptools import setup, Extension

npufunc = Extension('npufunc', sources=['single_type_logit.c'])

setup(name = 'spam',
    version='1.0',
    description='This is my spam package',
    ext_modules = [npufunc])

That would seem the most straight-forward update to the docs.

I don't know though if setuptools can be expected to work like this on all platforms though and I'm also not really sure why the docs pages suggests using numpy.distutils at all so it's not clear to me that setuptools can replace it here.

Another possibility would be to add instructions showing how to do the same using other build tools rather than setuptools.

The other warning can be addressed by adding the line

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions