PeterJCLaw / srcomp-http

Web API to the state of the Student Robotics Competition
https://github.com/PeterJCLaw/srcomp/wiki
GNU General Public License v3.0
0 stars 4 forks source link

Install the update script properly #4

Closed PeterJCLaw closed 5 years ago

PeterJCLaw commented 5 years ago

Under Python 2 we got away with having the ./update script be a locally callable script. Under Python 3 this hits issues due to the inclusion of the script's own directory on the sys.path which is looked at for imports.

For example:

['/home/srcomp/srcomp-http', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-arm-linux-gnueabihf', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']

Oddly, the stacktrace we get on failure suggests that modules from sr.comp.http actually are found from the global set, however those outside that namespace are the ones which fail:

Traceback (most recent call last):
  File "/home/srcomp/srcomp-http/update", line 5, in <module>
    from sr.comp.http import update
  File "/usr/local/lib/python3.5/dist-packages/sr/comp/http/__init__.py", line 1, in <module>
    from .server import app
  File "/usr/local/lib/python3.5/dist-packages/sr/comp/http/server.py", line 11, in <module>
    from sr.comp.match_period import MatchType
ImportError: No module named 'sr.comp.match_period'
PeterJCLaw commented 5 years ago

Turns out that python -m sr.comp.http.update was already supported. As that's good enough for the intended use-cases we don't need to also install a specific entry point (which I had thought we would need to).