setup.py shouldn't try to pip install anything

Bug #1662225 reported by Lucas Alvares Gomes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-redfish
Fix Released
High
Uggla

Bug Description

The setup.py script tries to import future and if it fails it then attempts to pip install that library [0] that seems to be a hack and needs to be removed because it causes a lot of pain on system that is trying to package the library. For example, when packing for RDO this problems appears:

DEBUG: configure yum
DEBUG: configure yum priorities
DEBUG: configure yum rhnplugin
DEBUG: touching file: /var/lib/mock/dlrn-centos7-x86_64-1/root/.initialized
Finish: chroot init
INFO: Running in chroot: ['cd /tmp/pkgsrc && python setup.py sdist']
Start: chroot ['cd /tmp/pkgsrc && python setup.py sdist']
DEBUG: child environment: None
DEBUG: Executing command: ['/bin/sh', '-c', 'cd /tmp/pkgsrc && python setup.py sdist'] with env {'LANG': 'en_IE.UTF-8', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'TERM': 'vt100', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PROMPT_COMMAND': 'printf "\\033]0;<mock-chroot>\\007"', 'PS1': '<mock-chroot> \\s-\\v\\$ ', 'SHELL': '/bin/bash'} and shell False
DEBUG: Unsharing. Flags: 134217728
Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    check_call(["pip", "install", "future"])
  File "/usr/lib64/python2.7/subprocess.py", line 537, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
DEBUG: Child return code was: 1
Finish: chroot ['cd /tmp/pkgsrc && python setup.py sdist']
DEBUG: kill orphans

[0] https://github.com/openstack/python-redfish/blob/c422e152f3046efa90bd282f3cf3754fabd0d2fe/setup.py#L27-L30

...

Another problem this would raise is that, in order to execute anything in setup.py (say just do python setup.py sdist) will require a privileged user otherwise we won't have permission to install the library via pip, for example:

$ python setup.py sdist
Collecting future
Installing collected packages: future
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 326, in run
    strip_file_prefix=options.strip_file_prefix,
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 834, in install
    strip_file_prefix=strip_file_prefix
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 1037, in move_wheel_files
    strip_file_prefix=strip_file_prefix,
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
    ensure_dir(destdir)
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/future-0.16.0.dist-info'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Traceback (most recent call last):
  File "setup.py", line 29, in <module>
    check_call(["pip", "install", "future"])
  File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '[u'pip', u'install', u'future']' returned non-zero exit status 2

description: updated
Revision history for this message
Uggla (rene-ribaud) wrote :

Thanks for submitting this bug.
Yes I did that and that's a dirty hack. :)

I'll try to fix it ASAP.

Changed in python-redfish:
assignee: nobody → ribaudr (rene-ribaud)
importance: Undecided → High
status: New → In Progress
Revision history for this message
Lucas Alvares Gomes (lucasagomes) wrote :

Hi ribaudr,

No problem, thanks for taking a look at it. I think that overall, the rule should be to not depend on third-party libraries in the setup.py module, that can cause a lot of trouble.

Revision history for this message
Uggla (rene-ribaud) wrote :

Main problem is that setup.py and python package management globally has a lot of limitations, and sometimes it is not possible.

Revision history for this message
Uggla (rene-ribaud) wrote :

Can you please try https://review.openstack.org/#/c/432596/ if it fixes the pb.

Changed in python-redfish:
status: In Progress → Fix Committed
Changed in python-redfish:
milestone: none → 0.4
Changed in python-redfish:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.