Skycoder42 / qdep

A very basic yet simple to use dependency management tool for qmake based projects
BSD 3-Clause "New" or "Revised" License
18 stars 4 forks source link

__init__() got an unexpected keyword argument 'encoding' #4

Closed defaultsamson closed 4 years ago

defaultsamson commented 4 years ago

When I run the command to setup my Qt installation qdep prfgen --qmake ~/Qt/5.12.6/gcc_64/bin/qmake I run into this error

Traceback (most recent call last):
  File "/usr/local/bin/qdep", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/qdep/internal/cli.py", line 163, in main
    prfgen(path.abspath(sys.argv[0]), res.qmake, res.dir)
  File "/usr/local/lib/python3.5/dist-packages/qdep/qdep.py", line 12, in prfgen
    qmake_res = sub_run([qmake, "-query", "QT_HOST_DATA"], check=True, stdout=subprocess.PIPE, encoding="UTF-8")
  File "/usr/local/lib/python3.5/dist-packages/qdep/internal/common.py", line 59, in sub_run
    return subprocess.run(*args, **kwargs)
  File "/usr/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'encoding'

I'm using a fresh install of Ubuntu 16.04 with Python 3.5.2, and this doesn't happen on my Ubuntu 18.04 install with Python 3.6.9. When I take the problematic line of code:

https://github.com/Skycoder42/qdep/blob/81e66117fdf389a2ea27292355101c4d63fa7904/qdep/qdep.py#L12

and remove the encoding=... part...

qmake_res = sub_run([qmake, "-query", "QT_HOST_DATA"], check=True, stdout=subprocess.PIPE)

it works :) I'm not an experienced Python dev, so I'm not sure if there are any negative implications of this quick-fix, but it got it to run just fine with this.

HOWEVER

When I build a project with qdep in QtCreator, I get Project ERROR: Failed to load qdep feature, which is an error in my *.pro file. I realized I was silly, and found the qdep.prf in b'/home/test/Qt/5.12.6/gcc_bin\n'/mkspecs/features/, and moved it to /home/test/Qt/5.12.6/gcc_bin/mkspecs/features/ as it should be.

BUT NOW

I'm getting the following error when I build my project

Traceback (most recent call last):
  File "/usr/local/bin/qdep", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/qdep/internal/cli.py", line 179, in main
    dephash(*res.input, project=res.project, pkgpath=res.pkgpath)
  File "/usr/local/lib/python3.5/dist-packages/qdep/internal/private.py", line 10, in dephash
    print(pkg_hash(pkg_url, pkg_path))
  File "/usr/local/lib/python3.5/dist-packages/qdep/internal/common.py", line 41, in pkg_hash
    return "__QDEP_PKG_" + hashlib.sha3_256((pkg_url + pkg_path).lower().encode("UTF-8")).hexdigest()
AttributeError: module 'hashlib' has no attribute 'sha3_256'
defaultsamson commented 4 years ago

I updated my Python version from 3.5 to 3.8 and that solved it. Weird, and a bit of a headache, but I'm glad it's all over now :)

closing unnecessary issue

Skycoder42 commented 4 years ago

Yes, as you probably already found out, qdep requires python 3.8

defaultsamson commented 4 years ago

Sometimes actually reading the doc instead of me thinking I know what I'm doing saves an hour or two :)

Great tool btw!

Skycoder42 commented 4 years ago

Thanks!