如何为 ppa 打包 python 应用程序?

jok*_*ino 5 python packaging

我打算将FBuntu 打包成 PPA 以便于分发。

这个应用程序的本质是用户必须对 auth.py 文件进行特定的编辑才能使其工作,因此我无法继续进行下去。

auth.py 的默认前几行如下所示:

import facebook

class facebookAuthentication:
    def __init__(self):
        url = "https://..."
        self.parse_url(url)
Run Code Online (Sandbox Code Playgroud)

从集市分支 FBuntu 后,用户必须使用通过 Facebook 进行身份验证后获得的 URL 手动编辑 URL。我不知道如何在生成 deb 包后编辑应用程序。

欢迎任何有关如何进行包装的指导。

and*_*ing 3

我不确定这个问题与包装有什么关系。用户不必直接编辑 python 文件,当然需要 root 权限才能安装。您真正想要的是安装到用户主目录的正确conf 文件。就像是:

import os
import ConfigParser

try:
    import xdg.BaseDirectory
except ImportError:
    home = os.environ.get('HOME')
    xdg_config_home = os.path.join(home, '.config/')
else:
    xdg_config_home = xdg.BaseDirectory.xdg_config_home

confDir =  os.path.join(xdg_config_home, 'myApp')
confFile =  os.path.join(confDir, 'conf.ini')

config = ConfigParser.ConfigParser()

if os.path.isfile(confFile):
    config.read(confFile)
    print "The URL is " + config.get('Section', 'url')
else:
    print "URL not set. Please edit " + confFile
    if not os.path.exists(confDir):
        os.makedirs(confDir)
    config.add_section('Section')
    config.set('Section', 'url', ' ')
    with open(confFile, 'wb') as confFile:
        config.write(confFile)
Run Code Online (Sandbox Code Playgroud)

当然,如果这是一个 GUI 应用程序,这对用户来说仍然有点多。您可能想要实现一个首选项窗口。