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

numpy.distutils is deprecated. #5607

Closed
matusvalo opened this issue Aug 9, 2023 · 3 comments · Fixed by #5620
Closed

numpy.distutils is deprecated. #5607

matusvalo opened this issue Aug 9, 2023 · 3 comments · Fixed by #5620

Comments

@matusvalo
Copy link
Contributor

matusvalo commented Aug 9, 2023

Describe your issue

When running test suite, I have discovered following warning:

[-1] compiling (c/cy2) and running numpy_cimport ...
=== C/C++ compiler error output: ===
/Users/ness-skmac3/dev/cython/runtests.py:250: DeprecationWarning:

  `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
  of the deprecation of `distutils` itself. It will be removed for
  Python >= 3.12. For older Python versions it will remain present.
  It is recommended to use `setuptools < 60.0` for those Python versions.
  For more details, see:
    https://numpy.org/devdocs/reference/distutils_status_migration.html


  from numpy.distutils.misc_util import get_info
====================================

Moreover, numpy.distutils is also used here:

from numpy.distutils.misc_util import get_numpy_include_dirs

I suppose it should be fix before python 3.12. Ref. numpy/numpy#18588

@matusvalo
Copy link
Contributor Author

@mattip is there any preferred way how to replace mentioned functions? I was not able to figure out from the documentation (but I did not go deep to be honest).

@da-woods
Copy link
Contributor

da-woods commented Aug 9, 2023

Does numpy.get_include() work for the directories? (I haven't looked to see if there's anything else we use)

@mattip
Copy link
Contributor

mattip commented Aug 9, 2023

I only see those two

$ git grep "numpy.distutils"
Demos/setup.py:    from numpy.distutils.misc_util import get_numpy_include_dirs
runtests.py:    from numpy.distutils.misc_util import get_info

The first has been moved, as you said, to numpy.get_include()
The second is a little more involved. We prefer people move away from setup.py to meson. There is still an example setup.py in the 1.25 docs. The recommended pattern is to use

defs = [('NPY_NO_DEPRECATED_API', 0)]
inc_path = np.get_include()
# Add paths for npyrandom and npymath libraries:
lib_path = [
    abspath(join(np.get_include(), '..', '..', 'random', 'lib')),
    abspath(join(np.get_include(), '..', 'lib'))
]
ext = Extension("extending_distributions",
                          sources=[join('.', 'extending_distributions.pyx')],
                          include_dirs=[inc_path],
                          library_dirs=lib_path,
                          libraries=['npyrandom', 'npymath'],
                          define_macros=defs,
                          )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants