2017-08-17 63 views
1

這個問題涉及到Openembedded/Yocto。'no module named setuptools',但它包含在DEPENDS變量中

我有源代碼需要由自定義python3腳本編譯。 這意味着,一些python3腳本應該在do_compile()進程中運行。 該腳本導入setuptools,因此,我在配方中添加了DEPENDS += "python3-setuptools-native"。據我瞭解的文件,這應該使setuptools模塊可用於建設過程(本機)。 但是,當bitbake執行do_compile()進程時,出現此錯誤:no module named 'setuptools'

讓我把它分解到最小的(非)工作示例:

FILE:test.bb

LICENSE = "BSD" 
LIC_FILES_CHKSUM = "file://test/LICENSE;md5=d41d8cd98f00b204e9800998ecf8427e" 

DEPENDS += "python3-setuptools-native" 

SRC_URI = "file://test.py \ 
      file://LICENSE" 

do_compile() { 
    python3 ${S}/../test.py 
} 

FILE:test.py

import setuptools 

print("HELLO") 

bitbaking:

$ bitbake test 
ERROR: test-1.0-r0 do_compile: Function failed: do_compile (log file is located at /path/to/test/1.0-r0/temp/log.do_compile.8532) 
ERROR: Logfile of failure stored in: /path/to/test/1.0-r0/temp/log.do_compile.8532 
Log data follows: 
| DEBUG: Executing shell function do_compile 
| Traceback (most recent call last): 
| File "/path/to/test-1.0/../test.py", line 1, in <module> 
|  import setuptools 
| ImportError: No module named 'setuptools' 
| WARNING: exit code 1 from a shell command. 
| ERROR: Function failed: do_compile (log file is located at /path/to/test/1.0-r0/temp/log.do_compile.8532) 
ERROR: Task (/path/to/test.bb:do_compile) failed with exit code '1' 
NOTE: Tasks Summary: Attempted 400 tasks of which 398 didn't need to be rerun and 1 failed. 
NOTE: Writing buildhistory 

Summary: 1 task failed: 
    /path/to/test.bb:do_compile 
Summary: There was 1 ERROR message shown, returning a non-zero exit code. 

我的錯誤是否是錯誤的,DEPENDS += "python3-setuptools-native"使得python3模塊的'setuptools'可用於do_compile()中的python3腳本?我怎麼能做到這一點?

回答

1

爲了得到setuptools的支持,需要更多的工作。幸運的是有一個類來處理:

inherit setuptools3 

這應該是所有的需要打包的setuptools與OE核心基礎的項目。只要你的項目有一個標準的setup.py,你就不需要編寫任何的do_compile()或do_install()函數。

如果您確實需要查看詳細信息,meta/classes/setuptools3.bbclassmeta/classes/distutils3.bbclass應該包含您需要的內容(包括從配方中調用native python的相當不明顯的方式)。