Install / RedHat 6.2 / pip fails with InstallationError

Bug #939653 reported by Marc Rechté
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

This is with official 6.1 openerp downloaded here http://nightly.openerp.com/6.1/releases/openerp-6.1-1.tar.gz
Followed the README
The last step (# pip install .) fails with the following message:

...
copying and adjusting openerp-server -> build/scripts-2.6

changing mode of build/scripts-2.6/openerp-server from 644 to 755

running install_lib

byte-compiling /usr/lib/python2.6/site-packages/openerp/addons/base/ir/ir_model.py to ir_model.pyc

python: Python/compile.c:3437: stackdepth_walk: Assertion `depth >= 0' failed.

----------------------------------------

Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-g0BVFR-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Zjgm4Z-record/install-record.txt failed with error code -6 in /tmp/pip-g0BVFR-build

Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/basecommand.py", line 104, in main
    status = self.run(options, args)
  File "/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/commands/install.py", line 250, in run
    requirement_set.install(install_options, global_options)
  File "/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/req.py", line 1133, in install
    requirement.install(install_options, global_options)
  File "/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/req.py", line 577, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python2.6/site-packages/pip-1.1-py2.6.egg/pip/__init__.py", line 256, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-g0BVFR-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Zjgm4Z-record/install-record.txt failed with error code -6 in /tmp/pip-g0BVFR-build

Related branches

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Marc,

This problem doesn't occurs due to OpenERP. So I am closing it.

Sorry wrong project.

Thanks!

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello,

That is quite unfortunately caused by a bug in certain Python 2.6 versions on RedHat/CentOS. OpenERP uses standard Python 2.6 features that seem to work on all other Python 2.6 platforms.

As discussed on Launchpad answer #185679 and in the forum [1], it seems that on affected Python 2.6 versions it is impossible to nest more than 4 "if" filters in a list comprehension expression.

The ir.model class uses a list comprehension expression with 5 nested ifs:

  def _get_fields_type(self, cr, uid, context=None):
      return sorted([(k,k) for k,v in fields.__dict__.iteritems()
                      if type(v) == types.TypeType
                      if issubclass(v, fields._column)
                      if v != fields._column
                      if not v._deprecated
                      if not issubclass(v, fields.function)])

We could implement a workaround for CentOS in this specific case, but it does not guarantee that we will not see other similar (but less obvious) cases of this same problem, because it breaks our fundamental hypothesis of "cross-platformness" of Python!
My google skills did not reveal any obvious bug report on Fedora/CentOS/RedHat, so it would perhaps be a good idea to report this upstream and get it fixed where it should be.

One way to rewrite the above code without so many nested `if`s is to simply replace them with `and`s:

 def _get_fields_type(self, cr, uid, context=None):
      return sorted([(k,k) for k,v in fields.__dict__.iteritems()
                      if type(v) == types.TypeType and \
                         issubclass(v, fields._column) and \
                         v != fields._column and \
                         not v._deprecated and \
                         not issubclass(v, fields.function)])

[1] http://www.openerp.com/forum/topic30304.html

Changed in openobject-addons:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: Invalid → Confirmed
affects: openobject-addons → openobject-server
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

The workaround described in comment #2 was implemented in the 6.1 server branch at revision 4082 (revision-id: <email address hidden>)
It should be part of tonight's nightlies.

Thanks a lot for testing our RPM packaging and reporting this!

PS: please do not hesitate to report this bug upstream, it would save everyone a lot of trouble

Changed in openobject-server:
milestone: none → 6.1
status: Confirmed → Fix Released
Revision history for this message
Pablo Baenas (pbaenas) wrote :

Install python 2.6.7 from source fix this issue.

Revision history for this message
Zydoon (zydoon) wrote :

on RHEL 6 updating python 2.6.6 from source to 2.6.7 is a huge adventure, I just replaced the file ir_model.py modified by Olivier:
openerp/addons/base/ir/ir_model.py
with this one
http://bazaar.launchpad.net/~openerp/openobject-server/trunk/files/4090/openerp/addons/base/ir/ir_model
and RPM building was ok.
sudo python setup.py bdist_rpm

Revision history for this message
Marc Rechté (marc3) wrote :

It is now working OK. Thanks a lot.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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