在构建python时,裤子与scala相关的错误失败

时间:2015-10-01 03:16:04

标签: python pants

我试图用裤子来构建一个简单的pex来测试它。但是,我遇到了一些问题:

$ ./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

由于很难将我的问题的所有部分表达为单个粘贴,因此我发布了on github(对外部链接道歉)。

相关位是我的顶级BUILD

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

和我的hworld二进制文件的BUILD

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

也许也是BUILD.tools,但它很长,我直接从裤子/裤子中复制了它(正如我从另一个回购的工作版本开始的文档中所建议的那样)。

我尝试了各种排列(使用BUILD.tools,没有pants.ini中的各种内容)但是在每种情况下它都失败了与scala相关的内容......这有点令人困惑,因为我和#39; m只构建python。并且,在pantsbuild / pants repo里面跑步对我来说很好。

我会提醒你,我是裤子的新手,而且我可能做了些傻事;)。有什么想法吗?

2 个答案:

答案 0 :(得分:1)

如果其他人遇到此问题,我通过删除与我scala_jar中的scala相关的内容(特别是使用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

答案 1 :(得分:0)

这看起来像你的裤子设置是使用来自master的代码,但你的虚拟环境中的裤子版本是一些提交。根据你的pants.ini你在你的例子中使用0.0.50版本,它会自动从pypi中提取0.0.50版本。

但scala_jar实现落在0.0.50和0.0.51之间,特别是this commit here

通过修补你的差异并在pants.ini中碰撞pants_version,我能够让你的项目进行编译。我很高兴你找到了一些让你取得进步的东西。