468,511 Members | 1,531 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,511 developers. It's quick & easy.

Libraries in python

Hy people, I'm new in python and comming from JAVA.

Something I really like in java is the easy way to add a library to the
project. Just put the jar file in the folder ( WEB-INF/lib ) and
doesn't need to restart the server ( tomcat ).

Can I do some like using python - I'm using apache mod_python?

thanks a lot

Sep 2 '06 #1
3 1742
Hy people, I'm new in python and comming from JAVA.
>
Something I really like in java is the easy way to add a library to the
project. Just put the jar file in the folder ( WEB-INF/lib ) and
doesn't need to restart the server ( tomcat ).

Can I do some like using python - I'm using apache mod_python?
Not sure what you are after. If you configured apache to invoke
mod_python on a location basis (given directory and subdirectories of
that for example) then you can certainly drop any python module there
and use it from any other python code from that directory without
restarting apache.
Sep 2 '06 #2
ed**********@gmail.com wrote:
Hy people, I'm new in python and comming from JAVA.

Something I really like in java is the easy way to add a library to the
project. Just put the jar file in the folder ( WEB-INF/lib ) and
doesn't need to restart the server ( tomcat ).

Can I do some like using python - I'm using apache mod_python?
I know exactly what you mean because I had the same question when I
came to Python from Java. What you're looking for is Python "eggs".
Unfortunately, they're a fairly new addition to the Python ecosystem
and they're not as nice/simple to use as jars. Here are a few of their
shortcomings:

1. not nearly all of the libraries that you may want to use are
distributed as eggs, so you may need to package them yourself, which
can be a pain. To be fair, this is not a shortcoming of eggs directly,
but rather a disadvantage of new technology--it's not ubiquitous yet.

2. you have to put them in the source root directory of the project so
they can be imported in all packages in the project. This seems to
clutter things up for me, and I'd rather have a project-local lib
directory in which to put them (I know that's possible with sys.path
hacks, but that's a hack, this should be standardized).

3. eggs only work well for python-only packages. In other words if the
library includes platform-specific binaries or other non-python-code
files then the egg must be unpacked for it to work. I really hate this
one because it means all those unpackaged files must be checked into
source control rather than just a single library archive file.

4. the seemingly "standard" place to deploy eggs is in the global
site-packages directory of your Python installation. That's terrible
because it makes it a pain to use different versions of a given package
in different projects. Yes, you can use the "setuptools.requires()"
function, but I want to deploy my apps without requiring those who
install it to download lots of dependencies to get it running (not to
mention I just want to use Python's standard "import", not some
non-standard "requires()" function). And yes, I know "requires()" is
supposed to automatically handle the dependencies too, but that just
seems too error prone because it makes too many assumptions about
resource availablitiy... all I want to do is bundle the library when I
deploy (preferably in the form of a single file).

That's my $0.02 on Python packaging and library dependencies. In my
opinion it's one of the few things that Java got right that Python
didn't.

~ Daniel

Sep 2 '06 #3
That's my $0.02 on Python packaging and library dependencies. In my
opinion it's one of the few things that Java got right that Python
didn't.
Yeah, sure. Hunting down a subtle class loading bug because of e.g.
different xml-api versions in your classpath in just a few hours is a
thing java certainly "got right".

Additionally, you refuse to "hack" around with sys.path, but the concept
of CLASSPATH that you have to carefully compose in the first place
appeals to you.

There is no standard way of versioned library access anywhere in java -
so while setuptools might not be perfect, they at least offer _something_.

And the fact that machine code containing eggs are an annoyance to you
is perfectly met by the need of java to have JNI dependant .so/.dll
files being part of the LD_LIBRARY_PATH (and whatever is needed on
windows, I presume PATH)

Just because every nitwit in java is accustomed to meddle with
classpaths and thus the application servers do something like adding
WEB-INF/lib to the classpath (a thing that you refer to as hacking in
python) does not mean its system is in any way superior to pythons.

Diez

Sep 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Robert Ferrell | last post: by
1 post views Thread by Laughlin, Joseph V | last post: by
2 posts views Thread by ACB | last post: by
1 post views Thread by Bo Peng | last post: by
6 posts views Thread by Bill Spotz | last post: by
2 posts views Thread by Ognjen Bezanov | last post: by
85 posts views Thread by g | last post: by
reply views Thread by abarun22 | last post: by
4 posts views Thread by stuntgoat | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.