2015-10-01 37 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,我可以讓你的項目編譯。不過,我很高興你找到了一些可以讓你取得進步的東西。