distutils support in Jython
I wanted to play around with Jython, especially because I believe that Web services and dynamic languages should be a nice match. This is actually my first contact with Python, so I got stuck with a pretty simple problem: Most Python packages come with an installation routine based on distutils. Unfortunately, I was unable to install anything this way because distutils is not available with a standard Jython installation.
So I grabbed the distutils source itself, which I was unable to install either - it seems not to run with Jython out of the box.
The following two patches, based on information in the distutils mailing list, did the trick:
I added this to to INSTALL_SCHEMES dictionary:
'java': {
'purelib': '$base',
'platlib': '$base',
'headers': '$base/Include/$dist_name',
'scripts': '$base/Scripts',
'data' : '$base',
},
and then patched file_util.py from
if preserve_times:
os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
if preserve_mode:
os.chmod(dst, S_IMODE(st[ST_MODE]))
to this:
if hasattr(os, 'utime'):
if preserve_times:
os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
if hasattr(os, 'chmod'):
if preserve_mode:
os.chmod(dst, S_IMODE(st[ST_MODE]))
Ugly, probably stupid as hell ... but it worked.
The second blurb can be simplified and possibly more efficient as:
the hasattr will never run if the first is false, and that’s really the important condition.
That said, this isn’t working for me with latest Jython, though I did find that some people are trying to make utime and chmod work with a new javaos.py implementation.