gibson-cli 0.8.10__py3-none-any.whl → 0.8.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gibson/api/ProjectApi.py +2 -2
- gibson/command/Deploy.py +1 -1
- gibson/command/Help.py +2 -51
- gibson/command/Version.py +1 -1
- gibson/core/CommandRouter.py +0 -6
- gibson/services/mcp/server.py +7 -6
- {gibson_cli-0.8.10.dist-info → gibson_cli-0.8.11.dist-info}/METADATA +2 -2
- {gibson_cli-0.8.10.dist-info → gibson_cli-0.8.11.dist-info}/RECORD +11 -12
- {gibson_cli-0.8.10.dist-info → gibson_cli-0.8.11.dist-info}/WHEEL +1 -1
- {gibson_cli-0.8.10.dist-info → gibson_cli-0.8.11.dist-info}/top_level.txt +0 -1
- venv/bin/activate_this.py +0 -59
- {gibson_cli-0.8.10.dist-info → gibson_cli-0.8.11.dist-info}/entry_points.txt +0 -0
gibson/api/ProjectApi.py
CHANGED
@@ -22,9 +22,9 @@ class ProjectApi(BaseApi):
|
|
22
22
|
def lookup(self, uuid: str):
|
23
23
|
return self.get(f"{uuid}")
|
24
24
|
|
25
|
-
def deploy(self, uuid: str,
|
25
|
+
def deploy(self, uuid: str, databases: List[str] | None = None):
|
26
26
|
return self.post(
|
27
|
-
f"{uuid}/deploy", {"environments":
|
27
|
+
f"{uuid}/deploy", {"environments": databases} if databases else None
|
28
28
|
)
|
29
29
|
|
30
30
|
def diff(self, uuid: str):
|
gibson/command/Deploy.py
CHANGED
gibson/command/Help.py
CHANGED
@@ -4,7 +4,6 @@ from rich.table import Table
|
|
4
4
|
from rich.text import Text
|
5
5
|
|
6
6
|
from gibson.command.BaseCommand import BaseCommand
|
7
|
-
from gibson.core.Memory import Memory
|
8
7
|
|
9
8
|
|
10
9
|
class Help(BaseCommand):
|
@@ -25,32 +24,26 @@ class Help(BaseCommand):
|
|
25
24
|
"auth": {
|
26
25
|
"description": "authenticate with the gibson cli",
|
27
26
|
"subcommands": ["login", "logout"],
|
28
|
-
"memory": None,
|
29
27
|
},
|
30
28
|
"build": {
|
31
29
|
"description": "create the entities in the datastore",
|
32
30
|
"subcommands": ["datastore"],
|
33
|
-
"memory": "stored",
|
34
31
|
},
|
35
32
|
"code": {
|
36
33
|
"description": "pair program with gibson",
|
37
34
|
"subcommands": ["api", "base", "entity", "models", "schemas", "tests"],
|
38
|
-
"memory": None,
|
39
35
|
},
|
40
36
|
"conf": {
|
41
37
|
"description": "set a configuration variable",
|
42
38
|
"subcommands": None,
|
43
|
-
"memory": None,
|
44
39
|
},
|
45
40
|
"count": {
|
46
41
|
"description": "show the number of entities stored",
|
47
42
|
"subcommands": ["last", "stored"],
|
48
|
-
"memory": "based on user selection",
|
49
43
|
},
|
50
44
|
"deploy": {
|
51
45
|
"description": "deploy the project database(s) with the current schema",
|
52
46
|
"subcommands": None,
|
53
|
-
"memory": None,
|
54
47
|
},
|
55
48
|
"dev": {
|
56
49
|
"description": Text.assemble(
|
@@ -58,78 +51,55 @@ class Help(BaseCommand):
|
|
58
51
|
*dev_mode_text,
|
59
52
|
),
|
60
53
|
"subcommands": ["on", "off"],
|
61
|
-
"memory": None,
|
62
54
|
},
|
63
|
-
"
|
64
|
-
"description": "delete entities from memory",
|
65
|
-
"subcommands": ["all", "last", "stored"],
|
66
|
-
"memory": "based on user selection",
|
67
|
-
},
|
68
|
-
"help": {"description": "for help", "subcommands": None, "memory": None},
|
55
|
+
"help": {"description": "for help", "subcommands": None},
|
69
56
|
"import": {
|
70
57
|
"description": "import entities from a datasource",
|
71
58
|
"subcommands": ["api", "mysql", "pg_dump", "openapi"],
|
72
|
-
"memory": "stored",
|
73
59
|
},
|
74
60
|
"list": {
|
75
61
|
"description": "see a list of your entities or projects",
|
76
62
|
"subcommands": ["entities", "projects"],
|
77
|
-
"memory": None,
|
78
63
|
},
|
79
64
|
"mcp": {
|
80
65
|
"description": "allows tools like Cursor to interact with your gibson project",
|
81
66
|
"subcommands": ["run"],
|
82
|
-
"memory": None,
|
83
|
-
},
|
84
|
-
"merge": {
|
85
|
-
"description": "merge last memory (recent changes) into stored project memory",
|
86
|
-
"subcommands": None,
|
87
|
-
"memory": "last -> stored",
|
88
67
|
},
|
89
68
|
"modify": {
|
90
69
|
"description": "change an entity using natural language",
|
91
70
|
"subcommands": None,
|
92
|
-
"memory": "last > stored",
|
93
71
|
},
|
94
72
|
"new": {
|
95
73
|
"description": "create something new",
|
96
74
|
"subcommands": ["project", "module", "entity"],
|
97
|
-
"memory": None,
|
98
75
|
},
|
99
76
|
"remove": {
|
100
77
|
"description": "remove an entity from the project",
|
101
78
|
"subcommands": None,
|
102
|
-
"memory": "last > stored",
|
103
79
|
},
|
104
80
|
"rename": {
|
105
81
|
"description": "rename an entity",
|
106
82
|
"subcommands": ["entity"],
|
107
|
-
"memory": "last > stored",
|
108
83
|
},
|
109
84
|
"rewrite": {
|
110
85
|
"description": "rewrite all code",
|
111
86
|
"subcommands": None,
|
112
|
-
"memory": "stored",
|
113
87
|
},
|
114
88
|
"show": {
|
115
89
|
"description": "display an entity",
|
116
90
|
"subcommands": None,
|
117
|
-
"memory": "last > stored",
|
118
91
|
},
|
119
92
|
"studio": {
|
120
93
|
"description": "connect to your database and launch the SQL studio",
|
121
94
|
"subcommands": None,
|
122
|
-
"memory": None,
|
123
95
|
},
|
124
96
|
"tree": {
|
125
97
|
"description": "illustrate the project layout in a tree view",
|
126
98
|
"subcommands": None,
|
127
|
-
"memory": None,
|
128
99
|
},
|
129
100
|
"q": {
|
130
|
-
"description": "
|
101
|
+
"description": "chat with gibson",
|
131
102
|
"subcommands": None,
|
132
|
-
"memory": None,
|
133
103
|
},
|
134
104
|
}
|
135
105
|
|
@@ -152,7 +122,6 @@ class Help(BaseCommand):
|
|
152
122
|
help.add_column("command", style="yellow bold", header_style="yellow bold")
|
153
123
|
help.add_column("description")
|
154
124
|
help.add_column("subcommands", header_style="magenta")
|
155
|
-
help.add_column("memory affected", style="grey50", header_style="grey50")
|
156
125
|
|
157
126
|
for subcommand, config in subcommands.items():
|
158
127
|
help.add_row(
|
@@ -165,26 +134,8 @@ class Help(BaseCommand):
|
|
165
134
|
if config["subcommands"]
|
166
135
|
else ""
|
167
136
|
),
|
168
|
-
config["memory"] or "",
|
169
137
|
)
|
170
138
|
|
171
139
|
console.print(help)
|
172
140
|
|
173
141
|
self.conversation.newline()
|
174
|
-
|
175
|
-
if self.configuration.project:
|
176
|
-
stats = Memory(self.configuration).stats()
|
177
|
-
memory = Table(
|
178
|
-
title="Memory",
|
179
|
-
show_header=True,
|
180
|
-
header_style="bold",
|
181
|
-
box=box.ROUNDED,
|
182
|
-
expand=True,
|
183
|
-
)
|
184
|
-
memory.add_column("stored", style="green", header_style="green")
|
185
|
-
memory.add_column("last", style="yellow", header_style="yellow")
|
186
|
-
memory.add_row(
|
187
|
-
f"{stats['entities']['num']} {stats['entities']['word']}",
|
188
|
-
f"{stats['last']['num']} {stats['last']['word']}",
|
189
|
-
)
|
190
|
-
console.print(memory)
|
gibson/command/Version.py
CHANGED
@@ -21,7 +21,7 @@ class Version(BaseCommand):
|
|
21
21
|
f"You are currently using version: {Colors.violet(VersionConf.num)}\n"
|
22
22
|
)
|
23
23
|
self.conversation.type(
|
24
|
-
f"Please update to the latest version by running: {Colors.command('
|
24
|
+
f"Please update to the latest version by running: {Colors.command('uv', 'tool', args='install', inputs='gibson-cli@latest')}\n"
|
25
25
|
)
|
26
26
|
else:
|
27
27
|
self.conversation.type(
|
gibson/core/CommandRouter.py
CHANGED
@@ -7,12 +7,10 @@ from gibson.command.Conf import Conf
|
|
7
7
|
from gibson.command.Count import Count
|
8
8
|
from gibson.command.Deploy import Deploy
|
9
9
|
from gibson.command.Dev import Dev
|
10
|
-
from gibson.command.Forget import Forget
|
11
10
|
from gibson.command.Help import Help
|
12
11
|
from gibson.command.importer.Import import Import
|
13
12
|
from gibson.command.list.List import List
|
14
13
|
from gibson.command.mcp.McpServer import McpServer
|
15
|
-
from gibson.command.Merge import Merge
|
16
14
|
from gibson.command.Modify import Modify
|
17
15
|
from gibson.command.new.New import New
|
18
16
|
from gibson.command.Question import Question
|
@@ -58,8 +56,6 @@ class CommandRouter:
|
|
58
56
|
command = Deploy(self.configuration)
|
59
57
|
elif sys.argv[1] == "dev":
|
60
58
|
command = Dev(self.configuration)
|
61
|
-
elif sys.argv[1] == "forget":
|
62
|
-
command = Forget(self.configuration)
|
63
59
|
elif sys.argv[1] == "help":
|
64
60
|
command = Help(self.configuration)
|
65
61
|
elif sys.argv[1] == "import":
|
@@ -68,8 +64,6 @@ class CommandRouter:
|
|
68
64
|
command = List(self.configuration)
|
69
65
|
elif sys.argv[1] == "mcp":
|
70
66
|
command = McpServer(self.configuration)
|
71
|
-
elif sys.argv[1] == "merge":
|
72
|
-
command = Merge(self.configuration)
|
73
67
|
elif sys.argv[1] == "modify":
|
74
68
|
command = Modify(self.configuration)
|
75
69
|
elif sys.argv[1] == "new":
|
gibson/services/mcp/server.py
CHANGED
@@ -121,16 +121,17 @@ def submit_data_modeling_request(uuid: str, data_modeling_request: str) -> Dict:
|
|
121
121
|
|
122
122
|
|
123
123
|
@mcp.tool()
|
124
|
-
def deploy_project(uuid: str) -> None:
|
124
|
+
def deploy_project(uuid: str, databases: List[str]) -> None:
|
125
125
|
"""
|
126
|
-
Deploy a GibsonAI project's
|
126
|
+
Deploy a GibsonAI project's database(s).
|
127
|
+
This updates the schema of the database(s) to match the project schema and automatically handles necessary schema migrations.
|
127
128
|
<IMPORTANT>
|
128
|
-
|
129
|
+
You must provide the names of the database(s) to deploy.
|
129
130
|
</IMPORTANT>
|
130
131
|
"""
|
131
132
|
project_api = ProjectApi(Configuration(interactive=False))
|
132
133
|
try:
|
133
|
-
return project_api.deploy(uuid=uuid)
|
134
|
+
return project_api.deploy(uuid=uuid, databases=databases)
|
134
135
|
except HTTPError as e:
|
135
136
|
return error_handler(e)
|
136
137
|
|
@@ -168,9 +169,9 @@ def get_deployed_schema(uuid: str) -> str:
|
|
168
169
|
@mcp.tool()
|
169
170
|
def query_database(api_key: str, query: str) -> List[Dict] | str | Dict:
|
170
171
|
"""
|
171
|
-
Query a GibsonAI project's hosted database using SQL. The
|
172
|
+
Query a GibsonAI project's hosted database using SQL. The database-specific API key must be provided.
|
172
173
|
<IMPORTANT>
|
173
|
-
If you're not sure which
|
174
|
+
If you're not sure which database to use, ask the user for clarification.
|
174
175
|
Always use the correct syntax for the database dialect (found in the project details).
|
175
176
|
Always wrap identifiers in the dialect appropriate quotes (backticks for MySQL, double quotes for PostgreSQL).
|
176
177
|
</IMPORTANT>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gibson-cli
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.11
|
4
4
|
Summary: Gibson Command Line Interface
|
5
5
|
Author-email: GibsonAI <noc@gibsonai.com>
|
6
6
|
Project-URL: Homepage, https://gibsonai.com/
|
@@ -74,7 +74,7 @@ Requires-Dist: watchfiles==1.0.5
|
|
74
74
|
Requires-Dist: websockets==12.0
|
75
75
|
Requires-Dist: yaspin==3.1.0
|
76
76
|
|
77
|
-
[](https://gibsonai.com/)
|
78
78
|
|
79
79
|
# Gibson CLI
|
80
80
|
|
@@ -4,16 +4,16 @@ bin/release.sh,sha256=6pnY_GctbwF-3sZB67b0nzUlTsxlhY1hqJQoqRutXuw,137
|
|
4
4
|
gibson/api/BaseApi.py,sha256=Wza4yuLHhFjkPxt2dhtUtM_r9b5IGd72V80VDl7v3Gw,3510
|
5
5
|
gibson/api/Cli.py,sha256=Qcm5NIQ4x1Wn6KfkrAzwvZeWyt-cKF_xD7_lTWL4Lbw,8071
|
6
6
|
gibson/api/DataApi.py,sha256=JZN6q7bO2O87xBCsU9w96NgINOJJZx3d7jOiHoVH1Wo,542
|
7
|
-
gibson/api/ProjectApi.py,sha256=
|
7
|
+
gibson/api/ProjectApi.py,sha256=esi51ABY_-6IvNlm-Cr29EBVHGWnWHJ1WqEgVsEKPMo,1419
|
8
8
|
gibson/bin/gibson.py,sha256=ybtdrqLfmTb-gG2U7kWSHWSZDvc864omYR9vres38ZU,458
|
9
9
|
gibson/command/BaseCommand.py,sha256=0LdxshtNj8sySMSaDFIPooDbdZx0mNMyhCuyqcF4JsU,769
|
10
10
|
gibson/command/Build.py,sha256=nFwYhO5lpq7cM6oSH6nBA2ubW8wW7aJFsXIwjE1F2EY,4382
|
11
11
|
gibson/command/Conf.py,sha256=yuAGL6M8MUURG4hW3MAW043c-h_ALw3FHWbyCOR8YTQ,2375
|
12
12
|
gibson/command/Count.py,sha256=QOagwCwDxUHYPivFntr-RWUmlKWKDHgDIGZBfju6VpY,1040
|
13
|
-
gibson/command/Deploy.py,sha256
|
13
|
+
gibson/command/Deploy.py,sha256=51EHk-4CZygJcIz9pD-Xnpf1Dat1Qok0OdFLUWfqpuQ,2003
|
14
14
|
gibson/command/Dev.py,sha256=zbZjsgAKAHlNUflEr_Lj2QmRBXNbIGIHrPJ3t5DcFC8,4213
|
15
15
|
gibson/command/Forget.py,sha256=rpUmnHISvQlMgsFwa0p2nndaygy9UvDph3mlOmwlugo,1016
|
16
|
-
gibson/command/Help.py,sha256=
|
16
|
+
gibson/command/Help.py,sha256=LASgmDCmXMORKh6R-979UaZ62NkjZ-E3Ukt8CUXwEfs,4856
|
17
17
|
gibson/command/Merge.py,sha256=R5ybMC1tUR5_T8YyUfXutzFa_V9j1_flv0s7KTJRq0M,1061
|
18
18
|
gibson/command/Modify.py,sha256=XgTM6EodL7sVhWrnWuTCDx2PNJw3xo-aKI80HCmSpV8,1171
|
19
19
|
gibson/command/Question.py,sha256=g8SwopbzeG14WWP0bc-fXIDVqOOicMzjC9YXoGd-NxY,3830
|
@@ -21,7 +21,7 @@ gibson/command/Remove.py,sha256=Ar8-vSNwmCaBupCLY_rcvyU_kWIILU_qVX5njV-tZVw,2478
|
|
21
21
|
gibson/command/Show.py,sha256=qkkprY2JhA4qOOhYOwAECDnFZwTdqcsKsG4cwB_b-84,1409
|
22
22
|
gibson/command/Studio.py,sha256=ZOcXGzrkGGFYtsrxP0qTeComKfUcpTAZWJ9Njd7JfR4,2019
|
23
23
|
gibson/command/Tree.py,sha256=BeJ_13xrrRCK5FP2rQHWpDKrshVzte-_D1pNG1GXPIw,3056
|
24
|
-
gibson/command/Version.py,sha256=
|
24
|
+
gibson/command/Version.py,sha256=bBVxvVc_QD3mpihGMasLqPkSM4G8lR2p0_gKKzIxuO0,1187
|
25
25
|
gibson/command/auth/Auth.py,sha256=DAvnKq3Ks77QJwuGJCWA9Iv3c0Qq5pHFIpEA-gy6CxM,1086
|
26
26
|
gibson/command/auth/Login.py,sha256=4iv3lm-6QNTgtIaszpphyye4eeYOvjU6Ol6ZLmZQZ1I,337
|
27
27
|
gibson/command/auth/Logout.py,sha256=QwW9pCNi61Ak0-1B-3spd_YlsmLYBxzV4uwyO0RYzxg,252
|
@@ -68,7 +68,7 @@ gibson/conf/dev/Schema.py,sha256=kOSlX1jEyVb82xd8TO8jEAimLcaefIFJr6d2JYvyTqg,74
|
|
68
68
|
gibson/conf/tests/test_conf_Dependencies.py,sha256=-MAS3SzB1euHFwFhd0dpyIHYNMYgxEaN2LTeZ1pqc6w,363
|
69
69
|
gibson/conf/tests/test_conf_Platform.py,sha256=Zc53IsZmV-hT9VRrZEPNrsuehSdWnJXWKGMmOhEqWHo,138
|
70
70
|
gibson/core/Colors.py,sha256=sllEmJAb2AAUH0e-ZLP1_C8pfz5U_w0fo5kubSH5g1o,3426
|
71
|
-
gibson/core/CommandRouter.py,sha256=
|
71
|
+
gibson/core/CommandRouter.py,sha256=V3JHyxA_tQnekRMNUg9qqRNjzpEYvtfx7KqRXsh85-s,3446
|
72
72
|
gibson/core/Completions.py,sha256=a26WRh40UpnTT5HGTPT8TCcL8h80HvvZiTJXZofDjx8,1207
|
73
73
|
gibson/core/Configuration.py,sha256=eBGBoCe4rrBxlAUg0-UhKwrQSnyxFoey5jC_FeaGlCI,16689
|
74
74
|
gibson/core/Conversation.py,sha256=KF7YPXijhhz6HOkife__ycHox4WeRKNHIpv3juDPhq0,10237
|
@@ -109,7 +109,7 @@ gibson/services/code/customization/CustomizationManager.py,sha256=M2gz98Yo2WTnnh
|
|
109
109
|
gibson/services/code/customization/Index.py,sha256=4Thf0gZM6VErZJS97w748PRNmHi8QvsyblOLCw1Y_XE,364
|
110
110
|
gibson/services/code/customization/tests/test_code_customization_Authenticator.py,sha256=kKExkLfKPpRA2NQH3fvRCuBEMhCGhR-IvNJqXuyBz3c,1949
|
111
111
|
gibson/services/code/customization/tests/test_code_customization_BaseCustomization.py,sha256=jaEwxxoU7d9ziOtfF21NPmZX2qSRpa-kz_8Ju9BKGts,412
|
112
|
-
gibson/services/mcp/server.py,sha256=
|
112
|
+
gibson/services/mcp/server.py,sha256=FAHlFFeP_fSlhxnUrnxIzoPEQOoFqKKRcaOyvZULsx0,6892
|
113
113
|
gibson/structure/Entity.py,sha256=N_Tx8RTs9ySMMgAoR9rVuMcsRgNA7zvNvJBScJLfYE4,675
|
114
114
|
gibson/structure/mysql/Entity.py,sha256=zolt3N_F3WlQtlOqrHflwsJeJ6r6A3MN4LxCzeAbU_k,3693
|
115
115
|
gibson/structure/mysql/testing.py,sha256=al4LI6e3bhjopsR0qTAmaOJyCQXF0_inVQ4xv7VQ6qo,9149
|
@@ -131,9 +131,8 @@ gibson/structure/tests/test_structure_Entity.py,sha256=askl8w0p1uqET6HKBogJlRcPP
|
|
131
131
|
gibson/tests/test_Env.py,sha256=DPWmP0-aEelducq9bAwv7rKoY2NjWXUeCrzfJDQkn2M,369
|
132
132
|
gibson/tests/test_Memory.py,sha256=YP7owToABAk_-s7fD5UG0HTc4lamDjdA39JUlLnk3Fg,2574
|
133
133
|
gibson/tests/test_utils.py,sha256=r_y-EG05YTCNtL8MWiAK1KmPsmeoMgypKsQC_lVgOtM,559
|
134
|
-
|
135
|
-
gibson_cli-0.8.
|
136
|
-
gibson_cli-0.8.
|
137
|
-
gibson_cli-0.8.
|
138
|
-
gibson_cli-0.8.
|
139
|
-
gibson_cli-0.8.10.dist-info/RECORD,,
|
134
|
+
gibson_cli-0.8.11.dist-info/METADATA,sha256=hpsC-cEM3DJvHfQ4X6cf6wNv47sK2_6mKhK2W3Wb9Sk,14645
|
135
|
+
gibson_cli-0.8.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
136
|
+
gibson_cli-0.8.11.dist-info/entry_points.txt,sha256=j5VUvq3AzL21xPvVC24zMoXFt-I5lUWulr66nL3OAPM,50
|
137
|
+
gibson_cli-0.8.11.dist-info/top_level.txt,sha256=RFaUY7VXGiqkMwo1Rj7pM4kGvxkhhnfo-2LmPpuL_fs,11
|
138
|
+
gibson_cli-0.8.11.dist-info/RECORD,,
|
venv/bin/activate_this.py
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020-202x The virtualenv developers
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
# a copy of this software and associated documentation files (the
|
5
|
-
# "Software"), to deal in the Software without restriction, including
|
6
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
# the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be
|
12
|
-
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
22
|
-
"""
|
23
|
-
Activate virtualenv for current interpreter:
|
24
|
-
|
25
|
-
import runpy
|
26
|
-
runpy.run_path(this_file)
|
27
|
-
|
28
|
-
This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
|
29
|
-
""" # noqa: D415
|
30
|
-
|
31
|
-
from __future__ import annotations
|
32
|
-
|
33
|
-
import os
|
34
|
-
import site
|
35
|
-
import sys
|
36
|
-
|
37
|
-
try:
|
38
|
-
abs_file = os.path.abspath(__file__)
|
39
|
-
except NameError as exc:
|
40
|
-
msg = "You must use import runpy; runpy.run_path(this_file)"
|
41
|
-
raise AssertionError(msg) from exc
|
42
|
-
|
43
|
-
bin_dir = os.path.dirname(abs_file)
|
44
|
-
base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
|
45
|
-
|
46
|
-
# prepend bin to PATH (this file is inside the bin directory)
|
47
|
-
os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
|
48
|
-
os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
|
49
|
-
os.environ["VIRTUAL_ENV_PROMPT"] = "" or os.path.basename(base) # noqa: SIM222
|
50
|
-
|
51
|
-
# add the virtual environments libraries to the host python import mechanism
|
52
|
-
prev_length = len(sys.path)
|
53
|
-
for lib in "../lib/python3.10/site-packages".split(os.pathsep):
|
54
|
-
path = os.path.realpath(os.path.join(bin_dir, lib))
|
55
|
-
site.addsitedir(path)
|
56
|
-
sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
|
57
|
-
|
58
|
-
sys.real_prefix = sys.prefix
|
59
|
-
sys.prefix = base
|
File without changes
|