question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Astropy's lazy loading mechanism doesn't survive deprecation warnings

See original GitHub issue

Description

In testing a project downstream astropy, I configure pytest to treat warnings as errors (so as to detect and handle deprecation warnings as soon as possible). CI started failing today with dev versions of astropy and numpy, and it seems that the warning that’s being changed into an error can’t be easily ignored with pytest because astropy’s lazy loading mechanism escalates it into an ImportError

For reference, the breaking commit upstream was https://github.com/numpy/numpy/commit/0ae08d026eaf8a975156c9149e318812bb9586bb

Steps to Reproduce

this can be reproduced against the tip of astropy (or the latest release) with

python -m pip install git+https://github.com/numpy/numpy.git
python -Werror -c "import astropy.convolution" 

Actual behavior

Traceback
Traceback (most recent call last):
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/astropy/convolution/convolve.py", line 26, in <module>
    _convolve = load_library("_convolve", LIBRARY_PATH)
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/numpy/ctypeslib.py", line 137, in load_library
    from numpy.distutils.misc_util import get_shared_lib_extension
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/numpy/distutils/__init__.py", line 26, in <module>
    from . import ccompiler
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/numpy/distutils/ccompiler.py", line 8, in <module>
    from distutils import ccompiler
  File "/Users/robcleme/.pyenv/versions/3.10.2/lib/python3.10/distutils/__init__.py", line 19, in <module>
    warnings.warn(_DEPRECATION_MESSAGE,
DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/astropy/convolution/__init__.py", line 8, in <module>
    from .convolve import convolve, convolve_fft, interpolate_replace_nans, convolve_models, convolve_models_fft  # noqa
  File "/Users/robcleme/.pyenv/versions/amical-dev/lib/python3.10/site-packages/astropy/convolution/convolve.py", line 28, in <module>
    raise ImportError("Convolution C extension is missing. Try re-building astropy.")
ImportError: Convolution C extension is missing. Try re-building astropy.

Expected behavior

I’d expect the deprecation warning to surface by itself instead of being escalated. Long term, this deprecation warning needs to be handled, but it’s probably a difficult process that’ll take time. On the other hand, refactoring astropy’s lazy loading mechanism doesn’t seem like a much easier task. I have no idea if there’s any viable short-term strategy to handle this situation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
neutrinoceroscommented, Feb 17, 2022

sure

0reactions
saimncommented, Feb 17, 2022

Could you make a PR if you’re already working on a patch ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy-loaded modules warnings after updating Angular from 8 ...
In my case, for some reason, the file name in the import statements were capatilized. For instance, let's say I had the following...
Read more >
Aladin FAQ
Why Aladin does not load my partial HEALPix map ? 5.12. Is Aladin supporting HEALPix cube maps ? 5.13. I've heard that Aladin...
Read more >
PyFITS Documentation - Read the Docs
PyFITS requires Python version 2.6 or newer. Support for Python 3.0 through 3.2 is deprecated, but Python 3.3 and above are fully supported....
Read more >
https://packages.cloud.google.com/apt/dists/mendel...
External libraries can also be dynamically loaded at run-time, ... the expirer. it is the script that handles time-to-live support, when it is...
Read more >
Charm++ Documentation - Read the Docs
Charm++ does not allow global variables, except readonly variables (see 2.2.2). ... (deprecated) Centralized load balancers using CentralLB.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found