DiamondLightSource / tickit

Event-based hardware simulation framework
Apache License 2.0
7 stars 0 forks source link

Docs build suddenly failing due to circular imports #181

Open abbiemery opened 1 year ago

abbiemery commented 1 year ago

With the latest update of setuptools there is now a circular dependency issue with setuptools and setuptool.dso when attempting to import the epics adapter for the docs sphinx automodule generated API reference. It looks like this originates in PythonSoftIOC.

Package versions:

setuptools==68.1.2
setuptools-dso==2.9

The error is below.

WARNING: autodoc: failed to import module 'io' from module 'tickit.adapters'; the following exception was raised:
Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
    return importlib.import_module(modname)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/tickit/src/tickit/adapters/io/__init__.py", line 1, in <module>
    from .epics_io import EpicsIo
  File "/workspace/tickit/src/tickit/adapters/io/epics_io.py", line 6, in <module>
    from softioc import builder, softioc
  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>
    from setuptools_dso.runtime import find_dso
  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>
    from setuptools import setup as _setup
  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 17, in <module>
    from setuptools.dist import Distribution
  File "/venv/lib/python3.10/site-packages/setuptools/dist.py", line 37, in <module>
    from setuptools.config import setupcfg, pyprojecttoml
  File "/venv/lib/python3.10/site-packages/setuptools/config/__init__.py", line 8, in <module>
    from . import setupcfg
  File "/venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py", line 38, in <module>
    from . import expand
  File "/venv/lib/python3.10/site-packages/setuptools/config/expand.py", line 53, in <module>
    from setuptools.dist import Distribution  # noqa
ImportError: cannot import name 'Distribution' from partially initialized module 'setuptools.dist' (most likely due to a circular import) (/venv/lib/python3.10/site-packages/setuptools/dist.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 88, in import_object
    module = import_module(modname, warningiserror=warningiserror)
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 68, in import_module
    raise ImportError(exc, traceback.format_exc()) from exc
ImportError: (ImportError("cannot import name 'Distribution' from partially initialized module 'setuptools.dist' (most likely due to a circular import) (/venv/lib/python3.10/site-packages/setuptools/dist.py)"), 'Traceback (most recent call last):\n  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module\n    return importlib.import_module(modname)\n  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\n  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load\n  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked\n  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked\n  File "<frozen importlib._bootstrap_external>", line 883, in exec_module\n  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\n  File "/workspace/tickit/src/tickit/adapters/io/__init__.py", line 1, in <module>\n    from .epics_io import EpicsIo\n  File "/workspace/tickit/src/tickit/adapters/io/epics_io.py", line 6, in <module>\n    from softioc import builder, softioc\n  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>\n    from setuptools_dso.runtime import find_dso\n  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>\n    from setuptools import setup as _setup\n  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 17, in <module>\n    from setuptools.dist import Distribution\n  File "/venv/lib/python3.10/site-packages/setuptools/dist.py", line 37, in <module>\n    from setuptools.config import setupcfg, pyprojecttoml\n  File "/venv/lib/python3.10/site-packages/setuptools/config/__init__.py", line 8, in <module>\n    from . import setupcfg\n  File "/venv/lib/python3.10/site-packages/setuptools/config/setupcfg.py", line 38, in <module>\n    from . import expand\n  File "/venv/lib/python3.10/site-packages/setuptools/config/expand.py", line 53, in <module>\n    from setuptools.dist import Distribution  # noqa\nImportError: cannot import name \'Distribution\' from partially initialized module \'setuptools.dist\' (most likely due to a circular import) (/venv/lib/python3.10/site-packages/setuptools/dist.py)\n')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
    return importlib.import_module(modname)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/tickit/src/tickit/adapters/io/__init__.py", line 1, in <module>
    from .epics_io import EpicsIo
  File "/workspace/tickit/src/tickit/adapters/io/epics_io.py", line 6, in <module>
    from softioc import builder, softioc
  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>
    from setuptools_dso.runtime import find_dso
  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>
    from setuptools import setup as _setup
  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 35, in <module>
    __version__ = setuptools.version.__version__
AttributeError: partially initialized module 'setuptools' has no attribute 'version' (most likely due to a circular import)

WARNING: autodoc: failed to import module 'epics' from module 'tickit.adapters'; the following exception was raised:
Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
    return importlib.import_module(modname)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/tickit/src/tickit/adapters/epics.py", line 8, in <module>
    from softioc import asyncio_dispatcher, builder, softioc
  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>
    from setuptools_dso.runtime import find_dso
  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>
    from setuptools import setup as _setup
  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 35, in <module>
    __version__ = setuptools.version.__version__
AttributeError: partially initialized module 'setuptools' has no attribute 'version' (most likely due to a circular import)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 88, in import_object
    module = import_module(modname, warningiserror=warningiserror)
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 68, in import_module
    raise ImportError(exc, traceback.format_exc()) from exc
ImportError: (AttributeError("partially initialized module 'setuptools' has no attribute 'version' (most likely due to a circular import)"), 'Traceback (most recent call last):\n  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module\n    return importlib.import_module(modname)\n  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import\n  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load\n  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked\n  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked\n  File "<frozen importlib._bootstrap_external>", line 883, in exec_module\n  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\n  File "/workspace/tickit/src/tickit/adapters/epics.py", line 8, in <module>\n    from softioc import asyncio_dispatcher, builder, softioc\n  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>\n    from setuptools_dso.runtime import find_dso\n  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>\n    from setuptools import setup as _setup\n  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 35, in <module>\n    __version__ = setuptools.version.__version__\nAttributeError: partially initialized module \'setuptools\' has no attribute \'version\' (most likely due to a circular import)\n')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 64, in import_module
    return importlib.import_module(modname)
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/workspace/tickit/src/tickit/adapters/epics.py", line 8, in <module>
    from softioc import asyncio_dispatcher, builder, softioc
  File "/venv/lib/python3.10/site-packages/softioc/__init__.py", line 5, in <module>
    from setuptools_dso.runtime import find_dso
  File "/venv/lib/python3.10/site-packages/setuptools_dso/__init__.py", line 8, in <module>
    from setuptools import setup as _setup
  File "/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 35, in <module>
    __version__ = setuptools.version.__version__
AttributeError: partially initialized module 'setuptools' has no attribute 'version' (most likely due to a circular import)