Skip to content

Commit b11ef7b

Browse files
committed
Merged pull request #30 (PyPy3 support follow-up)
2 parents 9046f4c + 21206d1 commit b11ef7b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

py2deb/utils.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Authors:
44
# - Arjan Verwer
55
# - Peter Odding <peter.odding@paylogic.com>
6-
# Last Change: December 16, 2018
6+
# Last Change: July 28, 2020
77
# URL: https://py2deb.readthedocs.io
88

99
"""The :mod:`py2deb.utils` module contains miscellaneous code."""
@@ -37,6 +37,7 @@
3737
3838
- pypy
3939
- pypy2.7
40+
- pypy3
4041
- python
4142
- python2
4243
- python2.7
@@ -227,12 +228,10 @@ def default_name_prefix():
227228
228229
:returns: One of the strings ``python``, ``python3`` or ``pypy``.
229230
"""
230-
if platform.python_implementation() == 'PyPy':
231-
return 'pypy'
232-
elif sys.version_info[0] == 3:
233-
return 'python3'
234-
else:
235-
return 'python'
231+
implementation = 'pypy' if platform.python_implementation() == 'PyPy' else 'python'
232+
if sys.version_info[0] == 3:
233+
implementation += '3'
234+
return implementation
236235

237236

238237
def detect_python_script(handle):
@@ -403,12 +402,14 @@ def python_version():
403402
- The name of the Debian package providing the current Python version.
404403
- The name of the interpreter executable for the current Python version.
405404
406-
:returns: A string like ``python2.7``, ``python3.7`` or ``pypy``.
405+
:returns: A string like ``python2.7``, ``python3.8``, ``pypy`` or ``pypy3``.
407406
"""
408-
python_version = (
409-
'pypy' if platform.python_implementation() == 'PyPy'
410-
else 'python%d.%d' % sys.version_info[:2]
411-
)
407+
if platform.python_implementation() == 'PyPy':
408+
python_version = 'pypy'
409+
if sys.version_info[0] == 3:
410+
python_version += '3'
411+
else:
412+
python_version = 'python%d.%d' % sys.version_info[:2]
412413
logger.debug("Detected Python version: %s", python_version)
413414
return python_version
414415

0 commit comments

Comments
 (0)