使用 python setuptools 'bdist_deb' 编译 C 代码

Compiling C code with python setuptools 'bdist_deb'

我必须将我的 RPM 包转换为 DEB 包才能在 Ubuntu 上安装它。由于我没有任何构建 DEB 包的经验,谷歌搜索建议 'bdist_rpm' from stdeb package

代码主要是 python、配置文件等。但是有一个 C 代码需要构建。 RPM 在 /usr/bin

中安装二进制文件

setup.py 中用于创建二进制文件的代码是

if sys.argv and len(sys.argv) > 1 and sys.argv[1].strip().startswith('bdist'):
try:
    compiler = UnixCCompiler(verbose=1)
    compiler.compile(['cutility/chown_sudo.c'])
    compiler.link_executable((['cutility/chown_sudo.o']), 'bin/sudoown')
except CompileError as compileError:
    print "Failed to compile the binary file."
    raise

bdist_rpm 理解这段代码并创建了 C。但是 bdist_deb 忽略了它 :(

通过网络搜索,debuild 实用程序建议为此创建一些 Makefile 以及许多其他复杂的东西

有那么复杂吗?一些搜索还建议改用 'alien' 工具 ?

到目前为止我的想法是,使用以下命令

python setup.py --command-packages=stdeb.command debianize

然后调整debian目录postint、control等。 但我不知道如何构建 C 代码

我发现我在 'bdist_rpm' 中使用的 'bdist' 检查在使用 'bdist_deb' 选项时导致了问题。使用 'bdist_deb' 选项时,将使用 'build' 参数调用脚本。在我为 startswith('build') 添加了一个 OR 之后,事情进展了