本文整理汇总了Python中mx.classpath函数的典型用法代码示例。如果您正苦于以下问题:Python classpath函数的具体用法?Python classpath怎么用?Python classpath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了classpath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _unittest_config_participant
def _unittest_config_participant(config):
vmArgs, mainClass, mainClassArgs = config
cpIndex, cp = mx.find_classpath_arg(vmArgs)
if cp:
cp = _uniqify(cp.split(os.pathsep))
if isJDK8:
# Remove entries from class path that are in Graal or on the boot class path
redundantClasspathEntries = set()
for dist in [entry.dist() for entry in _jvmci_classpath]:
redundantClasspathEntries.update((d.output_dir() for d in dist.archived_deps() if d.isJavaProject()))
redundantClasspathEntries.add(dist.path)
cp = os.pathsep.join([e for e in cp if e not in redundantClasspathEntries])
vmArgs[cpIndex] = cp
else:
redundantClasspathEntries = set()
for dist in [entry.dist() for entry in _jvmci_classpath] + _bootclasspath_appends:
redundantClasspathEntries.update(mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep))
redundantClasspathEntries.update(mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep))
if hasattr(dist, 'overlaps'):
for o in dist.overlaps:
path = mx.distribution(o).classpath_repr()
if path:
redundantClasspathEntries.add(path)
# Remove entries from the class path that are in the deployed modules
cp = [classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries]
vmArgs[cpIndex] = os.pathsep.join(cp)
if isJDK8:
# Run the VM in a mode where application/test classes can
# access JVMCI loaded classes.
vmArgs.append('-XX:-UseJVMCIClassLoader')
return (vmArgs, mainClass, mainClassArgs)
示例2: _path_args
def _path_args(depNames=None):
"""
Gets the VM args for putting the dependencies named in `depNames` on the
class path and module path (if running on JDK9 or later).
:param names: a Dependency, str or list containing Dependency/str objects. If None,
then all registered dependencies are used.
"""
jdk = mx.get_jdk()
if jdk.javaCompliance >= '1.9':
modules = [as_java_module(dist, jdk) for dist in _suite.dists if get_java_module_info(dist)]
if modules:
# Partition resources between the class path and module path
modulepath = []
classpath = []
cpEntryToModule = {m.dist.path : m for m in modules}
for e in mx.classpath(depNames).split(os.pathsep):
if cpEntryToModule.has_key(e):
modulepath.append(cpEntryToModule[e].jarpath)
else:
classpath.append(e)
# The Truffle modules must be eagerly loaded as they could be referenced from
# the main class hence the --add-modules argument
return ['--add-modules=' + ','.join([m.name for m in modules]), '--module-path=' + os.pathsep.join(modulepath), '-cp', os.pathsep.join(classpath)]
return ['-cp', mx.classpath(depNames)]
示例3: _unittest_config_participant
def _unittest_config_participant(config):
"""modifies the classpath to use the Sulong distribution jars instead of the classfiles to enable the use of Java's ServiceLoader"""
(vmArgs, mainClass, mainClassArgs) = config
cpIndex, _ = mx.find_classpath_arg(vmArgs)
junitCp = mx.classpath("com.oracle.mxtool.junit")
sulongCp = ':'.join([mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci')) for distr in sulongDistributions])
vmArgs[cpIndex] = junitCp + ":" + sulongCp
return (vmArgs, mainClass, mainClassArgs)
示例4: unittest_use_distribution_jars
def unittest_use_distribution_jars(config):
"""use the distribution jars instead of the class files"""
vmArgs, mainClass, mainClassArgs = config
cpIndex, _ = mx.find_classpath_arg(vmArgs)
junitCP = [mx.classpath("com.oracle.mxtool.junit")]
rubyCP = [mx.classpath(mx.distribution(distr)) for distr in rubyDists]
vmArgs[cpIndex] = ":".join(junitCP + rubyCP)
return (vmArgs, mainClass, mainClassArgs)
示例5: getPythonBenchmarksProfiling
def getPythonBenchmarksProfiling(vm, profile_option=None):
success, error, matcher = getSuccessErrorMatcher()
benchmarks = pythonProfilerBenchmarks
tests = []
for benchmark, arg in benchmarks.iteritems():
script = "edu.uci.python.benchmark/src/benchmarks/" + benchmark + ".py"
if (profile_option is not None):
cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg, profile_option, "-sort"]
else :
cmd = ['-cp', mx.classpath("edu.uci.python.shell"), "edu.uci.python.shell.Shell", script, arg]
vmOpts = ['-Xms2g', '-Xmx2g']
tests.append(ZippyTest("Python-" + benchmark, cmd, successREs=[success], failureREs=[error], scoreMatchers=[matcher], vmOpts=vmOpts))
return tests
示例6: jaotc_test
def jaotc_test(args):
"""run (acceptance) tests for the AOT compiler (jaotc)"""
all_tests = ['HelloWorld', 'java.base', 'javac']
parser = ArgumentParser(prog='mx jaotc-test')
parser.add_argument("--list", default=None, action="store_true", help="Print the list of available jaotc tests.")
parser.add_argument('tests', help='tests to run (omit to run all tests)', nargs=ZERO_OR_MORE)
args = parser.parse_args(args)
if args.list:
print "The following jaotc tests are available:\n"
for name in all_tests:
print " " + name
return
tests = args.tests or all_tests
for test in tests:
mx.log('Testing `{}`'.format(test))
if test == 'HelloWorld':
test_class(
classpath=mx.classpath('JAOTC_TEST'),
main_class='jdk.tools.jaotc.test.HelloWorld'
)
elif test == 'javac':
test_javac('jdk.tools.jaotc')
elif test == 'java.base':
test_modules(
classpath=mx.project('jdk.tools.jaotc.test').output_dir(),
main_class='jdk.tools.jaotc.test.HelloWorld',
modules=['java.base']
)
else:
mx.abort('Unknown jaotc test: {}'.format(test))
示例7: do_run_r
def do_run_r(args, command, extraVmArgs=None, jdk=None, nonZeroIsFatal=True):
'''
This is the basic function that runs a FastR process, where args have already been parsed.
Args:
args: a list of command arguments
command: e.g. 'R', implicitly defines the entry class (can be None for AOT)
extraVmArgs: additional vm arguments
jdk: jdk (an mx.JDKConfig instance) to use
nonZeroIsFatal: whether to terminate the execution run fails
By default a non-zero return code will cause an mx.abort, unless nonZeroIsFatal=False
The assumption is that the VM is already built and available.
'''
setREnvironment()
if not jdk:
jdk = get_default_jdk()
vmArgs = ['-cp', mx.classpath(_r_command_project)]
vmArgs += _graal_options()
if extraVmArgs is None or not '-da' in extraVmArgs:
# unless explicitly disabled we enable assertion checking
vmArgs += ['-ea', '-esa']
if extraVmArgs:
vmArgs += extraVmArgs
vmArgs = _sanitize_vmArgs(jdk, vmArgs)
if command:
vmArgs.append(_command_class_dict[command.lower()])
return mx.run_java(vmArgs + args, nonZeroIsFatal=nonZeroIsFatal, jdk=jdk)
示例8: rbdiag
def rbdiag(args):
'''Diagnoses FastR builtins
-v Verbose output including the list of unimplemented specializations
-n Ignore RNull as an argument type
-m Ignore RMissing as an argument type
--sweep Performs the 'chimney-sweeping'. The sample combination selection method is determined automatically.
--sweep-lite Performs the 'chimney-sweeping'. The diagonal sample selection method is used.
--sweep-total Performs the 'chimney-sweeping'. The total sample selection method is used.
If no builtin is specified, all registered builtins are diagnosed.
Examples:
mx rbdiag
mx rbdiag colSums colMeans -v
mx rbdiag scan -m -n
mx rbdiag colSums --sweep
'''
cp = mx.classpath('com.oracle.truffle.r.nodes.test')
setREnvironment()
os.environ["FASTR_TESTGEN_GNUR"] = "internal"
# this should work for Linux and Mac:
os.environ["TZDIR"] = "/usr/share/zoneinfo/"
mx.run_java(['-cp', cp, 'com.oracle.truffle.r.nodes.test.RBuiltinDiagnostics'] + args)
示例9: ruby_command
def ruby_command(args):
"""runs Ruby"""
java_home = os.getenv('JAVA_HOME', '/usr')
java = os.getenv('JAVACMD', java_home + '/bin/java')
argv0 = java
vmArgs, rubyArgs, user_classpath, print_command = extractArguments(args)
classpath = mx.classpath(['TRUFFLE_API', 'RUBY']).split(':')
truffle_api, classpath = classpath[0], classpath[1:]
assert os.path.basename(truffle_api) == "truffle-api.jar"
# Give precedence to graal classpath and VM options
classpath = user_classpath + classpath
vmArgs = vmArgs + [
# '-Xss2048k',
'-Xbootclasspath/a:' + truffle_api,
'-cp', ':'.join(classpath),
'org.jruby.truffle.Main'
]
allArgs = vmArgs + ['-X+T'] + rubyArgs
env = setup_jruby_home()
if print_command:
if mx.get_opts().verbose:
log('Environment variables:')
for key in sorted(env.keys()):
log(key + '=' + env[key])
log(java + ' ' + ' '.join(map(pipes.quote, allArgs)))
return os.execve(java, [argv0] + allArgs, env)
示例10: _find_classes_by_annotated_methods
def _find_classes_by_annotated_methods(annotations, suite):
"""
Scan distributions from binary suite dependencies for classes contain at least one method
with an annotation from 'annotations' and return a dictionary from fully qualified class
names to the distribution containing the class.
"""
binarySuiteDists = [d for d in mx.dependencies(opt_limit_to_suite=True) if d.isJARDistribution() and
isinstance(d.suite, mx.BinarySuite) and (not suite or suite == d.suite)]
if len(binarySuiteDists) != 0:
# Ensure Java support class is built
mx.build(['--dependencies', 'com.oracle.mxtool.junit'])
# Create map from jar file to the binary suite distribution defining it
jars = {d.classpath_repr() : d for d in binarySuiteDists}
cp = mx.classpath(['com.oracle.mxtool.junit'] + [d.name for d in binarySuiteDists])
out = mx.OutputCapture()
mx.run_java(['-cp', cp] + ['com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] + annotations + jars.keys(), out=out)
candidates = {}
for line in out.data.strip().split('\n'):
name, jar = line.split(' ')
# Record class name to the binary suite distribution containing it
candidates[name] = jars[jar]
return candidates
return {}
示例11: testgen
def testgen(args):
'''generate the expected output for unit tests, and All/Failing test classes'''
parser = ArgumentParser(prog='r testgen')
parser.add_argument('--tests', action='store', default=_all_unit_tests(), help='pattern to match test classes')
args = parser.parse_args(args)
# check we are in the home directory
if os.getcwd() != _fastr_suite.dir:
mx.abort('must run rtestgen from FastR home directory')
# check the version of GnuR against FastR
try:
fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber'])
gnur_version = subprocess.check_output(['R', '--version'])
if not gnur_version.startswith(fastr_version):
mx.abort('R version is incompatible with FastR, please update to ' + fastr_version)
except subprocess.CalledProcessError:
mx.abort('RVersionNumber.main failed')
# clean the test project to invoke the test analyzer AP
testOnly = ['--projects', 'com.oracle.truffle.r.test']
mx.clean(['--no-dist', ] + testOnly)
mx.build(testOnly)
# now just invoke junit with the appropriate options
mx.log("generating expected output for packages: ")
for pkg in args.tests.split(','):
mx.log(" " + str(pkg))
junit(['--tests', args.tests, '--gen-expected-output', '--gen-expected-quiet'])
示例12: _unittest
def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False, suite=None):
testfile = os.environ.get('MX_TESTFILE', None)
if testfile is None:
(_, testfile) = tempfile.mkstemp(".testclasses", "mxtool")
os.close(_)
mainClass = 'com.oracle.mxtool.junit.MxJUnitWrapper'
if not exists(join(mx.project('com.oracle.mxtool.junit').output_dir(), mainClass.replace('.', os.sep) + '.class')):
mx.build(['--only', 'com.oracle.mxtool.junit'])
coreCp = mx.classpath(['com.oracle.mxtool.junit'])
coreArgs = []
if verbose:
coreArgs.append('-JUnitVerbose')
if fail_fast:
coreArgs.append('-JUnitFailFast')
if enable_timing:
coreArgs.append('-JUnitEnableTiming')
if color:
coreArgs.append('-JUnitColor')
if eager_stacktrace:
coreArgs.append('-JUnitEagerStackTrace')
if gc_after_test:
coreArgs.append('-JUnitGCAfterTest')
def harness(unittestCp, vmLauncher, vmArgs):
prefixArgs = ['-esa', '-ea']
if gc_after_test:
prefixArgs.append('-XX:-DisableExplicitGC')
with open(testfile) as fp:
testclasses = [l.rstrip() for l in fp.readlines()]
cp = prefixCp + coreCp + os.pathsep + unittestCp
# suppress menubar and dock when running on Mac
vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs + ['-cp', mx._separatedCygpathU2W(cp)]
# Execute Junit directly when one test is being run. This simplifies
# replaying the VM execution in a native debugger (e.g., gdb).
mainClassArgs = coreArgs + (testclasses if len(testclasses) == 1 else ['@' + mx._cygpathU2W(testfile)])
config = (vmArgs, mainClass, mainClassArgs)
for p in _config_participants:
config = p(config)
vmLauncher.launcher(*config)
vmLauncher = _vm_launcher
if vmLauncher is None:
jdk = mx.get_jdk()
def _run_vm(vmArgs, mainClass, mainClassArgs):
mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk)
vmLauncher = _VMLauncher('default VM launcher', _run_vm, jdk)
try:
_run_tests(args, harness, vmLauncher, annotations, testfile, blacklist, whitelist, regex, mx.suite(suite) if suite else None)
finally:
if os.environ.get('MX_TESTFILE') is None:
os.remove(testfile)
示例13: microbench
def microbench(args):
"""run JMH microbenchmark projects"""
parser = ArgumentParser(
prog="mx microbench",
description=microbench.__doc__,
usage="%(prog)s [command options|VM options] [-- [JMH options]]",
)
parser.add_argument("--jar", help="Explicitly specify micro-benchmark location")
known_args, args = parser.parse_known_args(args)
vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True)
if JVMCI_VERSION < 9:
if isJVMCIEnabled(get_vm()) and "-XX:-UseJVMCIClassLoader" not in vmArgs:
vmArgs = ["-XX:-UseJVMCIClassLoader"] + vmArgs
# look for -f in JMH arguments
forking = True
for i in range(len(jmhArgs)):
arg = jmhArgs[i]
if arg.startswith("-f"):
if arg == "-f" and (i + 1) < len(jmhArgs):
arg += jmhArgs[i + 1]
try:
if int(arg[2:]) == 0:
forking = False
except ValueError:
pass
if known_args.jar:
# use the specified jar
args = ["-jar", known_args.jar]
if not forking:
args += vmArgs
else:
# find all projects with a direct JMH dependency
jmhProjects = []
for p in mx.projects_opt_limit_to_suites():
if "JMH" in [x.name for x in p.deps]:
jmhProjects.append(p.name)
cp = mx.classpath(jmhProjects)
# execute JMH runner
args = ["-cp", cp]
if not forking:
args += vmArgs
args += ["org.openjdk.jmh.Main"]
if forking:
jdk = get_jvmci_jdk()
jvm = get_vm()
def quoteSpace(s):
if " " in s:
return '"' + s + '"'
return s
forkedVmArgs = map(quoteSpace, jdk.parseVmArgs(vmArgs))
args += ["--jvmArgsPrepend", " ".join(["-" + jvm] + forkedVmArgs)]
run_vm(args + jmhArgs)
示例14: sldebug
def sldebug(args):
"""run a simple command line debugger for the Simple Language"""
vmArgs, slArgs = mx.extract_VM_args(args, useDoubleDash=True)
mx.run_java(
vmArgs
+ ["-cp", mx.classpath("com.oracle.truffle.sl.tools"), "com.oracle.truffle.sl.tools.debug.SLREPL"]
+ slArgs
)
示例15: view
def view(args):
"""browse the boot image under the Inspector
Browse a Maxine boot image under the Inspector.
Use "mx view -help" to see what the Inspector options are."""
mx.run_java(['-cp', mx.classpath(), 'com.sun.max.ins.MaxineInspector', '-vmdir=' + _vmdir, '-mode=image'] + args)