Fix python_repl to work for python_requirement_libraries.

Review Request #1934 — Created March 18, 2015 and submitted

jsirois
pants
jsirois/python_repl/is_py_fix
1270, 1275
15ee191...
pants-reviews
areitz, benjyw, kwlzn, zundel
This also adds a unit test for PythonRepl and knocks off a TODO
lifting up a bit of test infra for PythonTask tests.

 src/python/pants/backend/python/targets/python_requirement_library.py |   1 +
 src/python/pants/backend/python/tasks/python_repl.py                  |   5 +-
 tests/python/pants_test/backend/python/tasks/BUILD                    |  33 +++++++++-
 tests/python/pants_test/backend/python/tasks/python_task_test.py      |  63 +++++++++++++++++++
 tests/python/pants_test/backend/python/tasks/test_python_eval.py      |  50 +--------------
 tests/python/pants_test/backend/python/tasks/test_python_repl.py      | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 270 insertions(+), 53 deletions(-)
CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/54809259
AR
  1. LGTM, thanks (amazed that it was a one-line fix). I checked it out, and it looks like pants is doing the right thing now:

    [prometheus pants (rb_1934)]$ /usr/bin/python
    Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import antlr3
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named antlr3
    >>> ^D
    
    [prometheus pants (rb_1934)]$ ./pants repl 3rdparty/python:antlr-3.1.3
    INFO] Detected git repository at /Users/areitz/workspace/pants on branch rb_1934
    
    19:41:30 00:00 [main]
                   (To run a reporting server: ./pants server)
    19:41:30 00:00   [bootstrap]
    19:41:30 00:00   [setup]
    19:41:30 00:00     [parse]
                   Executing tasks in goals: bootstrap -> imports -> unpack-jars -> deferred-sources -> gen -> resolve -> compile -> resources -> repl
    19:41:30 00:00   [bootstrap]
    19:41:30 00:00     [bootstrap-jvm-tools]
    19:41:30 00:00   [imports]
    19:41:30 00:00     [ivy-imports]
    19:41:30 00:00   [unpack-jars]
    19:41:30 00:00     [unpack-jars]
    19:41:30 00:00   [deferred-sources]
    19:41:30 00:00     [deferred-sources]
    19:41:30 00:00   [gen]
    19:41:30 00:00     [thrift]
    19:41:30 00:00     [protoc]
    19:41:30 00:00     [antlr]
    19:41:30 00:00     [ragel]
    19:41:30 00:00     [jaxb]
    19:41:30 00:00     [wire]
    19:41:30 00:00     [aapt]
    19:41:30 00:00     [scrooge]
    19:41:30 00:00   [resolve]
    19:41:30 00:00     [ivy]
    19:41:30 00:00   [compile]
    19:41:30 00:00     [compile]
    19:41:30 00:00     [jvm]
    19:41:30 00:00       [jvm-compilers]
    19:41:30 00:00     [python-eval]
    19:41:30 00:00       [eval-targets]
    19:41:30 00:00     [checkstyle]
    19:41:30 00:00     [scalastyle]
    19:41:30 00:00     [cpp-compile]
    19:41:30 00:00   [resources]
    19:41:30 00:00     [prepare]
    19:41:30 00:00   [repl]
    19:41:30 00:00     [py]
    19:41:30 00:00       [run]
    Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> import antlr3
    >>> ^D
    
    19:41:36 00:06     [scala]
                   SUCCESS
    
    1. What - no faith in my test + CI?! It does exactly this! ;)
    2. Heh -- it was a little mind-boggling that all we were missing was a label! It acutally didn't work at first (and I was about to say so), but I discovered that I needed to re-bootstrap pants in order to be able to observe your change.

  2. 
      
BE
  1. Nice test!

  2. 
      
ZU
  1. 
      
  2. This works fine. I've been trying to use the shortcut pattern:

    from pants.backend.core.register import build_file_aliases as register_core
    from pants.backend.jvm.register import build_file_aliases as register_jvm
    ...
    
    @property
      def alias_groups(self):
        return register_core().merge(register_jvm())
    
    1. The register_jvm bit would not be an appropriate dep, I did a fair bit of dance here to keep the python backend tasks decoupled even though Task itself currently is.
      The register_core is a good idea though - but I'll leave as-is since the current base-class / sub-class arrangement of explicitly adding what you use is more obviously locally correct when reading this file.
  3. 
      
IT
  1. thanks for adding tests!

  2. 
      
JS
  1. Thanks folks - submitted @ https://github.com/pantsbuild/pants/commit/6989fce2bc298019b344cf75a28b255901882162
  2. 
      
JS
Review request changed

Status: Closed (submitted)

Loading...