srobo / competition-simulator

A simulator for Student Robotics Virtual Competitions
https://studentrobotics.org/docs/simulator/
MIT License
8 stars 2 forks source link

`sr.robot3` not found if another `sr.something` namespace package installed in same Python #381

Closed PeterJCLaw closed 1 year ago

PeterJCLaw commented 1 year ago

If using the same Python environment to run e.g: SRComp (which installs to sr.comp) as the one you want to use for running the simulator then the sr.robot3 package will not be found even though it is correctly on PYTHONPATH.

The fix seems to be to change modules/sr/__init__.py to modules/sr/__init__.pyi. This changes the package being an implicit namespace package, which is compatible with SRComp at least.

trickeydan commented 1 year ago

https://peps.python.org/pep-0420/

PeterJCLaw commented 1 year ago

Indeed. The .pyi file is useful to ensure that mypy correctly handles the namespace packages (or it certainly used to be needed, that may have been fixed).

trickeydan commented 1 year ago

Indeed. The .pyi file is useful to ensure that mypy correctly handles the namespace packages (or it certainly used to be needed, that may have been fixed).

I think there's a --namespace-packages arg for mypy to handle that. We use it for sr.robot3