Skip to content

Commit 7ee113a

Browse files
Return tuples from _pythoninfo.get_python_info() (#150)
1 parent 94310a3 commit 7ee113a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pyperformance/_pythoninfo.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def get_python_info(python=sys.executable):
6666
)
6767
except subprocess.CalledProcessError:
6868
raise Exception(f'could not get info for {python}')
69-
return json.loads(text)
69+
info = json.loads(text)
70+
# We would use type(sys.version_info) if it allowed it.
71+
info['version_info'] = tuple(info['version_info'])
72+
info['implementation_version'] = tuple(info['implementation_version'])
73+
return info
7074

7175

7276
def inspect_python_install(python=sys.executable):
@@ -169,12 +173,12 @@ def _get_raw_info():
169173
return {
170174
'executable': sys.executable,
171175
'version_str': sys.version,
172-
'version_info': tuple(sys.version_info),
176+
'version_info': sys.version_info,
173177
'hexversion': sys.hexversion,
174178
'api_version': sys.api_version,
175179
'magic_number': MAGIC_NUMBER.hex(),
176180
'implementation_name': sys.implementation.name.lower(),
177-
'implementation_version': tuple(sys.implementation.version),
181+
'implementation_version': sys.implementation.version,
178182
'platform': sys.platform,
179183
'prefix': sys.prefix,
180184
'exec_prefix': sys.exec_prefix,
@@ -191,7 +195,8 @@ def _get_raw_info():
191195

192196
if __name__ == '__main__':
193197
info = _get_raw_info()
194-
(info['_base_executable'], info['_is_dev'], info['_is_venv'],
195-
) = _inspect_python_install(**info)
198+
if '--inspect' in sys.argv:
199+
(info['_base_executable'], info['_is_dev'], info['_is_venv'],
200+
) = _inspect_python_install(**info)
196201
json.dump(info, sys.stdout, indent=4)
197202
print()

pyperformance/tests/test_pythoninfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
INFO = {
1010
'executable': sys.executable,
1111
'version_str': sys.version,
12-
'version_info': tuple(sys.version_info),
12+
'version_info': sys.version_info,
1313
'hexversion': sys.hexversion,
1414
'api_version': sys.api_version,
1515
# importlib.util.MAGIC_NUMBER has been around since 3.5.
1616
'magic_number': importlib.util.MAGIC_NUMBER.hex(),
1717
'implementation_name': sys.implementation.name.lower(),
18-
'implementation_version': tuple(sys.implementation.version),
18+
'implementation_version': sys.implementation.version,
1919
'platform': sys.platform,
2020
'prefix': sys.prefix,
2121
'exec_prefix': sys.exec_prefix,

0 commit comments

Comments
 (0)