Skip to main content
 首页 » 编程设计

setuptools之setup.py sdist 如何解引用符号链接(symbolic link)

2024年11月24日30arxive

setup.cfg 部分 data_files 包含一个带有符号链接(symbolic link)的目录。运行 python setup.py sdist 时,生成的分布不包含符号链接(symbolic link),它们将被忽略。这是 setup.py 的内容,基于 pbr :

#!/usr/bin/env python 
 
from setuptools import setup 
 
setup( 
    setup_requires=['pbr'], 
    pbr=True, 
) 

取消引用符号链接(symbolic link)并包含实际文件会很好。分布会更大,因为文件是重复的,但它会是完整的。

查看 sdist sources看起来符号链接(symbolic link)总是被忽略:

$ python setup.py sdist 
... 
'molecule/debops' not a regular file -- skipping 
... 

是否有解决方法说服 sdist 取消引用符号链接(symbolic link)?

请您参考如下方法:

MANIFEST.in graft command不幸的是不在 python 3 documentation 中, 但可以找到 in the sources .它调用include_pattern和 findall哪个follows symbolic links .因此,将以下行添加到 MANIFEST.in 就足够了:

graft molecule/ 

确保 molecule/ 树包含在分发中,并且将遵循所有符号链接(symbolic link)。这确实导致了重复的内容,但结果是完整的。

符号链接(symbolic link)抑制的根本原因是(与 sdist 不同)pbr 遍历 data_files 中提到的目录 without following symbolic links .因此,它将在 SOURCES.txt 文件中创建包含符号链接(symbolic link)的路径列表。他们将是ignored by sdist永远不要进入发行版。