Python setuptools: how to include a config file for distribution into /etc

前端 未结 1 1377
梦谈多话
梦谈多话 2020-12-30 18:55

How can I write setup.py so that:

  1. The binary egg distribution (bdist_egg) includes a sample configuration file and
  2. Upon ins
相关标签:
1条回答
  • 2020-12-30 19:38

    I was doing some research on this issue and I think the answer is in the setuptools documentation: http://peak.telecommunity.com/DevCenter/setuptools#non-package-data-files

    Next, I quote the extract that I think has the answer:

    Non-Package Data Files

    The distutils normally install general "data files" to a platform-specific location (e.g. /usr/share). This feature intended to be used for things like documentation, example configuration files, and the like. setuptools does not install these data files in a separate location, however. They are bundled inside the egg file or directory, alongside the Python modules and packages. The data files can also be accessed using the Resource Management API [...]

    Note, by the way, that this encapsulation of data files means that you can't actually install data files to some arbitrary location on a user's machine; this is a feature, not a bug. You can always include a script in your distribution that extracts and copies your the documentation or data files to a user-specified location, at their discretion. If you put related data files in a single directory, you can use resource_filename() with the directory name to get a filesystem directory that then can be copied with the shutil module. [...]

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题