forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_local_runtime_info.py
More file actions
50 lines (47 loc) · 1.82 KB
/
get_local_runtime_info.py
File metadata and controls
50 lines (47 loc) · 1.82 KB
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
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import sys
import sysconfig
data = {
"major": sys.version_info.major,
"minor": sys.version_info.minor,
"micro": sys.version_info.micro,
"include": sysconfig.get_path("include"),
"implementation_name": sys.implementation.name,
"base_executable": sys._base_executable,
}
config_vars = [
# The libpythonX.Y.so file. Usually?
# It might be a static archive (.a) file instead.
"LDLIBRARY",
# The directory with library files. Supposedly.
# It's not entirely clear how to get the directory with libraries.
# There's several types of libraries with different names and a plethora
# of settings.
# https://stackoverflow.com/questions/47423246/get-pythons-lib-path
# For now, it seems LIBDIR has what is needed, so just use that.
"LIBDIR",
# The versioned libpythonX.Y.so.N file. Usually?
# It might be a static archive (.a) file instead.
"INSTSONAME",
# The libpythonX.so file. Usually?
# It might be a static archive (a.) file instead.
"PY3LIBRARY",
# The platform-specific filename suffix for library files.
# Includes the dot, e.g. `.so`
"SHLIB_SUFFIX",
]
data.update(zip(config_vars, sysconfig.get_config_vars(*config_vars)))
print(json.dumps(data))