[Python-checkins] cpython: Cleanup: use sys.version_info instead of convoluted hexversion lshifts

eric.araujo python-checkins at python.org
Tue Aug 30 16:22:11 CEST 2011


http://hg.python.org/cpython/rev/f93acf8844ec
changeset:   72124:f93acf8844ec
user:        Éric Araujo <merwok at netwok.org>
date:        Mon Aug 29 21:43:48 2011 +0200
summary:
  Cleanup: use sys.version_info instead of convoluted hexversion lshifts

files:
  Lib/packaging/command/build_ext.py |  17 ++++++-----------
  1 files changed, 6 insertions(+), 11 deletions(-)


diff --git a/Lib/packaging/command/build_ext.py b/Lib/packaging/command/build_ext.py
--- a/Lib/packaging/command/build_ext.py
+++ b/Lib/packaging/command/build_ext.py
@@ -606,8 +606,7 @@
                 template = "python%d%d"
                 if self.debug:
                     template = template + '_d'
-                pythonlib = (template %
-                       (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+                pythonlib = template % sys.version_info[:2]
                 # don't extend ext.libraries, it may be shared with other
                 # extensions, it is a reference to the original list
                 return ext.libraries + [pythonlib]
@@ -621,22 +620,19 @@
             # not at this time - AIM Apr01
             #if self.debug:
             #    template = template + '_d'
-            pythonlib = (template %
-                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            pythonlib = template % sys.version_info[:2]
             # don't extend ext.libraries, it may be shared with other
             # extensions, it is a reference to the original list
             return ext.libraries + [pythonlib]
         elif sys.platform[:6] == "cygwin":
             template = "python%d.%d"
-            pythonlib = (template %
-                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            pythonlib = template % sys.version_info[:2]
             # don't extend ext.libraries, it may be shared with other
             # extensions, it is a reference to the original list
             return ext.libraries + [pythonlib]
         elif sys.platform[:6] == "atheos":
             template = "python%d.%d"
-            pythonlib = (template %
-                   (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+            pythonlib = template % sys.version_info[:2]
             # Get SHLIBS from Makefile
             extra = []
             for lib in sysconfig.get_config_var('SHLIBS').split():
@@ -654,9 +650,8 @@
 
         else:
             if sysconfig.get_config_var('Py_ENABLE_SHARED'):
-                pythonlib = 'python{}.{}{}'.format(
-                    sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
-                    sys.abiflags)
+                template = 'python%d%d' + sys.abiflags
+                pythonlib = template % sys.version_info[:2]
                 return ext.libraries + [pythonlib]
             else:
                 return ext.libraries

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list