openstack namespace does not play nicely with checkedout repos

Bug #951197 reported by Jason Kölker
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openstack-common
Fix Released
High
Mark McLoughlin

Bug Description

Both openstack.common and openstack.nose_plugin declare the 'openstack' namespace. When one package is installed it breaks pythons search path of ./ for modules. This breaks update.py for example which is meant to be run out of the os-common checkout directory. It imports cfg from openstack.common, but since it is not installed it cannot be found:

site-packages$ ls openstack*
openstack.nose_plugin-0.5-py2.7-nspkg.pth

openstack:
nose_plugin.py nose_plugin.pyc

openstack.nose_plugin-0.5-py2.7.egg-info:
dependency_links.txt installed-files.txt PKG-INFO SOURCES.txt
entry_points.txt namespace_packages.txt requires.txt top_level.txt

common$ python update.py
Traceback (most recent call last):
  File "update.py", line 64, in <module>
    from openstack.common import cfg
ImportError: No module named common

Since update.py is a "temporary" workaround for incubation we *could* hack it to inject ./openstack/common into the openstack namespace, but there might be a better way. Need to research.

Changed in openstack-common:
assignee: nobody → Jason Kölker (jason-koelker)
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-common (master)

Fix proposed to branch: master
Review: https://review.openstack.org/5179

Changed in openstack-common:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-common (master)

Reviewed: https://review.openstack.org/5179
Committed: http://github.com/openstack/openstack-common/commit/e8a5ae2e5aab6b649b57d03f8a03af689d7e6b6e
Submitter: Jenkins
Branch: master

commit e8a5ae2e5aab6b649b57d03f8a03af689d7e6b6e
Author: Jason Kölker <email address hidden>
Date: Fri Mar 9 17:29:41 2012 -0600

    Import cfg module directly if not in path

    If openstack.common is not installed, but another module has declared
    the openstack namespace an ImportError is thrown since the common doesnt
    exist in the openstack namespace. This falls back to importing cfg
    directly from ./openstack/common/cfg.py.

    Also ensures that openstack/__init__.py exists in the destination

    * Fixes LP951197

    Change-Id: I88c26fb7cc1aed97e66b068e4f0562b1f00b2b29

Changed in openstack-common:
status: In Progress → Fix Committed
Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

The change doesn't handle the case where cfg.py imports other modules from openstack/common which aren't installed yet either. This is the case with the new iniparser.py module that I recently got merged.

As a workaround so I can get my changes into nova, I hacked update.py to use this code:

try:
    from openstack.common import cfg
except AttributeError:
    try:
        sys.path.insert(0, '.')
        from openstack.common import cfg
    finally:
        sys.path.pop(0)

Changed in openstack-common:
status: Fix Committed → Confirmed
Revision history for this message
Bhuvan Arumugam (bhuvan) wrote :

Right now, update.py is not usable.
whitepearl:openstack-common bhuvan$ python update.py ../nova/openstack-common.conf
Traceback (most recent call last):
  File "update.py", line 74, in <module>
    if f is not None:
NameError: name 'f' is not defined

With Johannes's patch in #3, it's working fine.

Johannes, can you please propose your patch for review, as attached in gerrit?

Changed in openstack-common:
status: Confirmed → Incomplete
Revision history for this message
Mark McLoughlin (markmc) wrote :

Looks like this stills isn't resolved, given the issue Brian Waldon was seeing: https://review.openstack.org/#/c/6769/

Changed in openstack-common:
status: Incomplete → Confirmed
milestone: none → folsom-1
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-common (master)

Fix proposed to branch: master
Review: https://review.openstack.org/8401

Changed in openstack-common:
status: Confirmed → In Progress
Revision history for this message
Mark McLoughlin (markmc) wrote :

AFAIR, the update.sh script works around this issue

Changed in openstack-common:
status: In Progress → Fix Released
milestone: folsom-1 → 2012.2
assignee: Jason Kölker (jason-koelker) → Mark McLoughlin (markmc)
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.