Skip to content

Import issues with relative paths and editable install #532

@ajoubertza

Description

@ajoubertza

We've migrated our PyTango project to scikit-build-core - it has been working well, but the latest release has broken something with editable installs.

With 0.5.1, pip install -e . on Linux-based systems didn't work either, but it was a different issue. Specifically, the compiled extension code, _tango.so in our case, had to be copied to back to the source repository folder to avoid a ModuleNotFoundError: No module named 'tango._tango' when importing our library. More details in our gitlab issue. After copying the file, the import and library worked fine. Interestingly, the file copying step isn't required on macOS (tested using mambaforge).

With 0.6.0, we don't get ModuleNotFoundError: No module named 'tango._tango' anymore, Instead, there are many runtime warnings about objects in the extension code being re-registered have appeared, and then a new failure related to a relative import.

>>> import tango
<frozen importlib._bootstrap>:241: RuntimeWarning: to-Python converter for PyCmdDoneEvent already registered; second conversion method ignored.
<frozen importlib._bootstrap>:241: RuntimeWarning: to-Python converter for PyAttrReadEvent already registered; second conversion method ignored.
...
<frozen importlib._bootstrap>:241: RuntimeWarning: to-Python converter for log4tango::Level::LevelLevel already registered; second conversion method ignored.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/tango/__init__.py", line 451, in <module>
    from .attr_data import AttrData
  File "/app/tango/attr_data.py", line 26, in <module>
    from .utils import is_non_str_seq, is_pure_str
  File "/app/tango/utils.py", line 54, in <module>
    from .constants import AlrmValueNotSpec, StatusNotSet, TgLibVers
ModuleNotFoundError: No module named 'tango.attr_data.constants'

In our case, the constants module is imported from the compiled extension module earlier in __init__.py, so the code above worked previously. Changing the imports above slightly, to import constants again fixed that problem, but then there was a new circular import problem in another module.

I guess it is related to changes in #399. Maybe we have something incompatible in our code that needs to change. I can provide the old and new site-packages/_pytango_editable.py files, if necessary.

P.S. Thanks for the great work on this project!

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