This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: get_python_version is not import in
Type: behavior Stage: resolved
Components: Distutils Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: dmi.baranov, eric.araujo, l, maoliping455, ncoghlan, python-dev, tarek
Priority: normal Keywords: patch

Created on 2013-05-24 00:37 by maoliping455, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
issue18045.patch dmi.baranov, 2013-05-27 21:39 review
issue18045-py27.diff l, 2013-09-04 20:04 Add missing import statement review
Messages (7)
msg189888 - (view) Author: Matt Mao (maoliping455) Date: 2013-05-24 00:37
Python version : 2.7.5
OS             : CentOS 6.3

When I tried to build a rpm with "python ./ bdist_rpm", I get the following error :

Traceback (most recent call last):
  File "", line 221, in <module>
    ...  and much more ;)"""
  File "/usr/local/python2.7/lib/python2.7/distutils/", line 152, in setup
  File "/usr/local/python2.7/lib/python2.7/distutils/", line 953, in run_commands
  File "/usr/local/python2.7/lib/python2.7/distutils/", line 972, in run_command
  File "/usr/local/python2.7/lib/python2.7/python2.7/distutils/command/", line 383, in run
    pyversion = get_python_version()
NameError: global name 'get_python_version' is not defined

I find that we do not import function get_python_version in python2.7/distutils/command/
I think we need to add “from distutils.sysconfig import get_python_version” in this file.
msg190155 - (view) Author: Dmi Baranov (dmi.baranov) * Date: 2013-05-27 21:39
Added a patch. Not covered by test, because this case require external module in test package definition.
msg190364 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-05-30 15:25
Thanks for catching this.  I think the patch is incorrect when it replaces “from sysconfig import get_python_version” by “from distutils.sysconfig import get_python_version”; it should only add the missing import in, not touch the other modules.
msg190368 - (view) Author: Dmi Baranov (dmi.baranov) * Date: 2013-05-30 15:54
I would agree that the patch is incorrect, if it was produced with additional refactoring or changes in functionality, not described in the issue. It's just a PEP8 compliance at package level.
msg196947 - (view) Author: Lukas Wunner (l) Date: 2013-09-04 20:04
The attached patch adds just the missing import statement (which already exists in all 3.x versions) and changes nothing else.
msg213223 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-03-12 09:04
New changeset 677327810121 by Éric Araujo in branch '2.7':
Fix missing import in bdist_rpm (#18045)
msg213224 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 09:04
Thanks for the report and patches.
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62245
2014-03-12 09:04:42eric.araujosetstatus: open -> closed
resolution: fixed
messages: + msg213224

stage: patch review -> resolved
2014-03-12 09:04:07python-devsetnosy: + python-dev
messages: + msg213223
2013-09-04 20:04:25lsetfiles: + issue18045-py27.diff
nosy: + l
messages: + msg196947

2013-06-03 12:54:09ncoghlansetnosy: + ncoghlan
2013-05-30 15:54:11dmi.baranovsetmessages: + msg190368
2013-05-30 15:25:53eric.araujosetmessages: + msg190364
2013-05-30 08:54:06berker.peksagsettype: behavior
stage: patch review
2013-05-30 08:52:32berker.peksaglinkissue18051 superseder
2013-05-27 21:39:36dmi.baranovsetfiles: + issue18045.patch

nosy: + dmi.baranov
messages: + msg190155

keywords: + patch
2013-05-24 00:37:22maoliping455create