def execute(self): print "Build operating on target: %s" % self.target executor = PythonChroot(self.target, self.root_dir) launcher = PythonLauncher(executor.dump().path()) binary = None if isinstance(self.target, PythonBinary): binary = executor.path() launcher.run(binary=binary, args=list(self.args))
def _run_python_test(self, target): chroot = PythonChroot(target, self.root_dir) launcher = PythonLauncher(chroot.dump().path()) extra_deps = PythonTestBuilder.get_pytest_eggs(self.root_dir) test_args = ['-m', 'pytest'] test_args.extend(PythonTestBuilder.generate_junit_args(target)) test_args.extend(self.args) # Pass any extra args in to pytest. sources = [os.path.join(target.target_base, source) for source in target.sources] return launcher.run(interpreter_args=test_args, args=list(sources), extra_deps=extra_deps, kill_orphans=True, )
def _run_python_test(self, target): chroot = PythonChroot(target, self.root_dir) chroot.add_req(pkg_resources.Requirement.parse('pytest')) chroot.add_req(pkg_resources.Requirement.parse('unittest2')) launcher = PythonLauncher(chroot.dump().path()) test_args = ['-m', 'pytest'] test_args.extend(PythonTestBuilder.generate_junit_args(target)) test_args.extend(self.args) # Pass any extra args in to pytest. sources = [os.path.join(target.target_base, source) for source in target.sources] return launcher.run(interpreter_args=test_args, args=list(sources), kill_orphans=True, )
def execute(self): print("Build operating on target: %s %s" % (self.target, 'Extra targets: %s' % ' '.join(map(str, self.extra_targets)) if self.extra_targets else '')) executor = PythonChroot(self.target, self.root_dir, extra_targets=self.extra_targets) if self.options.pex: # TODO(wickman) This overlaps with commands/build.py and should be factored out, perhaps # in pants.new. pex_name = os.path.join(self.root_dir, 'dist', '%s.pex' % self.target.name) PexBuilder(executor.dump()).write(pex_name) print('Wrote %s' % pex_name) else: launcher = PythonLauncher(executor.dump().path()) binary = None if isinstance(self.target, PythonBinary): binary = executor.path() launcher.run(binary=binary, args=list(self.args))
def _run_lint(self, target, args): chroot = PythonChroot(target, self.root_dir) launcher = PythonLauncher(chroot.dump().path()) interpreter_args = ['-m', 'pylint.lint', '--rcfile=%s' % os.path.join(self.root_dir, 'build-support', 'pylint', 'pylint.rc')] if args: interpreter_args.extend(args) sources = OrderedSet([]) if not isinstance(target, PythonEgg): target.walk(lambda trg: sources.update( trg.sources if hasattr(trg, 'sources') and trg.sources is not None else [])) launcher.run( interpreter_args=interpreter_args, args=list(sources), extra_deps=sys.path, # TODO(wickman) Extract only the pylint dependencies from sys.path with_chroot=True)
def test_non_zipsafe_egg_dir(self): chroot = create_eggdrop_chroot(PythonChrootEggsTest.NOT_ZIPSAFE_EGG_DIR) launcher = PythonLauncher(chroot.dump().path()) assert launcher.run() == 0
def test_zipsafe_egg(self): chroot = create_eggdrop_chroot(PythonChrootEggsTest.ZIPSAFE_EGG) launcher = PythonLauncher(chroot.dump().path()) assert launcher.run() == 0