Пример #1
0
    def execute(self):
        (accept_predicate,
         reject_predicate) = Target.lang_discriminator('java')
        targets = self.require_homogeneous_targets(accept_predicate,
                                                   reject_predicate)
        if targets:
            tools_classpath = self.tool_classpath(self._bootstrap_key)
            self.context.release_lock()
            with preserve_stty_settings():
                exclusives_classpath = self.get_base_classpath_for_target(
                    targets[0])
                classpath = self.classpath(
                    tools_classpath,
                    confs=self.confs,
                    exclusives_classpath=exclusives_classpath)

                print('')  # Start REPL output on a new line.
                try:
                    # NOTE: We execute with no workunit, as capturing REPL output makes it very sluggish.
                    execute_java(classpath=classpath,
                                 main=self.main,
                                 jvm_options=self.jvm_options,
                                 args=self.args)
                except KeyboardInterrupt:
                    # TODO(John Sirois): Confirm with Steve Gury that finally does not work on mac and an
                    # explicit catch of KeyboardInterrupt is required.
                    pass
Пример #2
0
  def execute(self, **pex_run_kwargs):
    (accept_predicate, reject_predicate) = Target.lang_discriminator('python')
    targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
    if targets:
      # We can't throw if the target isn't a python target, because perhaps we were called on a
      # JVM target, in which case we have to no-op and let scala repl do its thing.
      # TODO(benjy): Some more elegant way to coordinate how tasks claim targets.
      interpreter = self.select_interpreter_for_targets(targets)

      extra_requirements = []
      if self.get_options().ipython:
        entry_point = self.get_options().ipython_entry_point
        for req in self.get_options().ipython_requirements:
          extra_requirements.append(PythonRequirement(req))
      else:
        entry_point = 'code:interact'

      pex_info = PexInfo.default()
      pex_info.entry_point = entry_point
      with self.temporary_chroot(interpreter=interpreter,
                                 pex_info=pex_info,
                                 targets=targets,
                                 platforms=None,
                                 extra_requirements=extra_requirements) as chroot:
        pex = chroot.pex()
        self.context.release_lock()
        with stty_utils.preserve_stty_settings():
          with self.context.new_workunit(name='run', labels=[WorkUnit.RUN]):
            po = pex.run(blocking=False, **pex_run_kwargs)
            try:
              return po.wait()
            except KeyboardInterrupt:
              pass
Пример #3
0
  def execute(self):
    (accept_predicate, reject_predicate) = Target.lang_discriminator('java')
    targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
    if targets:
      tools_classpath = self.tool_classpath('scala-repl')
      self.context.release_lock()
      with preserve_stty_settings():
        classpath = self.classpath(targets, cp=tools_classpath)

        # The scala repl requires -Dscala.usejavacp=true since Scala 2.8 when launching in the way
        # we do here (not passing -classpath as a program arg to scala.tools.nsc.MainGenericRunner).
        jvm_options = self.jvm_options
        if not any(opt.startswith('-Dscala.usejavacp=') for opt in jvm_options):
          jvm_options.append('-Dscala.usejavacp=true')

        print('')  # Start REPL output on a new line.
        try:
          # NOTE: We execute with no workunit, as capturing REPL output makes it very sluggish.
          DistributionLocator.cached().execute_java(classpath=classpath,
                                                    main=self.get_options().main,
                                                    jvm_options=jvm_options,
                                                    args=self.args)
        except KeyboardInterrupt:
          # TODO(John Sirois): Confirm with Steve Gury that finally does not work on mac and an
          # explicit catch of KeyboardInterrupt is required.
          pass
Пример #4
0
    def execute(self):
        (accept_predicate,
         reject_predicate) = Target.lang_discriminator('java')
        targets = self.require_homogeneous_targets(accept_predicate,
                                                   reject_predicate)
        if targets:
            tools_classpath = self.tool_classpath('scala-repl')
            self.context.release_lock()
            with preserve_stty_settings():
                classpath = self.classpath(targets, cp=tools_classpath)

                # The scala repl requires -Dscala.usejavacp=true since Scala 2.8 when launching in the way
                # we do here (not passing -classpath as a program arg to scala.tools.nsc.MainGenericRunner).
                jvm_options = self.jvm_options
                if not any(
                        opt.startswith('-Dscala.usejavacp=')
                        for opt in jvm_options):
                    jvm_options.append('-Dscala.usejavacp=true')

                print('')  # Start REPL output on a new line.
                try:
                    # NOTE: We execute with no workunit, as capturing REPL output makes it very sluggish.
                    execute_java(classpath=classpath,
                                 main=self.get_options().main,
                                 jvm_options=jvm_options,
                                 args=self.args)
                except KeyboardInterrupt:
                    # TODO(John Sirois): Confirm with Steve Gury that finally does not work on mac and an
                    # explicit catch of KeyboardInterrupt is required.
                    pass
Пример #5
0
  def execute(self, **pex_run_kwargs):
    (accept_predicate, reject_predicate) = Target.lang_discriminator('python')
    targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
    if targets:
      # We can't throw if the target isn't a python target, because perhaps we were called on a
      # JVM target, in which case we have to no-op and let scala repl do its thing.
      # TODO(benjy): Some more elegant way to coordinate how tasks claim targets.
      interpreter = self.select_interpreter_for_targets(targets)

      extra_requirements = []
      if self.get_options().ipython:
        entry_point = self.get_options().ipython_entry_point
        for req in self.get_options().ipython_requirements:
          extra_requirements.append(PythonRequirement(req))
      else:
        entry_point = 'code:interact'

      pex_info = PexInfo.default()
      pex_info.entry_point = entry_point
      with self.cached_chroot(interpreter=interpreter,
                              pex_info=pex_info,
                              targets=targets,
                              platforms=None,
                              extra_requirements=extra_requirements) as chroot:
        pex = chroot.pex()
        self.context.release_lock()
        with stty_utils.preserve_stty_settings():
          with self.context.new_workunit(name='run', labels=[WorkUnitLabel.RUN]):
            po = pex.run(blocking=False, **pex_run_kwargs)
            try:
              return po.wait()
            except KeyboardInterrupt:
              pass
