HewlettPackard / python-hpOneView

DEPRECATED - no longer actively maintained. New repository: https://github.com/HewlettPackard/oneview-python
MIT License
87 stars 57 forks source link

Allow python 2.7.5 support for RHEL/CENTOS/OL7 #308

Closed cocampbe closed 7 years ago

cocampbe commented 7 years ago

Scenario/Intent

Add code to setup.py to check for python version. No need to require futures if you actually use python3. This code will bypass future if you are already using 3.

from setuptools import find_packages
from setuptools import setup
import sys

is_future = 'future>=0.15.2' if sys.version_info[0] < 3 else ''

setup(name='hpOneView',
      version='4.0.0',
      description='HPE OneView Python Library',
      url='https://github.com/HewlettPackard/python-hpOneView',
      download_url="https://github.com/HewlettPackard/python-hpOneView/tarball/v4.0.0",
      author='Hewlett Packard Enterprise Development LP',
      author_email='oneview-pythonsdk@hpe.com',
      license='MIT',
      packages=find_packages(exclude=['examples*', 'tests*']),
      keywords=['oneview', 'hpe'],
      install_requires=[is_future])
cocampbe commented 7 years ago

Looks like more is needed to make this ready for python3. A forking I will go.

cocampbe commented 7 years ago

OK. Here is my situation. RHEL/CENTOS/OL7 come with python 2.7.5 by default. If you change this line

if PYTHON_VERSION < (2, 7, 9):

in init.py, everythong seems to work fine. I am not certain when Red Hat will change to 2.7.9. Maybe in 7u4. But for now making that change will allow folks to use the supported version that ships with those distros. One could use software collections, but I am not certain that many people are familiar with them.

fgbulsoni commented 7 years ago

Hello @cocampbe , there are many places in the code that import future, and future's standard library is also imported quite extensively.

I'd recommend against not installing future despite of the Python version used.

As for 2.7.5 on RHEL, it should already be working with no need for alterations.

    if PYTHON_VERSION < (2, 7, 9):
        warning_message = 'Running unsupported Python version: %s, unexpected errors might occur.'
        warning_message += ' Use of Python v2.7.9+ is advised.'
        warnings.warn(warning_message % '.'.join(map(str, PYTHON_VERSION)), Warning)

This part of the code will just be raising warnings, since that Python version is considered as not supported.

The SDK works on RHEL's python version mainly because RedHat has TLS backported, but that is not a rule of thumb for other distros.

Related issues for more information: #279 & #259

@cocampbe Are you hitting anything related to this that is restricting you at the moment?

cocampbe commented 7 years ago

I need to double check. I was kind of all over the place yesterday. I started on OL6, but it runs 2.6.6 by default. Then I moved over to OL7. I may have just got a warning, but when I tried querying fc-networks, it failed and I just assumed it was a code issue. I am in Houston so Harvey has become a distraction. I think this will work on OL6 using softwarecollections. I'll give that a shot and report back.

cocampbe commented 7 years ago

OK, I was able to install it on OL6. You have to enable the softwarecollections repo. Then you can install python27. Next you can clone the hponeview repo. You will need to install future first. The below command will install it. The trusted-host part is not necessary. I have to because of the way our proxies are set.

scl enable python27 'pip install future --trusted-host pypi.python.org'

After that, you can install the module. cd to the repo and run this.

scl enable python27 'pip install .'

I then tested a script and it is working. I do see that it is just a warning. Sorry for any confusion.