Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r58332:a8952105d742
Date: 2012-10-21 15:13 +0200
http://bitbucket.org/pypy/pypy/changeset/a8952105d742/
Log: hg merge default
diff --git a/pypy/doc/getting-started-dev.rst b/pypy/doc/getting-started-dev.rst
--- a/pypy/doc/getting-started-dev.rst
+++ b/pypy/doc/getting-started-dev.rst
@@ -100,7 +100,7 @@
To translate and run for the CLI you must have the SDK installed: Windows
users need the `.NET Framework SDK`_, while Linux and Mac users
can use Mono_. To translate and run for the JVM you must have a JDK
-installed (at least version 5) and ``java``/``javac`` on your path.
+installed (at least version 6) and ``java``/``javac`` on your path.
A slightly larger example
+++++++++++++++++++++++++
diff --git a/pypy/translator/jvm/genjvm.py b/pypy/translator/jvm/genjvm.py
--- a/pypy/translator/jvm/genjvm.py
+++ b/pypy/translator/jvm/genjvm.py
@@ -2,11 +2,13 @@
Backend for the JVM.
"""
+from __future__ import with_statement
+import os
+import re
+import subprocess
import sys
-import os
import py
-import subprocess
from pypy.tool.udir import udir
from pypy.translator.translator import TranslationContext
from pypy.translator.oosupport.genoo import GenOO
@@ -25,6 +27,8 @@
JVMWeakRefConst
from pypy.translator.jvm.prebuiltnodes import create_interlink_node
+MIN_JAVA_VERSION = '1.6.0'
+
class JvmError(Exception):
""" Indicates an error occurred in JVM backend """
@@ -222,12 +226,35 @@
jvm = GenJvm(tmpdir, t, EntryPoint(main_graph, True, True))
return jvm.generate_source()
+_missing_support_programs = None
+
def detect_missing_support_programs():
- def check(exechelper):
- if py.path.local.sysfind(exechelper) is None:
- py.test.skip("%s is not on your path" % exechelper)
- check(getoption('javac'))
- check(getoption('java'))
+ global _missing_support_programs
+ if _missing_support_programs is not None:
+ if _missing_support_programs:
+ py.test.skip(_missing_support_programs)
+ return
+
+ def missing(msg):
+ global _missing_support_programs
+ _missing_support_programs = msg
+ py.test.skip(msg)
+
+ for cmd in 'javac', 'java':
+ if py.path.local.sysfind(getoption(cmd)) is None:
+ missing("%s is not on your path" % cmd)
+ if not _check_java_version(MIN_JAVA_VERSION):
+ missing('Minimum of Java %s required' % MIN_JAVA_VERSION)
+ _missing_support_programs = False
+
+def _check_java_version(version):
+ """Determine if java meets the specified version"""
+ cmd = [getoption('java'), '-version']
+ with open(os.devnull, 'w') as devnull:
+ stderr = subprocess.Popen(cmd, stdout=devnull,
+ stderr=subprocess.PIPE).communicate()[1]
+ search = re.search('[\.0-9]+', stderr)
+ return search and search.group() >= version
class GenJvm(GenOO):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit