【问题标题】:Pants fails with scala related errors when building python构建python时裤子因scala相关错误而失败
【发布时间】:2015-10-01 03:16:03
【问题描述】:

我正在尝试使用裤子来构建一个微不足道的 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')

还有 BUILD 用于我的 hworld 二进制文件:

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

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

我尝试了各种排列(使用 BUILD.tools,没有 pants.ini 中的各种东西),但在每种情况下,它都因与 scala 相关的东西而失败......这有点令人困惑,因为我只是在构建Python。而且,在pantsbuild/pants repo 中运行对我来说效果很好。

我会提醒你,我对裤子很陌生,很可能我做了一些愚蠢的事情;)。有什么想法吗?

【问题讨论】:

  • 我认为我们已经在裤子的 1.0 版本中解决了这个问题,根本不需要 BUILD.tools。安装过程已简化,请参阅pantsbuild.org/install.html

标签: python pants


【解决方案1】:

如果其他人遇到这个问题,我通过从我的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

【讨论】:

    【解决方案2】:

    这看起来像是您的裤子设置使用来自 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,我能够编译您的项目。不过,我很高兴你找到了一些能让你取得进步的东西。

    【讨论】:

      猜你喜欢
      • 2022-07-07
      • 2020-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-11
      • 1970-01-01
      • 1970-01-01
      • 2021-07-16
      相关资源
      最近更新 更多