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)
[]
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 usingsubprocess
, 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:
and now:
Checklist