ApeWorX / py-solc-x

Python wrapper and version management tool for the solc Solidity compiler.
https://solcx.readthedocs.io/
MIT License
138 stars 48 forks source link

use python built-in shutil.which instead of shelling out #137

Closed f0rki closed 10 months ago

f0rki commented 2 years ago

What I did

So my original issue was that running which without stderr being redirected to /dev/null results in an ugly error message, when running solcx on a new system without any solc (e.g., in a container).

I switched to python's builtin shutil.which instead of using subprocess, which fixes this and avoids spawning a new process. It is part of the standard library so it should work on all platforms and behave equally. However I have only tested on linux.

How to verify it

previously:

$ python -c 'import solcx; print(solcx.import_installed_solc())'
which: no solc in ($PATH)
[]

and now:

$ python -c 'import solcx; print(solcx.import_installed_solc())'
[]

Checklist