gpt4 book ai didi

Python 应用程序目录选择

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:20 25 4
gpt4 key购买 nike

我正在编写一个新的 Python 应用程序,打算分发给几位同事。这一次我想开阔视野,真正尝试按预期使用 Linux 目录结构(至少在某种程度上),而不是我通常无忧无虑的态度,即让所有内容都自包含并在我的主目录中的文件夹中运行。如果这不正确,您能否阅读我的分割并发表评论或提出建议。

让我们称应用程序为“narf”

/usr/narf - Install location for the actual python file(s).    
/usr/bin/narf - Either a softlink to the main python file above or use this location instead.
/etc/narf - Any configuration files for app narf.
/var/log/narf - Any log files for app narf.
/usr/lib - Any required libraries for app narf.
/run/narf - Any persistent (across reboot), but still temp files for app narf.
/tmp/narf - Very temp files for app narf that go away with reboot

我认为我应该坚持使用/usr/X(例如/usr/bin 而不是/bin),因为我的应用程序不是系统关键的,只是一个插件。

我目前使用的是 Ubuntu 16 LTS,但其中一部分是为了尝试针对任何流行的 Linux 发行版标准化我的应用程序。

感谢您的帮助。

* 更新 *

我想我至少看到了部分问题的答案。查看/usr,我现在看到它是一个非常简单的目录,几乎类似于用户级根目录(即有 bin、lib、local、sbin 等,但仅此而已)。这让我相信我的应用程序绝对不应该存在于/usr 中,而只能存在于/usr/bin 中。

最佳答案

您最好将整个应用程序放入/opt。看这里:http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#opt

然后将可执行文件的软链接(soft link)放入/usr/local/bin。看这里:https://unix.stackexchange.com/a/8658/219043

我不会担心剩下的。

关于Python 应用程序目录选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42683602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com