portante / pycscope

Cscope database generator for Python source code
GNU General Public License v2.0
141 stars 29 forks source link

Cannot install: No module named 'parser' #49

Open ClayShoaf opened 2 years ago

ClayShoaf commented 2 years ago

When I try to install, I get the following output:

[user ~/github/pycscope]$ python setup.py install
Traceback (most recent call last):
  File "/home/user/github/pycscope/setup.py", line 5, in <module>
    from pycscope import __version__
  File "/home/user/github/pycscope/pycscope/__init__.py", line 25, in <module>
    import keyword, parser, symbol, token
ModuleNotFoundError: No module named 'parser'
ruben2020 commented 2 years ago

I think the issue is basically that pycscope cannot be run using Python 3.10 because the parser module has been removed. It works on Python 3.8 and older, though.

portante commented 2 years ago

Ugh.

arkdae commented 2 years ago

That's not the only thing that is gone in 3.10, so is the symbol module.

brianphaley commented 2 years ago

Hi Peter!

And at least one new distro (Ubuntu 22.04) is 3.10+ only now ;-( I guess ast is the closest replacement? I might have to start looking at this as I use it every day, until then can generate cscope.out files on an older system.

portante commented 2 years ago

Any help you can offer would be great. I have not had a chance to dive into this work for a long time now.

ruben2020 commented 2 years ago

@portante The parser module has been deprecated since Python 3.10. The only way left is the ast (abstract syntax tree) module. However, I think pycscope requires a concrete syntax tree that preserves the original source code, rather than an abstract syntax tree that's lossy. So, instead of using the ast module, you may need something like LibCST.

ruben2020 commented 2 years ago

@portante oh. I'm mistaken. There might be a far simpler way to fix this. Please see this page. The change looks trivial. They simply replaced parser.suite with ast.parse.

ruben2020 commented 2 years ago

@portante I tried it, but it doesn't work. I think the old tuple structure is no longer used. Looks like you have no other choice but to port pycscope to ast or LibCST, which is a huge change to pycscope. It's almost a rewrite I expect. The other alternative is for you to get the old parser and symbol modules' source code from 3.9 and incorporate it into pycscope.