[SciPy-dev] issues with scipy and eggs

Andrew Straw strawman at astraw.com
Sat Dec 10 15:51:30 CST 2005


Robert Kern wrote:

>Andrew Straw wrote:
>
>>Issue 2 - how to use full scipy from an egg?
>>============================================
>>
>>I can't figure out the incantation for using scipy (full) from an egg. 
>>AFAICT this should just work with "import scipy" because both the
>>scipy_core and scipy egg are in my easy-install.pth file.  But doing
>>"import scipy" only gets me scipy core.  Furthermore, Robert Kern
>>suggested the following, which does apparently find the full scipy egg,
>>but it doesn't  load full scipy.
>>
>
>No, you need to add the following to the scipy/__init__.py in both scipy_core
>and full scipy:
>
>try:
>    __import__('pkg_resources').declare_namespace(__name__)
>except ImportError:
>    pass
>
>That way, pkg_resources knows to keep looking for the other half.
>
I'm attempting to do this, but it doesn't work.  If I add these lines to
core/scipy/__init__.py, scipy core on its own works fine.  However,
after installing an un-modified full scipy, I get the following error:

Python 2.4.1 (#2, May  6 2005, 11:22:24)
[GCC 3.3.6 (Debian 1:3.3.6-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy_core-0.8.2.1625-py2.4-linux-x86_64.egg/scipy/__init__.py:24:
UserWarning: Module scipy was already imported from
/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy_core-0.8.2.1625-py2.4-linux-x86_64.egg/scipy/__init__.pyc,
but
/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy-0.4.3.1482-py2.4-linux-x86_64.egg
is being added to sys.path
  tmp_pkg_resources = __import__('pkg_resources')
Importing test to scipy
Importing base to scipy
Importing basic to scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy_core-0.8.2.1625-py2.4-linux-x86_64.egg/scipy/__init__.py",
line 70, in ?
    __doc__ += PackageImport().import_packages()
  File
"/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy_core-0.8.2.1625-py2.4-linux-x86_64.egg/scipy/_import_tools.py",
line 147, in import_packages
    return self._format_titles(titles)
  File
"/.sharehome/astraw/py24-amd64/lib/python2.4/site-packages/scipy_core-0.8.2.1625-py2.4-linux-x86_64.egg/scipy/_import_tools.py",
line 90, in _format_titles
    max_length = max(lengths)
ValueError: max() arg is an empty sequence

If I attempt to create an __init__.py in scipy/build/scipy/__init__.py
before doing "python setup.py bdist_egg" with those lines, I get the
same error.  (There doesn't seem to be a scipy/__init__.py in full scipy.)

>
>Also, if both eggs are already on sys.path, then pkg_resources.require() isn't
>necessary.
>
Yes, I'm just going by your previous email which suggested using
pkg_resources.require().  All my other eggs load fine without this, so I
figured this might have worked around some scipy funkiness.

>Additionally, if they weren't the lone pkg_resources.require('SciPy')
>wouldn't find scipy_core.
>
I have no idea what you mean here.

Having two packages that use the "scipy" namespace seems to be at the
root of the issue here. (Hence the UserWarning above.) Do we need to do
something relating to setuptools' namespace packages?

Cheers!
Andrew





More information about the Scipy-dev mailing list