[Distutils] Help with easy_install

Martin Manns mmanns at gmx.net
Mon Dec 1 21:58:11 CET 2008


Phillip J. Eby <pje <at> telecommunity.com> writes:
> At 09:24 AM 12/1/2008 +0000, Martin Manns wrote:
> >Phillip J. Eby <pje <at> telecommunity.com> wrote:
> > > From reading your setup script, I don't understand why your package
> > > needs a .pth file of its own, let alone why it's writing it directly
> > > in the setup script.  I would expect it to work correctly if you
> > > simply delete that portion of the setup script.  In fact, it works
> > > for me that way.
> >
> >Without the .pth file, the libraries in the folder pyspread are not found.
> >If I leave it out, the program fails to start (after installation finished
> >successfully).
> 
> You'll need to be more specific about what "fails to start" 
> means.  What specifically happens?  What is the traceback?

OK
I removed all files manually including the egg, removed the wx requirement from
setup.py and installed again:
$ cat setup.py
#!/usr/bin/env python

from distutils.core import setup
from distutils.sysconfig import get_python_lib

setup(name='pyspread',
      version='0.0.10b',
      description='A spreadsheet that accepts a pure python expression in each
cell.',
      license='GPL v3 :: GNU General Public License',
      classifiers=[ 'Development Status :: 3 - Alpha',
                    'Intended Audience :: End Users/Desktop',
      ],
      author='Martin Manns',
      author_email='mmanns at gmx.net',
      url='http://sourceforge.net/projects/pyspread/',
      install_requires=["numpy>=1.1"],
      requires=['numpy (>=1.1)'],
      scripts=['pyspread/pyspread.py'],
      packages=['pyspread'],
      package_data={'pyspread': ['icons/*.png', 'icons/actions/*.png', \
                         'examples/*', \
                         'doc/manual.html', 'README', 'COPYING']},
)
$ su
# easy_install-2.5 pyspread-0.0.10b.zip
Processing pyspread-0.0.10b.zip
Running pyspread-0.0.10b/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-bI0ZtQ/pyspread-0.0.10b/egg-dist-tmp-VNtCCf
zip_safe flag not set; analyzing archive contents...
Adding pyspread 0.0.10b to easy-install.pth file
Installing pyspread.py script to /usr/bin

Installed /usr/lib/python2.5/site-packages/pyspread-0.0.10b-py2.5.egg
Processing dependencies for pyspread==0.0.10b
Finished processing dependencies for pyspread==0.0.10b
# exit
$ pyspread.py 
Traceback (most recent call last):
  File "/usr/bin/pyspread.py", line 5, in <module>
    pkg_resources.run_script('pyspread==0.0.10b', 'pyspread.py')
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 448, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1173, in run_script
    exec script_code in namespace, namespace
  File "/usr/bin/pyspread.py", line 65, in <module>
    
ImportError: No module named _widgets

And indeed there is no sub-folder pyspread in site-packages and therefore no
module _widgets that can be found.

> >And how do I get the pyspread.pth file created?
> 
> You don't.  If your program isn't working without it, it probably 
> means your program isn't doing its imports correctly.
>
> Offhand, my guess is that you're using pyspread.pyspread as a main 
> program, and also trying to import things from the pyspread 
> package.  That won't work correctly, because Python puts the 
> directory containing the __main__ script as the first entry on 
> sys.path -- meaning that when you try to import from the pyspread 
> *package*, you instead wind up importing from the pyspread 
> *script*.  But let's see your traceback to find out what's really going on.

Hmm. Not quite, I guess.
My idea of the directory structure is as follows:
+ Everything but the main script that is in /usr/bin
resides in [...]/site-packages/pyspread
+ The modules are imported directly (without pyspread.[mymodule]
Probably this is a bad idea. However, with the pyspread.pth file in
site-packages, it works.

I just made a deb that has all files in an own directory in /usr/lib/pyspread
and the images etc. in /usr/share/pyspread
Perhaps, this can be done with easy_install, too.

Martin




More information about the Distutils-SIG mailing list