2015-10-01 39 views
2

我试图用裤子来构建一个微不足道的pex只是为了测试它。但是,我遇到了一些问题:构建python裤子失败时发生scala相关错误

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

BUILD我hworld二进制:

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

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

我试过各种组合(与BUILD.tools,没有,各种东西在​​),但在任何情况下,它与有关scala的东西失败......这有点令人困惑,因为我只是建立python 。而且,在pantsbuild /裤子回购里面运行对我来说工作得很好。

我会提醒你我是全新的裤子,可能我做了一件傻事;)。有任何想法吗?

+0

我想我们已经在1.0版本的裤子中解决了这个问题,因为根本不需要BUILD.tools。安装过程已精简,请参阅http://www.pantsbuild.org/install.html。 – ericzundel

回答

1

如果别人打本,我解决它通过删除斯卡拉相关(特别是,任何使用scala_jar)条目从我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 
0

这看起来像在您的裤子设置为的情况下,使用来自主人的代码,但在虚拟环境中的裤子版本是一些落后的承诺。根据你的pants.ini,你在你的例子中使用了0.0.50版本,它会自动从pypi中释放0.0.50版本。

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

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