Python packages - problems, pitfalls.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Sun Nov 4 13:15:35 EST 2001


>>>>> "CG" == Chris Gonnerman <chris.gonnerman at newcenturycomputers.net> writes:

    >> be smart enough to avoid such problems?  Why I consider this a
    >> major problem is that the importing of a sub-package depends on
    >> where its parent package is!!  So if pkg is no longer the root
    >> of the package and say its put inside another BigPkg then to
    >> make pkg's sub packages work you'd have to edit *all* the sub
    >> packages and change every reference to pkg.a to BigPkg.pkg.a.
    >> This is a huge pain.

    CG> Hmm.  I personally can't say that I've ever renested a package
    CG> to a deeper level.  Has anyone else had a problem with this?
    CG> The closest I can think of is converting a group of related
    CG> modules into a package, and that wasn't all that much work.

Well, I believe the SciPy project (http://www.scipy.org) had lots of
trouble dealing with this -- its a pretty huge project.  Also consider
the following case:

I have an application that is shipped as part of a package.  I'd like
the application to run right off the main directory or when the
package is installed.  Also lets add to the problem by saying that the
project is under CVS and its a pain putting everything into another
directory.  Something like this:

   pkg_root/
	__init__.py
	app.py
	# app is the application that is not part of the package
	common_module.py
	setup.py
	common/
		__init__.py 
		foo.py  # more common stuff
	sub/
		__init__.py
		submodule.py
		a.py
	sub1/
		__init__.py
		b.py

pkg_root might either be installed as Package (in site-packages) or
someone may decide to run app.py from within pkg_root.

Also, irrespective of whether people have run into such problems or
not, don't you think it makes sense for modules to be searched the way
I had suggested earlier??  Or is there some serious issue with this.

Thanks.

prabhu

--
Prabhu Ramachandran			  MayaVi Data Visualizer
http://www.aero.iitm.ernet.in/~prabhu     http://mayavi.sf.net

Where there's no emotion, there's no motive for violence.
		-- Spock, "Dagger of the Mind", stardate 2715.1




More information about the Python-list mailing list