olofk / fusesoc

Package manager and build abstraction tool for FPGA/ASIC development
BSD 2-Clause "Simplified" License
1.14k stars 235 forks source link

Python 3.6 SyntaxError in edalize #621

Closed shenki closed 6 months ago

shenki commented 1 year ago

A colleague installed fusesoc using pip on a machine running python3.6:

Traceback (most recent call last):
  File "/home/user/.local/bin/fusesoc", line 7, in <module>
    from fusesoc.main import main
  File "/home/user/.local/lib/python3.6/site-packages/fusesoc/main.py", line 32, in <module>
    from fusesoc.coremanager import CoreManager, DependencyError
  File "/home/user/.local/lib/python3.6/site-packages/fusesoc/coremanager.py", line 16, in <module>
    from fusesoc.core import Core
  File "/home/user/.local/lib/python3.6/site-packages/fusesoc/core.py", line 7, in <module>
    from fusesoc.capi2.core import Core as Capi2Core
  File "/home/user/.local/lib/python3.6/site-packages/fusesoc/capi2/core.py", line 1013, in <module>
    for backend in get_edatools():
  File "/home/user/.local/lib/python3.6/site-packages/edalize/edatool.py", line 54, in get_edatools
    return [get_edatool(pkg) for pkg in walk_tool_packages()]
  File "/home/user/.local/lib/python3.6/site-packages/edalize/edatool.py", line 54, in <listcomp>
    return [get_edatool(pkg) for pkg in walk_tool_packages()]
  File "/home/user/.local/lib/python3.6/site-packages/edalize/edatool.py", line 40, in get_edatool
    return getattr(import_module(f"edalize.{name}"), name.capitalize())
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/user/.local/lib/python3.6/site-packages/edalize/filelist.py", line 135
    if match := regex.match(outpath):
              ^
SyntaxError: invalid syntax

The fusesoc docs list 3.6 as the minimum version, but edalize CI tests against 3.7 and above. The assignment expression was added in 3.8 according to https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions

shenki commented 1 year ago

This shows up in fusesoc ci: https://github.com/olofk/fusesoc/actions/runs/4634094461/jobs/8199945878

buehlerIBM commented 1 year ago

I am the colleague. I am 100% new to fusesoc and don't know what shenki's comment should tell me. I installed python3.9 (and 3.8) and made it the default version. However, fusesoc is hard-coded to use python3.6. If I try to overwrite that e.g. with python3.8 ~/.local/bin/fusesoc it still won't run:

python3.8 ~/.local/bin/fusesoc
Traceback (most recent call last):
  File "/home/buehler/.local/bin/fusesoc", line 7, in <module>
    from fusesoc.main import main
ModuleNotFoundError: No module named 'fusesoc'

I guess this is because of this: ~/.local/lib/python3.6/site-packages I played around with symbolic links etc. but couldn't get it to work. I guess I'll have to wait for someone to help me. BTW: I am running on RedHat8.2

shenki commented 1 year ago

Try reinstalling fusesoc with the updated python

buehlerIBM commented 1 year ago

I did already. I also removed ~/.local/lib/python3.6.
This all did not help.

dbesse commented 1 year ago

This has been reported in edalize as well, but with no reaction: https://github.com/olofk/edalize/issues/374

buehlems commented 1 year ago

We could solve the problems on our side: I had changed the python version to 3.9 but not the pip version. Once I fixed that, fusesoc did work.
So it is basically a documentation problem that remains: Python 3.6 is not sufficient. I verified that 3.8 and 3.9 do work.

dbesse commented 1 year ago

The problematic file is not used (contains a reference to edam["top_core"] which is not defined) and is the only one using python3.8 syntax. So, I believe it would make more sense to fix or remove it instead of requiring 3.8 and calling it a documentation problem.

olofk commented 6 months ago

I believe this should be fixed with https://github.com/olofk/edalize/issues/374 . Please reopen otherwise