构建python时,Pants失败,并出现与scala相关的错误

2024-10-01 00:31:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用裤子做一个小的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

^{pr2}$

以及hworld二进制文件的BUILD

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

也许还有BUILD.tools但它很长,我直接从pantsbuild/pants复制了它(正如文档中建议的那样,我从另一个repo开始使用一个工作版本)。在

我尝试过各种排列(用构建工具,没有,pants.ini)中的各种东西,但在任何情况下,它都会因为与scala相关的东西而失败。。。这有点令人费解,因为我只是在构建python。而且,在pantsbuild/pantsrepo中运行对我来说很好。在

我要提醒你,我对裤子是全新的,很可能我做了些傻事;)。有什么想法吗?在


Tags: toinbuildtargethomefailureserveron
2条回答

这看起来像一个例子,你的裤子设置使用了来自master的代码,但是你的虚拟环境中的裤子版本落后了一些提交。根据你的裤子.ini你可以使用py0.0.0版本来自动释放。在

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

通过修补你的差异和撞上裤子的版本裤子.ini,我可以让你的项目编译。不过,我很高兴你找到了让你进步的东西。在

如果有人碰到这个问题,我通过从我的BUILD.tools中删除与scala相关的(特别是使用scala_jar)条目来解决这个问题:

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

相关问题 更多 >