eric7/eric7_virtualenv.py

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

eric ide

mercurial