Skip to content

[MSVC] Annoy failed to run test on Windows due to "ModuleNotFoundError: No module named 'imp'" with python 3.12.4 #666

@Zhaojun-Liu

Description

@Zhaojun-Liu

Hi: Recently, we updated the python to 3.12.4 and build Annoy, it failed to run test due to ModuleNotFoundError: No module named 'imp', can you take a look? Thanks.

Repro steps:

  1. git clone https://github.com/spotify/annoy C:\gitP\spotify\annoy
  2. git -C "F:\gitP\spotify\annoy" reset --hard 2be37c9
  3. cd /d C:\gitP\spotify\annoy
  4. python.exe -m pip install numpy h5py pytest setuptools
  5. python setup.py build
  6. python setup.py nosetests

Actual result:

C:\Python312\Lib\site-packages\setuptools\__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
c:\gitp\spotify\annoy\.eggs\nose-1.3.7-py3.12.egg\nose\config.py:142: SyntaxWarning: invalid escape sequence '\.'
  """nose configuration.
Traceback (most recent call last):
  File "C:\gitP\spotify\annoy\setup.py", line 80, in <module>
    setup(name='annoy',
  File "C:\Python312\Lib\site-packages\setuptools\__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\setuptools\_distutils\core.py", line 171, in setup
    ok = dist.parse_command_line()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 478, in parse_command_line
    args = self._parse_command_opts(parser, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\setuptools\dist.py", line 858, in _parse_command_opts
    nargs = _Distribution._parse_command_opts(self, parser, args)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\setuptools\_distutils\dist.py", line 537, in _parse_command_opts
    cmd_class = self.get_command_class(command)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\setuptools\dist.py", line 703, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
                                        ^^^^^^^^^
  File "C:\Python312\Lib\importlib\metadata\__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "c:\gitp\spotify\annoy\.eggs\nose-1.3.7-py3.12.egg\nose\__init__.py", line 1, in <module>
    from nose.core import collector, main, run, run_exit, runmodule
  File "c:\gitp\spotify\annoy\.eggs\nose-1.3.7-py3.12.egg\nose\core.py", line 12, in <module>
    from nose.loader import defaultTestLoader
  File "c:\gitp\spotify\annoy\.eggs\nose-1.3.7-py3.12.egg\nose\loader.py", line 21, in <module>
    from nose.importer import Importer, add_path, remove_path
  File "c:\gitp\spotify\annoy\.eggs\nose-1.3.7-py3.12.egg\nose\importer.py", line 12, in <module>
    from imp import find_module, load_module, acquire_lock, release_lock
ModuleNotFoundError: No module named 'imp'

Expected: run test ok.

Note: I found that imp is removed in python 3.12. I don't know how to update the test part in Annoy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions