httplib2 API is different when installed from source or as RPM?
-
22-04-2021 - |
Domanda
Boy, is this frustrating...
I installed the httplib2
by downloading the .tar.gz package from the site on my CentOS development VM. After spending 1/2 day to get it do two-way ssl authentication, I install the python26-httplib2.noarch
on the target RHEL 5.7 machine. Suddenly the code does not run as the class constructor is different!
The official documentation defines the Http
class as follows:
class httplib2.Http([cache=None][, timeout=None][, proxy_info=None][, ca_certs=None][, disable_ssl_certificate_validation=False])
My code that uses the tar installation indeed does this, and it works:
client = httplib2.Http(ca_certs='/path-to/ca.cert')
However, the ca_cert
parameter is not recognized in the RPM installation. Looking in the lib, I indeed see the following:
class Http(object):
def __init__(self, cache=None, timeout=None, proxy_info=None):
i.e. totally different parameter list.
Is there any explanation for this?
PS. Sorry if I sound furious - I am. It's 8pm and I hoped to check in the code today...
PPS. Python 2.6
Soluzione
I would guess: different httplib2 versions. As far as I understand from a quick glance at the change log and code, ca_certs
supports SSL server certificate validation, which has been added in httplib2 0.7.0. Is it possible that the httplib2 version coming from RPM is older than that? What does print httplib2.__version__
show?
As a workaround, I would suggest not to install Python libraries from tar.gz files or from Red Hat packages; use pip instead, possibly with a requirement file where you can specify the exact version number (or even a lower-bound one) of each external library you need for your program to run.