[openstack-dev] [all] [glance] python namespaces considered harmful to development, lets not introduce more of them

Ben Nemec openstack at nemebean.com
Wed Aug 27 15:07:13 UTC 2014


On 08/27/2014 09:31 AM, Sean Dague wrote:
> So this change came in with adding glance.store -
> https://review.openstack.org/#/c/115265/5/lib/glance, which I think is a
> bad direction to be headed.
> 
> Here is the problem when it comes to working with code from git, in
> python, that uses namespaces, it's kind of a hack that violates the
> principle of least surprise.
> 
> For instance:
> 
> cd /opt/stack/oslo.vmware
> pip install .
> cd /opt/stack/olso.config
> pip install -e .
> python -m olso.vmware
> /usr/bin/python: No module named olso.vmware
> 
> In python 2.7 (using pip) namespaces are a bolt on because of the way
> importing modules works. And depending on how you install things in a
> namespace will overwrite the base __init__.py for the top level part of
> the namespace in such a way that you can't get access to the submodules.
> 
> It's well known, and every conversation with dstuft that I've had in the
> past was "don't use namespaces".
> 
> A big reason we see this a lot is due to the fact that devstack does
> 'editable' pip installs for most things, because the point is it's a
> development environment, and you should be able to change code, and see
> if live without having to go through the install step again.
> 
> If people remember the constant issues with oslo.config in unit tests 9
> months ago, this was because of mismatch of editable vs. non editable
> libraries in the system and virtualenvs. This took months to get to a
> consistent workaround.
> 
> The *workaround* that was done is we just gave up on installing olso
> libs in a development friendly way. I don't consider that a solution,
> it's a work around. But it has some big implications for the usefulness
> of the development environment. It also definitely violates the
> principle of least surprise, as changes to oslo.messaging in a devstack
> env don't immediately apply, you have to reinstall olso.messaging to get
> them to take.
> 
> If this is just oslo, that's one thing (and still something I think
> should be revisted, because when the maintainer of pip says "don't do
> this" I'm inclined to go by that). But this change aims to start brining
> this pattern into other projects. Realistically I'm quite concerned that
> this will trigger more work arounds and confusion.
> 
> It also means, for instance, that once we are in a namespace we can
> never decide to install some of the namespace from pypi and some of it
> from git editable (because it's a part that's under more interesting
> rapid development).
> 
> So I'd like us to revisit using a namespace for glance, and honestly,
> for other places in OpenStack, because these kinds of violations of the
> principle of least surprise is something that I'd like us to be actively
> minimizing.
> 
> 	-Sean
> 

+1.  Just say no to namespaces.

The only reason we didn't rip them out of oslo completely is that
renaming libraries used by so many projects is painful in and of itself.
 If you can avoid making the namespace mistake up front that's
absolutely the way to go.

-Ben



More information about the OpenStack-dev mailing list