Пример #6
0
    def execute(self):
        (accept_predicate,
         reject_predicate) = Target.lang_discriminator('python')
        targets = self.require_homogeneous_targets(accept_predicate,
                                                   reject_predicate)
        if targets:
            # We can't throw if the target isn't a python target, because perhaps we were called on a
            # JVM target, in which case we have to no-op and let scala repl do its thing.
            # TODO(benjy): Some more elegant way to coordinate how tasks claim targets.
            interpreter = self.select_interpreter_for_targets(targets)

            extra_requirements = []
            if self.context.options.python_repl_ipython:
                entry_point = self.context.config.get(
                    'python-ipython',
                    'entry_point',
                    default='IPython:start_ipython')
                ipython_requirements = self.context.config.getlist(
                    'python-ipython',
                    'requirements',
                    default=['ipython==1.0.0'])
                for req in ipython_requirements:
                    extra_requirements.append(PythonRequirement(req))
            else:
                entry_point = 'code:interact'

            with self.temporary_pex_builder(
                    interpreter=interpreter) as builder:
                builder.set_entry_point(entry_point)
                chroot = PythonChroot(targets=targets,
                                      extra_requirements=extra_requirements,
                                      builder=builder,
                                      interpreter=interpreter,
                                      conn_timeout=self.conn_timeout)

                chroot.dump()
                builder.freeze()
                pex = PEX(builder.path(), interpreter=interpreter)
                self.context.lock.release()
                with stty_utils.preserve_stty_settings():
                    with self.context.new_workunit(name='run',
                                                   labels=[WorkUnit.RUN]):
                        po = pex.run(blocking=False)
                        try:
                            return po.wait()
                        except KeyboardInterrupt:
                            pass
Пример #7
0
    def execute(self):
        (accept_predicate, reject_predicate) = Target.lang_discriminator("java")
        targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
        if targets:
            tools_classpath = self.tool_classpath(self._bootstrap_key)
            self.context.lock.release()
            with preserve_stty_settings():
                exclusives_classpath = self.get_base_classpath_for_target(targets[0])
                classpath = self.classpath(tools_classpath, confs=self.confs, exclusives_classpath=exclusives_classpath)

                print("")  # Start REPL output on a new line.
                try:
                    # NOTE: We execute with no workunit, as capturing REPL output makes it very sluggish.
                    execute_java(classpath=classpath, main=self.main, jvm_options=self.jvm_args, args=self.args)
                except KeyboardInterrupt:
                    # TODO(John Sirois): Confirm with Steve Gury that finally does not work on mac and an
                    # explicit catch of KeyboardInterrupt is required.
                    pass
Пример #8
0
  def execute(self):
    (accept_predicate, reject_predicate) = Target.lang_discriminator('java')
    targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
    if targets:
      tools_classpath = self.tool_classpath('scala-repl')
      self.context.release_lock()
      with preserve_stty_settings():
        classpath = self.classpath(targets, cp=tools_classpath, confs=self.confs)

        print('')  # Start REPL output on a new line.
        try:
          # NOTE: We execute with no workunit, as capturing REPL output makes it very sluggish.
          execute_java(classpath=classpath,
                       main=self.get_options().main,
                       jvm_options=self.jvm_options,
                       args=self.args)
        except KeyboardInterrupt:
          # TODO(John Sirois): Confirm with Steve Gury that finally does not work on mac and an
          # explicit catch of KeyboardInterrupt is required.
          pass
Пример #9
0
  def execute(self):
    (accept_predicate, reject_predicate) = Target.lang_discriminator('python')
    targets = self.require_homogeneous_targets(accept_predicate, reject_predicate)
    if targets:
      # We can't throw if the target isn't a python target, because perhaps we were called on a
      # JVM target, in which case we have to no-op and let scala repl do its thing.
      # TODO(benjy): Some more elegant way to coordinate how tasks claim targets.
      interpreter = self.select_interpreter_for_targets(targets)

      extra_requirements = []
      if self.get_options().ipython:
        entry_point = self.context.config.get('python-ipython', 'entry_point',
                                              default='IPython:start_ipython')
        ipython_requirements = self.context.config.getlist('python-ipython', 'requirements',
                                                           default=['ipython==1.0.0'])
        for req in ipython_requirements:
          extra_requirements.append(PythonRequirement(req))
      else:
        entry_point = 'code:interact'

      with self.temporary_pex_builder(interpreter=interpreter) as builder:
        builder.set_entry_point(entry_point)
        chroot = PythonChroot(
          targets=targets,
          extra_requirements=extra_requirements,
          builder=builder,
          interpreter=interpreter,
          conn_timeout=self.conn_timeout)

        chroot.dump()
        builder.freeze()
        pex = PEX(builder.path(), interpreter=interpreter)
        self.context.lock.release()
        with stty_utils.preserve_stty_settings():
          with self.context.new_workunit(name='run', labels=[WorkUnit.RUN]):
            po = pex.run(blocking=False)
            try:
              return po.wait()
            except KeyboardInterrupt:
              pass