src/eric7/eric7_pip.py

branch
eric7
changeset 10084
125166c6b66c
child 10238
9ea4634a697e
equal deleted inserted replaced
10083:62019277dd0a 10084:125166c6b66c
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 eric pip Packages Manager.
9
10 This is the main Python script to manage Python packages with 'pip' from
11 outside of the IDE.
12 """
13
14 import os
15 import sys
16
17 from PyQt6.QtGui import QGuiApplication
18
19 for arg in sys.argv[:]:
20 if arg.startswith("--config="):
21 from eric7 import Globals
22
23 configDir = arg.replace("--config=", "")
24 Globals.setConfigDir(configDir)
25 sys.argv.remove(arg)
26 elif arg.startswith("--settings="):
27 from PyQt6.QtCore import QSettings
28
29 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
30 if not os.path.isdir(settingsDir):
31 os.makedirs(settingsDir)
32 QSettings.setPath(
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir
34 )
35 sys.argv.remove(arg)
36
37 from eric7.Globals import AppInfo
38 from eric7.Toolbox import Startup
39
40
41 def createMainWidget(argv): # noqa: U100
42 """
43 Function to create the main widget.
44
45 @param argv list of commandline parameters
46 @type list of str
47 @return reference to the main widget
48 @rtype QWidget
49 """
50 from eric7.PipInterface.PipPackagesWindow import PipPackagesWindow
51
52 return PipPackagesWindow(None)
53
54
55 def main():
56 """
57 Main entry point into the application.
58 """
59 QGuiApplication.setDesktopFileName("eric7_pip.desktop")
60
61 options = [
62 (
63 "--config=configDir",
64 "use the given directory as the one containing the config files",
65 ),
66 (
67 "--settings=settingsDir",
68 "use the given directory to store the settings files",
69 ),
70 ]
71 appinfo = AppInfo.makeAppInfo(
72 sys.argv,
73 "eric Package Manager",
74 "",
75 "Utility to manage Python packages with 'pip'.",
76 options,
77 )
78 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget)
79 sys.exit(res)
80
81
82 if __name__ == "__main__":
83 main()

eric ide

mercurial