2

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?

FatalError
  • 52,695
  • 14
  • 99
  • 116
  • I think we've fixed this in the 1.0 release of pants by just not requiring a BUILD.tools at all. The installation process has been streamlined, see http://www.pantsbuild.org/install.html. – ericzundel May 01 '16 at 12:24

2 Answers2

1

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
FatalError
  • 52,695
  • 14
  • 99
  • 116
0

This looks like a case where your pants setup was using code from master but the pants version in your virtual env was a few commits behind. According to your pants.ini you are using the 0.0.50 release in your example, which automatically pulls the 0.0.50 release from pypi.

But the scala_jar implementation landed in between 0.0.50 and 0.0.51, specifically this commit here.

By patching in your diff and bumping the pants_version in your pants.ini, I was able to get your project to compile. I am glad you found something that allowed you make progress, though.

mateor
  • 1,293
  • 1
  • 16
  • 19