FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-python/pythonFiles/create_microvenv.py at main · Spitfire1900/vscode-python · GitHub
Spitfire1900
/
vscode-python
Public
forked from
microsoft/vscode-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-python
/
pythonFiles
/
create_microvenv.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (44 loc) · 1.4 KB
Breadcrumbs
vscode-python
/
pythonFiles
/
create_microvenv.py
Copy path
File metadata and controls
60 lines (44 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import
argparse
import
os
import
pathlib
import
subprocess
import
sys
from
typing
import
Optional
,
Sequence
VENV_NAME
=
".venv"
LIB_ROOT
=
pathlib
.
Path
(
__file__
).
parent
/
"lib"
/
"python"
CWD
=
pathlib
.
Path
.
cwd
()
class
MicroVenvError
(
Exception
):
pass
def
run_process
(
args
:
Sequence
[
str
],
error_message
:
str
)
->
None
:
try
:
print
(
"Running: "
+
" "
.
join
(
args
))
subprocess
.
run
(
args
,
cwd
=
os
.
getcwd
(),
check
=
True
)
except
subprocess
.
CalledProcessError
:
raise
MicroVenvError
(
error_message
)
def
parse_args
(
argv
:
Sequence
[
str
])
->
argparse
.
Namespace
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--name"
,
default
=
VENV_NAME
,
type
=
str
,
help
=
"Name of the virtual environment."
,
metavar
=
"NAME"
,
action
=
"store"
,
)
return
parser
.
parse_args
(
argv
)
def
create_microvenv
(
name
:
str
):
run_process
(
[
sys
.
executable
,
os
.
fspath
(
LIB_ROOT
/
"microvenv.py"
),
name
],
"CREATE_MICROVENV.MICROVENV_FAILED_CREATION"
,
)
def
main
(
argv
:
Optional
[
Sequence
[
str
]]
=
None
)
->
None
:
if
argv
is
None
:
argv
=
[]
args
=
parse_args
(
argv
)
print
(
"CREATE_MICROVENV.CREATING_MICROVENV"
)
create_microvenv
(
args
.
name
)
print
(
"CREATE_MICROVENV.CREATED_MICROVENV"
)
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
Back
|
FazBrowse Home
|
New Git URL