Closed JulienPalard closed 5 years ago
Hello,
Would it be possible to merge and release this PR ?
I have unit tests for a small preview web server that fails because of the bad formatted logs :
logger.error("Error while checking dependencies: ", e)
And when I point to the github master in setup.py
setuptools will still get the 0.11 version.
Thank you.
What I try to fix
Avoid a call in
executable_is_available
Also avoiding problems if the said process does not implement
--version
. Fixed by just using shutil.which.While fixing this, I took the time to break the API (WTF ?), don't hesitate if it's not OK.
Undecided exception type
The implementations of
check_dependencies
were sometimes:and sometimes:
Which were semantically equivalent: if it raises, something is wrong. But two distinct exceptions were semantically the same:
BuilderDependencyNotFound
andExecutableNotFound
. I tried to untangle this by removingExecutableNotFound
.Unclear method protocol
check_executable_is_available
andcheck_dependencies
was said to return a boolean, but in fact never returnedFalse
. In one hand, returning a bool say "please use an if", but never returningFalse
make the if useless.Now
check_executable_is_available
is renamed asexecutable_is_available
and just returns a boolean, never raises, as it's enough.And
check_dependencies
now never returnsTrue
, just raises in case of a missing dependency.The qpdf case
A missing
qpdf
were spotted only at runtime, only if given an PDF with an unspported code. I found this while refactoring for the previous cases. I don't like discovering missing dependencies at runtime, so I moved this check in acheck_dependencies
.It make
qpdf
a dependency even when unnecessary, which is bad. But it make clear thatqpdf
can be necessary and has to be installed before a user try an incompatible PDF in production, which I think is a bit better.