Re: [Distutils] Buildout + namespace packages + Django management commands?
At 01:48 PM 9/19/2009 +0100, Kyle MacFarlane wrote:
The way setuptools (and thus buildout) does namespace packages doesn't work with how Django looks for management commands. Django only looks in the first package in the namespace on the system path and ignores the rest.
If they use the package's __path__ attribute, they'll find its contents, whether someone is using pkgutil.extend_path, .pth files, or setuptools. They don't have to support setuptools to support namespace packages, just pay attention to the __path__ variable that's part of standard Python.
2009/9/19 P.J. Eby
If they use the package's __path__ attribute, they'll find its contents, whether someone is using pkgutil.extend_path, .pth files, or setuptools. They don't have to support setuptools to support namespace packages, just pay attention to the __path__ variable that's part of standard Python.
I was hoping more if anybody knew a recipe to get round my problem but I had a look inside Django to see how it looks through packages. The problem is caused by line 58 at this link raising an ImportError: http://code.djangoproject.com/browser/django/trunk/django/core/management/__... It doesn't matter what order find_module is called on various paths, it still relies entirely on the order in sys.path. Calling find_module on second_app before first_app will still fail if first_app is the first app on sys.path (which suggests that something has been done wrong even before line 58 or find_module itself doesn't support namespaces?). Unfortunately I've never dealt with the imp module before. What would I need to do? Import the package (which is actually "path" in this code), get __path__ from it and then do find_module again but with __path__ instead?
2009/9/20 Kyle MacFarlane
I was hoping more if anybody knew a recipe to get round my problem but I had a look inside Django to see how it looks through packages.
The problem is caused by line 58 at this link raising an ImportError: http://code.djangoproject.com/browser/django/trunk/django/core/management/__...
Yeah, sorry. You can either use Django, or not use namespaces, or fix Django. :) Django simply doesn't support namespaces in this case. Yet another case of Django being the new Zope, although Zope has fixed that problem since a couple of years, and Zope Products can be namespace packages nowadays (and the special Products directory is now a namespace). This all is a part Djangos biggest problem: It doesn't play well with non-Django stuff. They are however aware of this problem, and I'm sure they would appreciate help with fixing this particular issue. In open source it's all a matter of available programmer time. :) -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
On Sun, Sep 20, 2009 at 4:56 AM, Lennart Regebro
2009/9/20 Kyle MacFarlane
: I was hoping more if anybody knew a recipe to get round my problem but I had a look inside Django to see how it looks through packages.
The problem is caused by line 58 at this link raising an ImportError: http://code.djangoproject.com/browser/django/trunk/django/core/management/__...
Yeah, sorry. You can either use Django, or not use namespaces, or fix Django. :) Django simply doesn't support namespaces in this case. Yet another case of Django being the new Zope, although Zope has fixed that problem since a couple of years, and Zope Products can be namespace packages nowadays (and the special Products directory is now a namespace).
This all is a part Djangos biggest problem: It doesn't play well with non-Django stuff. They are however aware of this problem, and I'm sure they would appreciate help with fixing this particular issue. In open source it's all a matter of available programmer time. :)
That's BS. This discussion is is happening because Django is using buildout, which I think qualifies as "non-Django stuff". Now, when someone is asking about a technical problem using a non-Django tool, they get grief that they're problem is that they don't use non-Django tools. Even if this argument had a shred of reason, it is totally inappropriate to use a response to a technical query as a platform for advocacy, especially negative advocacy. Finally, I am ashamed when I see members of the Zope community bad-mouth other frameworks, Jim -- Jim Fulton
2009/9/20 Jim Fulton
That's BS. This discussion is is happening because Django is using buildout, which I think qualifies as "non-Django stuff".
OK, maybe that was not the right wording.
Even if this argument had a shred of reason, it is totally inappropriate to use a response to a technical query as a platform for advocacy, especially negative advocacy.
Finally, I am ashamed when I see members of the Zope community bad-mouth other frameworks.
I don't think I did. Pointing out a well known problem is not bad-mouthing. Unless you consider calling Django "the new Zope" bad mouthing. I don't. :) -- Lennart Regebro: Python, Zope, Plone, Grok http://regebro.wordpress.com/ +33 661 58 14 64
2009/9/20 Kyle MacFarlane
If they use the package's __path__ attribute, they'll find its contents, whether someone is using pkgutil.extend_path, .pth files, or setuptools. They don't have to support setuptools to support namespace packages, just
2009/9/19 P.J. Eby
pay attention to the __path__ variable that's part of standard Python. I was hoping more if anybody knew a recipe to get round my problem but I had a look inside Django to see how it looks through packages.
The problem is caused by line 58 at this link raising an ImportError:
http://code.djangoproject.com/browser/django/trunk/django/core/management/__...
It doesn't matter what order find_module is called on various paths, it still relies entirely on the order in sys.path. Calling find_module on second_app before first_app will still fail if first_app is the first app on sys.path (which suggests that something has been done wrong even before line 58 or find_module itself doesn't support namespaces?).
Unfortunately I've never dealt with the imp module before. What would I need to do? Import the package (which is actually "path" in this code), get __path__ from it and then do find_module again but with __path__ instead?
I've almost got to the bottom of this by using collective.recipe.omelette and by putting the following in buildout.cfg: [easy_install] zip_ok = 0 But I have one (I hope) remaining problem. When buildout is run the first thing it does is install zc.buildout and setuptools and totally ignores any custom settings when doing so. How can I have setuptools install without being zipped? I've tried "unzip = true" in buildout.cfg but that is ignored too.
On Sun, Sep 20, 2009 at 10:45 AM, Kyle MacFarlane
2009/9/20 Kyle MacFarlane
... But I have one (I hope) remaining problem. When buildout is run
I assume you mean when bootstrapping.
the first thing it does is install zc.buildout and setuptools and totally ignores any custom settings when doing so. How can I have setuptools install without being zipped? I've tried "unzip = true" in buildout.cfg but that is ignored too.
This is a bug. :) I *think* the fix is straightforward. I'll try to get a fix out soon. Jim -- Jim Fulton
participants (4)
-
Jim Fulton
-
Kyle MacFarlane
-
Lennart Regebro
-
P.J. Eby