FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-python/pythonFiles/install_debugpy.py at main · MarkusLC/vscode-python · GitHub
MarkusLC
/
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
/
install_debugpy.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (49 loc) · 2.06 KB
Breadcrumbs
vscode-python
/
pythonFiles
/
install_debugpy.py
Copy path
File metadata and controls
66 lines (49 loc) · 2.06 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
61
62
63
64
65
66
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import
io
import
json
import
os
import
urllib
.
request
as
url_lib
import
zipfile
from
packaging
.
version
import
parse
as
version_parser
EXTENSION_ROOT
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
DEBUGGER_DEST
=
os
.
path
.
join
(
EXTENSION_ROOT
,
"pythonFiles"
,
"lib"
,
"python"
)
DEBUGGER_PACKAGE
=
"debugpy"
DEBUGGER_PYTHON_ABI_VERSIONS
=
(
"cp39"
,)
DEBUGGER_VERSION
=
"1.6.3"
# can also be "latest"
def
_contains
(
s
,
parts
=
()):
return
any
(
p
for
p
in
parts
if
p
in
s
)
def
_get_package_data
():
json_uri
=
"https://pypi.org/pypi/{0}/json"
.
format
(
DEBUGGER_PACKAGE
)
# Response format: https://warehouse.readthedocs.io/api-reference/json/#project
# Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst
with
url_lib
.
urlopen
(
json_uri
)
as
response
:
return
json
.
loads
(
response
.
read
())
def
_get_debugger_wheel_urls
(
data
,
version
):
return
list
(
r
[
"url"
]
for
r
in
data
[
"releases"
][
version
]
if
_contains
(
r
[
"url"
],
DEBUGGER_PYTHON_ABI_VERSIONS
)
)
def
_download_and_extract
(
root
,
url
,
version
):
root
=
os
.
getcwd
()
if
root
is
None
or
root
==
"."
else
root
print
(
url
)
with
url_lib
.
urlopen
(
url
)
as
response
:
data
=
response
.
read
()
with
zipfile
.
ZipFile
(
io
.
BytesIO
(
data
),
"r"
)
as
wheel
:
for
zip_info
in
wheel
.
infolist
():
# Ignore dist info since we are merging multiple wheels
if
".dist-info/"
in
zip_info
.
filename
:
continue
print
(
"
\t
"
+
zip_info
.
filename
)
wheel
.
extract
(
zip_info
.
filename
,
root
)
def
main
(
root
):
data
=
_get_package_data
()
if
DEBUGGER_VERSION
==
"latest"
:
use_version
=
max
(
data
[
"releases"
].
keys
(),
key
=
version_parser
)
else
:
use_version
=
DEBUGGER_VERSION
for
url
in
_get_debugger_wheel_urls
(
data
,
use_version
):
_download_and_extract
(
root
,
url
,
use_version
)
if
__name__
==
"__main__"
:
main
(
DEBUGGER_DEST
)
Back
|
FazBrowse Home
|
New Git URL