【问题标题】:How to include hidden files in python distutils?如何在 python distutils 中包含隐藏文件?
【发布时间】:2018-02-14 03:49:43
【问题描述】:

我的包有一个隐藏目录,我想将其作为包数据分发。我在distutils.setup(...) 中包含以下内容:

[...]
package_data={'mypkg': ['.hg/*']},
[...]

但是这种语法不起作用:当我运行python setup.py install 时,目录.hg 不包含在包中。我相信问题出在目录名称.hg 上,因为如果我将.hg 替换为hg,那么以下内容将按预期工作。

[...]
package_data={'mypkg': ['hg/*']},
[...]

不幸的是,目录名称必须是 .hg 才能使 Mercurial 工作。这个问题有解决办法吗?

【问题讨论】:

  • 我无法复制它。 package_data={'mypkg': ['../.git/*']} 包含在 sdistbdist_eggbdist_wheel 中的 .git/*。可能你需要升级setuptools
  • @phd 感谢您的评论,我有最新版本的setuptools。你用的是什么版本?
  • setuptools 38.4.0
  • @phd 对不起新手,但我使用的是 distutils.core import setup 而不是 from setuptools import setup。这造成了不同。如果您可以花时间将其表述为答案,我将确保接受它。

标签: python distutils setup.py hidden-files


【解决方案1】:

似乎与setuptools(而不是distutils)一起工作:

package_data={'mypkg': ['../.git/*']}

sdistbdist_eggbdist_wheel 中包含.git/*(非递归)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 1970-01-01
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 2013-05-09
    相关资源
    最近更新 更多