glato / emerge

Emerge is a browser-based interactive codebase and dependency visualization tool for many different programming languages. It supports some basic code quality and graph metrics and provides a simple and intuitive way to explore and analyze a codebase by using graph structures.
MIT License
783 stars 46 forks source link

SyntaxError: invalid syntax when starting emerge #16

Closed dj0nes closed 2 years ago

dj0nes commented 2 years ago

Getting the following error when trying to start emerge:

(app) āžœ  app git:(master) emerge
Traceback (most recent call last):
  File "/Users/dillon.jones/.pyenv/versions/app/bin/emerge", line 33, in <module>
    sys.exit(load_entry_point('emerge-viz==1.1.0', 'console_scripts', 'emerge')())
  File "/Users/dillon.jones/.pyenv/versions/app/bin/emerge", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/Users/dillon.jones/.pyenv/versions/3.7.10/envs/app/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 167, in load
    module = import_module(match.group('module'))
  File "/Users/dillon.jones/.pyenv/versions/3.7.10/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/dillon.jones/.pyenv/versions/3.7.10/envs/app/lib/python3.7/site-packages/emerge/main.py", line 8, in <module>
    from emerge.appear import Emerge
  File "/Users/dillon.jones/.pyenv/versions/3.7.10/envs/app/lib/python3.7/site-packages/emerge/appear.py", line 14, in <module>
    from emerge.languages.javaparser import JavaParser
  File "<fstring>", line 1
    (result=)
           ^
SyntaxError: invalid syntax

Seems like python doesn't like this line? https://github.com/glato/emerge/blob/ac8adeb7144fef1c99e9ee9c1872551be9936cdc/emerge/languages/javaparser.py#L162

Describe your environment

Python 3.7.10 MacOS 11.6.2, intel cpu emerge-viz 1.1.0

To Reproduce Steps to reproduce the behavior: Install emerge. I had to brew install graphviz and then run the following to avoid a wheel issue

pip install emerge-viz --global-option=build_ext --global-option="-I/usr/local/Cellar/graphviz/2.50.0/include/" --global-option="-L/usr/local/Cellar/graphviz/2.50.0/lib/" pygraphviz

run emerge

Expected behavior emerge starts

glato commented 2 years ago

@dj0nes Confirmed, thanks for finding this issue. I could reproduce it with

pyenv install 3.7.10
pyenv virtualenv 3.7.10 venv-3.7.10
pyenv activate venv-3.7.10
pip install emerge-viz
emerge

which gave me the same error. I'm not quite sure why exactly it's not working aas expected, since python 3.7 should have complete f-string support.

I've tested the same procedure with python 3.8, i.e.

pyenv install 3.8.12
pyenv virtualenv 3.8.12 venv-3.8.12
pyenv activate venv-3.8.12
pip install emerge-viz
emerge

and it starts up the way it should do:

(venv-3.8.12) grzegorz.lato@host ~ % emerge
usage: emerge [-h] [-c YAMLCONFIG] [-v] [-d] [-e] [-a LANGUAGE]

šŸ”Ž Welcome to emerge 1.1.0 (2022-02-06 15:05:39)

optional arguments:
  -h, --help            show this help message and exit
  -c YAMLCONFIG, --config YAMLCONFIG
                        set yaml config file
  -v, --verbose         set logging level to INFO
  -d, --debug           set logging level to DEBUG
  -e, --error           set logging level to ERROR
  -a LANGUAGE, --add-config LANGUAGE
                        add a new config from a template, where LANGUAGE is one of [JAVA, SWIFT, C, CPP, GROOVY, JAVASCRIPT, TYPESCRIPT, KOTLIN, OBJC, RUBY, PY]

It seems that this is somehow specific to at least python 3.7.10. I will have a deeper look at it. As long as this is not fixed, I will (hopefully temporarily) remove the python 3.7 badge hint, to prevent more users running into this. A temporary solution for you @dj0nes could be to install and use a higher python version (as shown above). Keep you up to date if I can find the reason for this.

dj0nes commented 2 years ago

Thanks for looking into this! Using python 3.8.12 as suggested works.

Tangential, I did see fatal error: 'graphviz/cgraph.h' file not found while pip tried installing emerge deps, fixed with:

brew install graphviz
pip install emerge-viz --global-option=build_ext --global-option="-I/usr/local/Cellar/graphviz/2.50.0/include/" --global-option="-L/usr/local/Cellar/graphviz/2.50.0/lib/" pygraphviz