astropy: ImportError in Python 3.6 importlib

I see this in Python 3.6 test suites. Is this safe to ignore or should be fixed somehow? Should we move this to astropy-helpers? I am not sure where this is coming from.

home/travis/miniconda/envs/test/lib/python3.6/importlib/_bootstrap.py:205:
ImportWarning: can't resolve package from __spec__ or __package__,
falling back on __name__ and __path__

  return f(*args, **kwds)

p.s. Instead of decreasing the number of issues, I am increasing it. Sorry, @bsipocz !

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 27 (25 by maintainers)

Most upvoted comments

I think this is still an issue until it is fixed upstream, so keeping this open for now.

Sorry I thought it was pllim above 😁 Yes I guess this could happen, but the cython releases is old enough now that we should be safe.

Yes, you can certainly ignore this warning. Ultimately this will go away seamlessly once addressed upstream (and we just keep it open in the meantime to avoid duplicate reports opened for it).

I also see these warnings, so did a quick debugging:

❯ PYTHONWARNINGS='error::ImportWarning' python setup.py test
running test
running build
running build_py
running pre_hook from astropy._erfa.setup_package for build_py command
running pre_hook from astropy.modeling.setup_package for build_py command
running build_ext
running pre_hook from astropy._erfa.setup_package for build_ext command
running pre_hook from astropy.modeling.setup_package for build_ext command
Traceback (most recent call last):
  File "setup.py", line 105, in <module>
    **package_info
  File "/home/simon/miniconda3/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/simon/dev/astropy/astropy/tests/command.py", line 201, in run
    self._build_temp_install()
  File "/home/simon/dev/astropy/astropy/tests/command.py", line 241, in _build_temp_install
    self.run_command('build')
  File "/home/simon/miniconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/simon/miniconda3/lib/python3.6/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/home/simon/miniconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/simon/dev/astropy/astropy_helpers/astropy_helpers/setup_helpers.py", line 252, in run
    orig_run(self)
  File "/home/simon/dev/astropy/astropy_helpers/astropy_helpers/commands/build_ext.py", line 301, in run
    super(build_ext, self).run()
  File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/home/simon/miniconda3/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 192, in build_extensions
    ext.sources = self.cython_sources(ext.sources, ext)
  File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 203, in cython_sources
    from Cython.Compiler.Main \
  File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 28, in <module>
    from .Scanning import PyrexScanner, FileSourceDescriptor
  File "Cython/Compiler/Scanning.py", line 1, in init Cython.Compiler.Scanning (/home/ilan/minonda/conda-bld/cython_1482480352936/work/Cython-0.25.2/Cython/Compiler/Scanning.c:15387)
  File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Plex/__init__.py", line 39, in <module>
    from .Scanners import Scanner
  File "Cython/Plex/Scanners.py", line 16, in init Cython.Plex.Scanners (/home/ilan/minonda/conda-bld/cython_1482480352936/work/Cython-0.25.2/Cython/Plex/Scanners.c:7116)
ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

It is a Cython issue (https://github.com/cython/cython/issues/1753 , https://github.com/cython/cython/issues/1720) related to a new warning in Python 3.6 (http://bugs.python.org/issue25791). https://github.com/cython/cython/issues/1720 gives some workaround, i will try.

IMO we should remove it from the ignore list, or not close but update the description here if the warning is still raised in newer versions

There was a fix in Cython 0.27 but disabled since (“Reopening since the implementation in 0.27.0 is not complete and was disabled in 0.27.1” : https://github.com/cython/cython/issues/1715).

Reading through their related issues, the tone seemed to be a bit arrogant and suggested that this won’t go away any time soon.

Maybe we can do a blind import before test collection, just as we do for a few upstream modules to filter out their deprecation warnings? But even if we do, I agree that it can be a bit risky, and anyway, low priority.

So, since this is caused by bug upstream, should we close this issue here?