使用setuptools创建deb或rpm - data_files

pac*_*lik 12 python rpm setuptools deb python-3.x

我有一个Python 3项目.

MKC
??? latex
?   ??? macros.tex
?   ??? main.tex
??? mkc
?   ??? cache.py
?   ??? __init__.py
?   ??? __main__.py
??? README.md
??? setup.py
??? stdeb.cfg
Run Code Online (Sandbox Code Playgroud)

在安装时,我想将我的乳胶文件移动到已知目录,比如说/usr/share/mkc/latex,所以我已经告诉setuptools要包含数据文件

data_files=[("/usr/share/mkc/latex",
             ["latex/macros.tex", "latex/main.tex"])],
Run Code Online (Sandbox Code Playgroud)

现在我跑的时候

./setup.py bdist --formats=rpm
Run Code Online (Sandbox Code Playgroud)

要么

./setup.py --command-packages=stdeb.command bdist_deb
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

error: can't copy 'latex/macros.tex': doesn't exist or not a regular file

运行./setup.py bdist正常,所以问题必须在包创建中.

tyn*_*ynn 12

创建deb文件时(我猜对rpm文件的计数相同),./setup.py --command-packages=stdeb.command bdist_deb首先创建一个源代码分发并使用该归档进行进一步处理.但是你的LaTeX文件不包含在那里,所以找不到它们.

您需要将它们添加到源包中.这可以通过添加MANIFEST.in来实现,内容如下:

recursive-include latex *.tex
Run Code Online (Sandbox Code Playgroud)

版本3.1上的distutils将自动包含data_files在源代码分发中,而setuptools显然工作方式非常不同.