glasgow: running Glasgow exectutable produces "TypeError: expected string or bytes-like object" in packaging\utils.py

The example below is a build command but even just running Glasgow without any arguments, produces the same error. I updated to commit 62e27d9941bf22d1fdb73681af7eb74e96be775a. This is still on python 3.9.

PS C:\Users\Tiago\Documents\Git> glasgow build --rev C3 uart
Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\users\tiago\.local\bin\glasgow.exe\__main__.py", line 7, in <module>
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 910, in main
    exit(loop.run_until_complete(_main()))
  File "c:\python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 490, in _main
    args = get_argparser().parse_args()
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 283, in get_argparser
    add_applet_arg(p_run, mode="interact", required=True)
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 128, in add_applet_arg
    for handle, metadata in GlasgowAppletMetadata.all().items():
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 87, in all
    return {ep.name: cls(ep) for ep in _entry_points(group=cls.GROUP_NAME)}
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 87, in <dictcomp>
    return {ep.name: cls(ep) for ep in _entry_points(group=cls.GROUP_NAME)}
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 97, in __init__
    self.requirements = _requirements_for_optional_dependencies(
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 31, in _requirements_for_optional_dependencies
    if requirement.marker and requirement.marker.evaluate({"extra": dependency}):
  File "C:\Users\Tiago\.local\pipx\venvs\glasgow\lib\site-packages\packaging\markers.py", line 252, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "C:\Users\Tiago\.local\pipx\venvs\glasgow\lib\site-packages\packaging\markers.py", line 157, in _evaluate_markers
    lhs_value, rhs_value = _normalize(lhs_value, rhs_value, key=environment_key)
  File "C:\Users\Tiago\.local\pipx\venvs\glasgow\lib\site-packages\packaging\markers.py", line 131, in _normalize
    return tuple(canonicalize_name(v) for v in values)
  File "C:\Users\Tiago\.local\pipx\venvs\glasgow\lib\site-packages\packaging\markers.py", line 131, in <genexpr>
    return tuple(canonicalize_name(v) for v in values)
  File "C:\Users\Tiago\.local\pipx\venvs\glasgow\lib\site-packages\packaging\utils.py", line 47, in canonicalize_name
    value = _canonicalize_regex.sub("-", name).lower()
TypeError: expected string or bytes-like object

I did try forcing it to be string in plugin.py: if requirement.marker and requirement.marker.evaluate({"extra": str(dependency)}):

but after doing so I get an issue with the aiohttp dependency (so I don’t know if this was the right thing to do):

  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\applet\audio\yamaha_opx\__init__.py", line 143, in <module>
    import aiohttp, aiohttp.web
ModuleNotFoundError: No module named 'aiohttp' 

Here is the full trace:

PS C:\Users\Tiago\Documents\Git> glasgow.exe --version
Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\users\tiago\.local\bin\glasgow.exe\__main__.py", line 7, in <module>
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 910, in main
    exit(loop.run_until_complete(_main()))
  File "c:\python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 490, in _main
    args = get_argparser().parse_args()
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 283, in get_argparser
    add_applet_arg(p_run, mode="interact", required=True)
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\cli.py", line 128, in add_applet_arg
    for handle, metadata in GlasgowAppletMetadata.all().items():
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 87, in all
    return {ep.name: cls(ep) for ep in _entry_points(group=cls.GROUP_NAME)}
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 87, in <dictcomp>
    return {ep.name: cls(ep) for ep in _entry_points(group=cls.GROUP_NAME)}
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\support\plugin.py", line 103, in __init__
    self._cls = entry_point.load()
  File "c:\python39\lib\importlib\metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "c:\python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\Tiago\Documents\Git\glasgow\software\glasgow\applet\audio\yamaha_opx\__init__.py", line 143, in <module>
    import aiohttp, aiohttp.web
ModuleNotFoundError: No module named 'aiohttp'

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 21 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Good/bad:

  • 3.9.x
    • 3.9.5 bad (see Ubuntu 20.04 LTS)
    • 3.9.9 bad
    • 3.9.10 bad
    • 3.9.11 good
    • 3.9.12 good
  • 3.10.x
    • 3.10.1 bad
    • 3.10.2 bad
    • 3.10.3 good

docker run --rm -it python:${version} bash
pip install 'git+https://github.com/GlasgowEmbedded/glasgow#subdirectory=software'
glasgow --version

I can confirm that the above fix works to fix this specific issue, glasgow --version now works again. glasgow build --rev C3 uart does not, but that is a bug which is probably windows specific. I’ll open a new report for that.