lopsided98 / nix-ros-overlay

ROS overlay for the Nix package manager
Apache License 2.0
173 stars 69 forks source link

Move empy override from distros/ to pkgs/ #358

Closed wentasah closed 4 months ago

wentasah commented 4 months ago

This is needed because colcon also depends on empy and is incompatible with empy 4. Colcon is defined in pkgs/, but distros/ overlay is applied after pkgs/.

Without this change, colcon prints the following errors:

ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.task.build.python': cannot import name 'OVERRIDE_OPT' from 'em' (/nix/store/qbzhivb1f0z53p4xy4203jhy7x6m9ymi-python3.11-empy-4.0.1/lib/python3.11/site-packages/em.py) The Python package 'empy' must be installed and 'em' must not be installed since both packages share the same namespace
Traceback (most recent call last):
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/entry_point.py", line 120, in load_entry_points
    extension_type = load_entry_point(entry_point)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/entry_point.py", line 166, in load_entry_point
    return entry_point.load()
           ^^^^^^^^^^^^^^^^^^
  File "/nix/store/dyl7f7v3cfi7j9d4z42pn2ss0bgw0r33-python3.11-setuptools-69.0.2/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2516, in load
    return self.resolve()
           ^^^^^^^^^^^^^^
  File "/nix/store/dyl7f7v3cfi7j9d4z42pn2ss0bgw0r33-python3.11-setuptools-69.0.2/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2522, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/task/python/build.py", line 25, in <module>
    from colcon_core.task.python.template import expand_template
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/task/python/template/__init__.py", line 4, in <module>
    from colcon_core.shell.template import expand_template  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/shell/template/__init__.py", line 19, in <module>
    raise e from None
  File "/nix/store/nqwh1ja6x4lm7jancwbjbmhq28d2xm50-python3.11-colcon-core-0.12.1/lib/python3.11/site-packages/colcon_core/shell/template/__init__.py", line 10, in <module>
    from em import OVERRIDE_OPT
ImportError: cannot import name 'OVERRIDE_OPT' from 'em' (/nix/store/qbzhivb1f0z53p4xy4203jhy7x6m9ymi-python3.11-empy-4.0.1/lib/python3.11/site-packages/em.py) The Python package 'empy' must be installed and 'em' must not be installed since both packages share the same namespace
Thieso commented 4 months ago

Can confirm, have the same problem.

lopsided98 commented 4 months ago

I implemented this slightly differently by adding an empy_3 attribute at the global scope. This prevents the override from affecting other packages (although in practice nothing in nixpkgs uses empy).