FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pre-commit/testing/zipapp/python at map-manifest · pre-commit/pre-commit · GitHub
pre-commit
pre-commit
Repository navigation
Code
Issues
17
(17)
Pull requests
8
(8)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
pre-commit
/
testing
/
zipapp
/
python
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
47 lines (39 loc) · 1.42 KB
Breadcrumbs
pre-commit
/
testing
/
zipapp
/
python
Copy path
File metadata and controls
executable file
·
47 lines (39 loc) · 1.42 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
#!/usr/bin/env python3
"""A shim executable to put dependencies on sys.path"""
from
__future__
import
annotations
import
argparse
import
os
.
path
import
runpy
import
sys
# an exe-zipapp will have a __file__ of shim.exe/__main__.py
EXE
=
__file__
if
os
.
path
.
isfile
(
__file__
)
else
os
.
path
.
dirname
(
__file__
)
EXE
=
os
.
path
.
realpath
(
EXE
)
HERE
=
os
.
path
.
dirname
(
EXE
)
WHEELDIR
=
os
.
path
.
join
(
HERE
,
'wheels'
)
SITE_DIRS
=
frozenset
((
'dist-packages'
,
'site-packages'
))
def
main
()
->
int
:
parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
parser
.
add_argument
(
'-m'
)
args
,
rest
=
parser
.
parse_known_args
()
if
args
.
m
:
# try and remove site-packages from sys.path so our packages win
sys
.
path
[:]
=
[
p
for
p
in
sys
.
path
if
os
.
path
.
split
(
p
)[
1
]
not
in
SITE_DIRS
]
for
wheel
in
sorted
(
os
.
listdir
(
WHEELDIR
)):
sys
.
path
.
append
(
os
.
path
.
join
(
WHEELDIR
,
wheel
))
if
args
.
m
==
'pre_commit'
or
args
.
m
.
startswith
(
'pre_commit.'
):
sys
.
executable
=
EXE
sys
.
argv
[
1
:]
=
rest
runpy
.
run_module
(
args
.
m
,
run_name
=
'__main__'
,
alter_sys
=
True
)
return
0
else
:
cmd
=
(
sys
.
executable
,
*
sys
.
argv
[
1
:])
if
sys
.
platform
==
'win32'
:
# https://bugs.python.org/issue19124
import
subprocess
return
subprocess
.
call
(
cmd
)
else
:
os
.
execvp
(
cmd
[
0
],
cmd
)
if
__name__
==
'__main__'
:
raise
SystemExit
(
main
())
Back
|
FazBrowse Home
|
New Git URL