简体   繁体   English

我的 Python 包应该在哪里添加用户系统上的文件?

[英]Where should my Python package add files on a user system?

I want my package to add a SQLite file either at time of package install or upon running an initialization method.我希望我的包在安装包时或运行初始化方法时添加一个 SQLite 文件。

Is there a conventional place where that file should live?是否有该文件应该存放的传统位置?

  • Option 1: within a /usr/local directory.选项 1:/usr/local目录中。
  • Option 2: within ~ home directory of /Users/<current_user>选项 2:/Users/<current_user> ~主目录中

I have no experience in this area, but I am leaning toward a hidden .my_package directory at ~ because when I look at my home this is what I see:我在这方面没有经验,但我倾向于隐藏.my_package目录~因为当我看着我的家时,我看到的是:

.conda
.docker
.ipython
.jupyter
.matplotlib
...

无论平台如何,您可能都希望使用appdirs包来确定正确的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM