duanli6834 2019-05-07 00:38
浏览 274

scons / SConscript文件的缩进错误

I'm trying to write a SConscript file so that I can use scons to build Go code. The SConscript file is pretty simple; its just a starter file:

def gc(source, target, env, for_signature):
   targets = target[0]
   sources = " ".join(str(s) for s in source)
   print(sources)
   return 'go build {}'.format(sources)


go_compiler = Builder(
   generator=gc,
   src_suffix='.go',
)

# Create environment
env = Environment(
   BUILDERS={'Go': go_compiler, }
)

# Build programs
main_package = env.Go(target='helloworld', source='helloworld.go')

But I keep getting this error:

# scons
scons: Reading SConscript files ...
  File "/root/repo/SConstruct", line 5

    print(sources)

    ^

IndentationError: unexpected indent

I tried switching between python v2.7 and 3.7, rewriting the code in various different ways, but I kept hitting the same issue. I even tried writing several fragments of the above code inside a python interpreter and the syntax and indentation were fine.

  • 写回答

1条回答 默认 最新

  • dongshen7561 2019-05-07 00:40
    关注

    I had copied/pasted some of this code from online. Turns out there was some embedded tabs, but my editor was using spaces. So several lines were inconsistently indented. I spend hours looking at this, so I figured I would share my mistake.

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能