nickdiego / compiledb

Tool for generating Clang's JSON Compilation Database files for make-based build systems.
GNU General Public License v3.0
1.35k stars 122 forks source link

Python 3: TypeError: __init__() got an unexpected keyword argument 'encoding' #92

Open unix-junkie opened 4 years ago

unix-junkie commented 4 years ago

I'm trying to run compiledb (the Python 3 version) on a Debian 9 box:

$ compiledb make
## Building [make]...
cc -I/usr/local/include   -c -o xpickrgb.o xpickrgb.c
cc -o xpickrgb -L/usr/local/lib xpickrgb.o -lX11 -lm -lc

Traceback (most recent call last):
  File "/home/bass/bin/compiledb", line 11, in <module>
    sys.exit(cli())
  File "/home/bass/.local/lib/python3.5/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/bass/.local/lib/python3.5/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/bass/.local/lib/python3.5/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/bass/.local/lib/python3.5/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bass/.local/lib/python3.5/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/bass/.local/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/bass/.local/lib/python3.5/site-packages/compiledb/commands/make.py", line 102, in command
    pipe = popen(cmd, stdout=PIPE, encoding='utf-8')
  File "/home/bass/.local/lib/python3.5/site-packages/compiledb/commands/make.py", line 14, in popen
    return Popen(cmd, encoding=encoding, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'encoding'

Python version is:

$ python3 -V
Python 3.5.3

When using the Python 2 version, there's no such error, and compiledb works correctly.

agnjunio commented 4 years ago

Just to clarify, what version of compiledb are you running?

pip3 freeze | grep compiledb
unix-junkie commented 4 years ago

It's version 0.9.8:

$ pip3 freeze | grep compiledb
compiledb==0.9.8

Strangely, the Python 2 version is slightly newer:

$ pip freeze | grep compiledb
compiledb==0.10.1
agnjunio commented 4 years ago

There were a recent patch to fix the issue you mentioned. Probably the fix is in the latest version (0.10.1). Try to have it installed on your python 3 version:

pip3 install compiledb --upgrade
unix-junkie commented 4 years ago

@agnjunio Unfortunately, it's still version 0.9.8:

$ pip3 install compiledb --upgrade --no-cache-dir
Collecting compiledb
  Downloading https://files.pythonhosted.org/packages/f3/93/cf32ff4c28aa3d22e35ae6f3648abf3d67ffc068d6f946191a7647372857/compiledb-0.9.8-py3-none-any.whl
Collecting click (from compiledb)
  Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
    100% |████████████████████████████████| 81kB 1.7MB/s 
Collecting bashlex (from compiledb)
  Downloading https://files.pythonhosted.org/packages/e4/27/c639cb10b965cf4fb5a3b9a9786ecd07edb681522e0d93bfc1ce8704f9d8/bashlex-0.14.tar.gz (60kB)
    100% |████████████████████████████████| 61kB 19.1MB/s 
Installing collected packages: click, bashlex, compiledb
  Running setup.py install for bashlex ... done
Successfully installed bashlex-0.14 click-7.0 compiledb-0.9.8
agnjunio commented 4 years ago

So, I made some initial testing and saw that your Python 3.5.x version is currently not supported by the versions listed in setup.py. Maybe that's why you can't upgrade to 0.10.1.

I will dig a little bit more to find out why versions 3.0-3.5 aren't passing in the tests.