How to distribute code with required modules?
Roy Smith
roy at panix.com
Sat Feb 2 10:29:38 EST 2002
I work in a shop that uses a lot of perl for internal tools. I've been
writing stuff (again, internal tools) in python, and trying to figure out a
way to get the language to be more accepted. Yesterday, I hit upon a
stumbling block.
The way we distribute tools is we just check them into a tools CVS module.
Everybody does "cvs update" on a regular basis, and gets any new tools that
have been added to the repository. I've written a lot of python classes
for handling the types of data files we work with. All of my tools depend
on some combination of those classes. I created a subdirectory of tools
called pylib, and check all my class modules into there. Then I set by
PYTHONLIB environment variable to "$HOME/sandbox/src/tools/pylib".
So, here's the problem. Somebody goes to run one of my tools, and it can't
find my classes. I explain to the guy that he just needs to set PYTHONPATH
and all will be well. I get a bit of pushback because none of his perl
tools require you to set a PERLLIB" variable; he just has code which looks
at $0, chops off the last component (leaving the directory from which the
script was run), and then appends the name of the module he wants:
if ($0 =~ m/(.*\/)/) {
$rundir = $1;
}
require "$rundir/module.pm";
He thinks my python scrips should do something similar (which would
certainly be possible). I'm trying to convince him that it would be very
un-pythonic to do it that way.
Any thoughts?
More information about the Python-list
mailing list