How to install writable shared and user specific data files with setuptools?

和自甴很熟 提交于 2021-01-28 20:20:38

问题


I know package_data. But it is for readonly data inside the package. Or is this assumption wrong? How to install shared or user specific writeable data? For example to ProgramData or AppData on Windows. I'm interested in a solution for linux, too.


回答1:


Your assumption seems right to me (package data should be read-only). For writable data: either let the user choose a target directory, or pick one directory according to a common convention. But this can not happen at install time. It's probably better to have your library or application check if these shared directories and files exist when they are needed, and if they don't then create them on the fly.

For example a pretty common convention is the XDG Base Directory Specification. These two projects can help write code according to this specification:

  • https://pypi.org/project/appdirs/
  • https://pypi.org/project/xdgappdirs/


来源:https://stackoverflow.com/questions/60158692/how-to-install-writable-shared-and-user-specific-data-files-with-setuptools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!