[Checkins] SVN: zc.buildout/branches/help-api/src/zc/buildout/easy_install.py Added Jython support.
Godefroid Chapelle
gotcha at bubblenet.be
Sun Mar 29 17:25:45 EDT 2009
Log message for revision 98544:
Added Jython support.
Signed-off-by: Georgy Berdyshev - ?\208?\147?\208?\181?\208?\190?\209?\128?\208?\179?\208?\184?\208?\185 ?\208?\145?\208?\181?\209?\128?\208?\180?\209?\139?\209?\136?\208?\181?\208?\178 <codingmaster at gmail.com>
Changed:
U zc.buildout/branches/help-api/src/zc/buildout/easy_install.py
-=-
Modified: zc.buildout/branches/help-api/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/help-api/src/zc/buildout/easy_install.py 2009-03-29 21:25:38 UTC (rev 98543)
+++ zc.buildout/branches/help-api/src/zc/buildout/easy_install.py 2009-03-29 21:25:44 UTC (rev 98544)
@@ -50,6 +50,14 @@
url_match = re.compile('[a-z0-9+.-]+://').match
+is_jython = sys.platform.startswith('java')
+
+if is_jython:
+ import subprocess
+ import java.lang.System
+ jython_os_name = (java.lang.System.getProperties()['os.name']).lower()
+
+
setuptools_loc = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('setuptools')
).location
@@ -303,11 +311,21 @@
logger.debug('Running easy_install:\n%s "%s"\npath=%s\n',
self._executable, '" "'.join(args), path)
- args += (dict(os.environ, PYTHONPATH=path), )
+ if is_jython:
+ extra_env = dict(os.environ, PYTHONPATH=path)
+ else:
+ args += (dict(os.environ, PYTHONPATH=path), )
+
sys.stdout.flush() # We want any pending output first
- exit_code = os.spawnle(
- os.P_WAIT, self._executable, _safe_arg (self._executable),
- *args)
+
+ if is_jython:
+ exit_code = subprocess.Popen(
+ [_safe_arg(self._executable)] + list(args),
+ env=extra_env).wait()
+ else:
+ exit_code = os.spawnle(
+ os.P_WAIT, self._executable, _safe_arg (self._executable),
+ *args)
dists = []
env = pkg_resources.Environment(
@@ -863,7 +881,10 @@
if log_level < logging.DEBUG:
logger.debug("in: %r\n%s", directory, ' '.join(args))
- assert os.spawnl(os.P_WAIT, executable, _safe_arg (executable), *args) == 0
+ if is_jython:
+ assert subprocess.Popen([_safe_arg(executable)] + args).wait() == 0
+ else:
+ assert os.spawnl(os.P_WAIT, executable, _safe_arg (executable), *args) == 0
return _copyeggs(tmp3, dest, '.egg-link', undo)
@@ -967,9 +988,14 @@
generated.append(dest)
return generated
-script_template = '''\
-#!%(python)s
+if is_jython and jython_os_name == 'linux':
+ script_header = '#!/usr/bin/env %(python)s'
+else:
+ script_header = '#!%(python)s'
+script_template = script_header + '''\
+
+
import sys
sys.path[0:0] = [
%(path)s,
@@ -1013,8 +1039,9 @@
generated.append(dest)
return generated
-py_script_template = '''\
-#!%(python)s
+py_script_template = script_header + '''\
+
+
import sys
sys.path[0:0] = [
@@ -1135,5 +1162,9 @@
if __debug__:
args.append('-O')
args.extend(['-m', 'py_compile', filepath])
- os.spawnv(os.P_WAIT, sys.executable, args)
-
+
+ if is_jython:
+ subprocess.call([sys.executable, args])
+ else:
+ os.spawnv(os.P_WAIT, sys.executable, args)
+
More information about the Checkins
mailing list