adafruit / circup

CircuitPython library updater.
MIT License
130 stars 37 forks source link

Update command only partially working for local path instead of device #220

Open FoamyGuy opened 6 months ago

FoamyGuy commented 6 months ago

Technically the combination of --path, --cpy-version, and --board-id should allow any of the other commands to run targeting a local directory (without a boot_out.txt file) instead of a physical device.

However the update command currently raises an error if you attempt to use it with these arguments.

$ circup --path fake_project/ --cpy-version 8.0.0 --board-id fake update
Found device at fake_project/, running CircuitPython 8.0.0.
A newer version of CircuitPython (9.0.4) is available.
Get it here: https://circuitpython.org/board/fake
Traceback (most recent call last):
  File "/home/timc/.local/bin/circup", line 33, in <module>
    sys.exit(load_entry_point('circup', 'console_scripts', 'circup')())
  File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/timc/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/timc/.local/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/timc/repos/circuitpython/circup/circup/commands.py", line 493, in update
    modules_to_update = [m for m in installed_modules if m.outofdate]
  File "/home/timc/repos/circuitpython/circup/circup/commands.py", line 493, in <listcomp>
    modules_to_update = [m for m in installed_modules if m.outofdate]
  File "/home/timc/repos/circuitpython/circup/circup/module.py", line 108, in outofdate
    if self.mpy_mismatch:
  File "/home/timc/repos/circuitpython/circup/circup/module.py", line 142, in mpy_mismatch
    if self.min_version and cpv < VersionInfo.parse(self.min_version):
UnboundLocalError: local variable 'cpv' referenced before assignment
FoamyGuy commented 6 months ago

the circup list command reports the same error as well.