awslabs / collectd-cloudwatch

A collectd plugin for sending data to Amazon CloudWatch
MIT License
200 stars 132 forks source link

Updating requests can break other packages on CentOS 7 #41

Open alanivey opened 7 years ago

alanivey commented 7 years ago

src/setup.py will always force update requests to the latest version. This caused at least one issue on CentOS 7 for another package.

In this example, certbot from the EPEL repository (which, depends on packages from standard repositories 'base' and 'updates') breaks after installing collectd-cloudwatch:

$ yum -q -y install epel-release
$ yum -q -y install certbot
$ certbot --version
certbot 0.12.0

$ yum -q -y install python-pip
$ pip list 2>/dev/null | awk -F"[()]" '/requests/ {print $2}'
2.6.0
$ rpm -q python-requests --queryformat '%{VERSION}\n'
2.6.0

$ yum -q -y install collectd

$ mkdir -p /usr/local/src/collectd-cloudwatch
$ curl -sL 'https://github.com/awslabs/collectd-cloudwatch/tarball/master' | tar zx -C '/usr/local/src/collectd-cloudwatch' --strip 1
$ python /usr/local/src/collectd-cloudwatch/src/setup.py
# Hit [Ctrl+C] to break prompt anytime after 'Installing python dependencies ... OK'

$ pip list 2>/dev/null | awk -F"[()]" '/requests/ {print $2}'
2.13.0

$ certbot --version
Traceback (most recent call last):
  File "/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.12.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 21, in <module>
    from certbot import client
  File "/usr/lib/python2.7/site-packages/certbot/client.py", line 10, in <module>
    from acme import client as acme_client
  File "/usr/lib/python2.7/site-packages/acme/client.py", line 31, in <module>
    requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3()
  File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 112, in inject_into_urllib3
    _validate_dependencies_met()
  File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 147, in _validate_dependencies_met
    raise ImportError("'pyOpenSSL' module missing required functionality. "
ImportError: 'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.

As a workaround, I am removing the re-installation of requests (if it's already on my system) before running src/setup.py:

if ( rpm -q python-requests &>/dev/null ) && ( grep -q -E '^PYTHON_DEPENDENCIES[[:blank:]]*.*requests' src/setup.py ); then
  sed -r -e '/^PYTHON_DEPENDENCIES/ s/"requests",?//g' -i-default src/collectd-cloudwatch/src/setup.py
fi

I didn't see anything in setup.py as for why the latest version is needed every time. Perhaps if a minimum version was pinned, I could better determine if I need to resolve issues with other packages.