如何使用setuptools安装可写的共享和用户特定的数据文件? [英] How to install writable shared and user specific data files with setuptools?

查看:47
本文介绍了如何使用setuptools安装可写的共享和用户特定的数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道package_data.但这是用于包内的只读数据的.还是这个假设是错误的?如何安装共享的或用户特定的 writeable 数据?例如Windows上的ProgramData或AppData.我也对Linux解决方案感兴趣.

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.

推荐答案

您的假设对我来说似乎很正确(包数据应该为只读).对于可写数据:要么让用户选择一个目标目录,要么根据一个通用约定选择一个目录.但这不会在安装时发生.最好让您的库或应用程序检查这些共享目录和文件在需要时是否存在,如果不存在则立即进行创建.

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.

例如, XDG Base目录规范.这两个项目可以帮助您根据此规范编写代码:

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

这篇关于如何使用setuptools安装可写的共享和用户特定的数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