On Fri, Jan 09, 2009 at 03:03:08PM -0600, ray terrill wrote: > I'm using python2.4 to try to package and deliver a custom python script. > I'm unable to import the package. > > My setup.py looks like the following: > from setuptools import setup, find_packages > setup( > name = "randomscript", > version = "1.0", > packages = find_packages(), > )
And where's the rest of the sources? > I'm building the package using the following: > python setup.py bdist_egg Some people say bdist_egg is not a good idea, and suggest using sdists only, unless you're building a package for Windows (or MacOS), and that package contains C extension modules that end-users will have trouble compiling. I am one of those people. > I'm installing the package using the following: > easy_install randomscript-1.0-py2.4.egg > Processing randomscript-1.0-py2.4.egg > Copying randomscript-1.0-py2.4.egg to /usr/lib/python2.4/site-packages > Adding randomscript 1.0 to easy-install.pth file > > Installed /usr/lib/python2.4/site-packages/randomscript-1.0-py2.4.egg > Processing dependencies for randomscript==1.0 > Finished processing dependencies for randomscript==1.0 > > If I attempt to use the script, I get an import error, but I do see the > script listed in my sys.path: > ImportError: No module named randomscript I suspect the .egg is empty (i.e. contains no Python sources and modules). You probably need to specify a path for find_packages(). > Also, if I cd to /usr/lib/python2.4/site-packages/, I see that my egg is > there, but is not a directory (should it be)? > -rw-r--r-- 1 root root 819 2009-01-09 20:06 randomscript-1.0-py2.4.egg It's a zip file, which is often inconvenient (and also slow, as a bonus). You can ask easy_install to unzip it while installing. > Any help would be appreciated. I'm generally very opposed to cargo cult programming, but when dealing with distutils/setuptools, the only way I manage to get something done is to start from a working example, then copy, paste and modify. Here's a simple example of a package that has only one source file in the same directory as setup.py: http://mg.pov.lt/eazysvn/svn/trunk/ The setup.py doesn't use find_packages, but specifies the name of the module in py_modules, and also defines a few entry points to get executable scripts in /usr/bin. Here's a more complicated example of a package, that has a Python package (the naming clash is unfortunate) under src/, with some resource files (*.png, etc.): http://mg.pov.lt/gtimelog/svn/ setup.py specifies the sources via packages, package_dir, and package_data. Marius Gedminas -- For vi emulation of emacs, just type ":sh emacs" (without the quotes).
signature.asc
Description: Digital signature
_______________________________________________ Distutils-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/distutils-sig
