FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pytype/setup.py at main · ag-python/pytype · GitHub
ag-python
/
pytype
Public
forked from
google/pytype
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
pytype
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
116 lines (97 loc) · 3.77 KB
Breadcrumbs
pytype
/
setup.py
Copy path
File metadata and controls
116 lines (97 loc) · 3.77 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
"""Pytype setup file."""
# pylint: disable=bad-indentation
import
glob
import
os
import
re
import
shutil
import
sys
from
setuptools
import
setup
# Path to directory containing setup.py
here
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
# Get the pybind11 setup helpers
#
# This is appended, so if already available in site-packages, that is used
# instead
sys
.
path
.
append
(
os
.
path
.
join
(
here
,
"pybind11"
))
from
pybind11
.
setup_helpers
import
Pybind11Extension
# pylint: disable=g-import-not-at-top,wrong-import-position
def
get_typegraph_ext
():
"""Generates the typegraph extension."""
return
Pybind11Extension
(
'pytype.typegraph.cfg'
,
sources
=
[
"pytype/typegraph/cfg.cc"
,
"pytype/typegraph/cfg_logging.cc"
,
"pytype/typegraph/pylogging.cc"
,
"pytype/typegraph/reachable.cc"
,
"pytype/typegraph/solver.cc"
,
"pytype/typegraph/typegraph.cc"
,
],
depends
=
[
"pytype/typegraph/cfg_logging.h"
,
"pytype/typegraph/map_util.h"
,
"pytype/typegraph/memory_util.h"
,
"pytype/typegraph/pylogging.h"
,
"pytype/typegraph/reachable.h"
,
"pytype/typegraph/solver.h"
,
"pytype/typegraph/typegraph.h"
,
],
cxx_std
=
11
,
)
def
copy_typeshed
():
"""Windows install workaround: copy typeshed if the symlink doesn't work."""
internal_typeshed
=
os
.
path
.
join
(
here
,
'pytype'
,
'typeshed'
)
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
internal_typeshed
,
'stdlib'
)):
if
os
.
path
.
exists
(
internal_typeshed
):
# If it is a symlink, remove it
try
:
os
.
remove
(
internal_typeshed
)
except
OSError
:
# This might be a directory that has not got a complete typeshed
# installation in it; delete and copy it over again.
shutil
.
rmtree
(
internal_typeshed
)
shutil
.
copytree
(
os
.
path
.
join
(
here
,
'typeshed'
),
internal_typeshed
)
def
scan_package_data
(
path
,
pattern
,
check
):
"""Scan for files to be included in package_data."""
# We start off in the setup.py directory, but package_data is relative to
# the pytype/ directory.
package_dir
=
'pytype'
path
=
os
.
path
.
join
(
*
path
)
full_path
=
os
.
path
.
join
(
package_dir
,
path
)
result
=
[]
for
subdir
,
_
,
_
in
os
.
walk
(
full_path
):
full_pattern
=
os
.
path
.
join
(
subdir
,
pattern
)
if
glob
.
glob
(
full_pattern
):
# Once we know that it matches files, we store the pattern itself,
# stripping off the prepended pytype/
result
.
append
(
os
.
path
.
relpath
(
full_pattern
,
package_dir
))
assert
os
.
path
.
join
(
path
,
*
check
)
in
result
return
result
def
get_data_files
():
builtins
=
scan_package_data
([
'stubs'
,
'builtins'
],
'*.pytd'
,
check
=
[
'attr'
,
'*.pytd'
])
stdlib
=
scan_package_data
([
'stubs'
,
'stdlib'
],
'*.pytd'
,
check
=
[
'*.pytd'
])
typeshed
=
(
scan_package_data
([
'typeshed'
],
'*.pyi'
,
check
=
[
'stdlib'
,
'*.pyi'
])
+
[
'typeshed/stdlib/VERSIONS'
]
+
scan_package_data
([
'typeshed'
],
'METADATA.toml'
,
check
=
[
'stubs'
,
'six'
,
'METADATA.toml'
]))
merge_pyi_grammar
=
[
'tools/merge_pyi/Grammar.txt'
]
return
builtins
+
stdlib
+
typeshed
+
merge_pyi_grammar
def
get_long_description
():
# Read the long-description from a file.
with
open
(
os
.
path
.
join
(
here
,
'README.md'
),
encoding
=
'utf-8'
)
as
f
:
desc
=
'
\n
'
+
f
.
read
()
# Fix relative links to the pytype docs.
return
re
.
sub
(
r'\[(.+)\]: docs/'
,
r'[\g<1>]: https://github.com/google/pytype/blob/main/docs/'
,
desc
)
copy_typeshed
()
# Only options configured at build time are declared here, everything else is
# declared in setup.cfg
setup
(
long_description
=
get_long_description
(),
package_data
=
{
'pytype'
:
get_data_files
()},
ext_modules
=
[
get_typegraph_ext
()],
)
Back
|
FazBrowse Home
|
New Git URL