pythonpants

Pants fails with scala related errors when building python


I'm trying to use pants to build a trivial pex just to test it out. However, I'm running into some issues:

$ ./pants binary src/python/hworld
INFO] Detected git repository at /home/jovalko/pants on branch master

23:03:48 00:00 [main]
               (To run a reporting server: ./pants server)
23:03:48 00:00   [bootstrap]
23:03:48 00:00   [setup]
23:03:48 00:00     [parse]
FAILURE: 
       Failed to resolve target for tool: //:scala-compiler. This target was obtained from
       option scalac in scope scala-platform. You probably need to add this target to your tools
       BUILD file(s), usually located in BUILD.tools in the workspace root.
       Exception AddressLookupError: name 'scala_jar' is not defined
while executing BUILD file FilesystemBuildFile(/home/jovalko/pants/BUILD.tools)
Loading addresses from '' failed.



23:03:48 00:00   [complete]
               FAILURE

Since it's difficult to express all the bits of my problem as a single paste, I've posted them on github (apologies for external linking).

The relevant bits are my top level BUILD:

# Pants source code
source_root('src/python')

and the BUILD for my hworld binary:

python_binary(name='hworld',
    source='hworld.py'
)

Perhaps also BUILD.tools but it's long and I copied it straight from pantsbuild/pants (as suggested in the docs that I start with a working version from another repo).

I've attempted various permutations (with BUILD.tools, without, various things in pants.ini) but in every case it fails with something related to scala... which is a bit perplexing, as I'm only building python. And, running inside the pantsbuild/pants repo works fine for me.

I'll remind you that I'm brand new to pants, and it's likely I did something silly ;). Any ideas?


Solution

  • In case anybody else hits this, I solved it by deleting the scala-related (specifically, anything that used scala_jar) entries from my BUILD.tools:

    diff --git a/BUILD.tools b/BUILD.tools
    index d0f1cf7..049fb2f 100644
    --- a/BUILD.tools
    +++ b/BUILD.tools
    @@ -23,32 +23,3 @@ jar_library(name = 'scala-repl',
                   ':scala-library',
                 ])
    
    -jar_library(name = 'scalastyle',
    -            jars = [
    -              scala_jar(org='org.scalastyle', name='scalastyle', rev='0.3.2')
    -            ])
    -
    -jar_library(name = 'scrooge-gen',
    -            jars = [
    -              scala_jar(org='com.twitter', name='scrooge-generator', rev='3.20.0',
    -                        excludes=[
    -                          # scrooge requires libthrift 0.5.0-1 which is not available on
    -                          # the default maven repos. Force scrooge to use thrift-0.6.1, which
    -                          # is compatible, instead.
    -                          exclude(org = 'org.apache.thrift', name = 'libthrift')
    -                        ])
    -            ],
    -            dependencies = [
    -              '3rdparty:thrift-0.6.1',
    -            ])
    -
    -jar_library(name = 'scrooge-linter',
    -            jars = [
    -              scala_jar(org='com.twitter', name='scrooge-linter', rev='3.20.0',
    -                        excludes=[
    -                          exclude(org = 'org.apache.thrift', name = 'libthrift')
    -                        ])
    -            ],
    -            dependencies = [
    -              '3rdparty:thrift-0.6.1',
    -            ])
    diff --git a/src/python/hworld/BUILD b/src/python/hworld/BUILD
    index ecfdd58..6407c02 100644
    --- a/src/python/hworld/BUILD
    +++ b/src/python/hworld/BUILD