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.

classification
Title: sys.version[:3] gives incorrect version
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nascheme Nosy List: gvanrossum, loewis, nascheme, pearu
Priority: normal Keywords:

Created on 2003-01-05 17:10 by pearu, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (7)
msg13877 - (view) Author: Pearu Peterson (pearu) Date: 2003-01-05 17:10
sys.version[:3] is used in several places [*] for
Python version and in most cases it is OK.
However, when Python is build/installed, say, with
  make all install VERSION=2.2.2
then sys.version[:3] does not represent Python version
correctly anymore. For example, the path to Python Lib
is then
  <prefix>/lib/python2.2.2/
but e.g. distutils finds it as
  <prefix>/lib/python2.2/
which obviously causes either an exception or a silent
incorrect behaviour [**] when trying to use distutils.

Note about fix: I don't have it but simply replacing
sys.version[:3] with
sys.version.split()[0] will not work.

Best regards, Pearu

[*] Running
  grep  "sys.version\[:3\]" {*,*/*,*/*/*}.py
in the Python Lib tree shows 8 matches for Python 2.2.2.

[**] .. e.g. when one has other Python installed with
VERSION=2.2
msg13878 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-05 23:14
Logged In: YES 
user_id=21627

I would suggest that 'make all install VERSION=2.2.2' is not
supported, so this does not need to be fixed.
msg13879 - (view) Author: Pearu Peterson (pearu) Date: 2003-01-05 23:40
Logged In: YES 
user_id=88489

A note: according to Python README Installation section,
make
make altinstall VERSION=2.2.2
is "legal". From reading the generated Makefile, the above seems
to be identical to 'make all install VERSION=2.2.2', but I
haven't
actually tried it out, though, so I might be wrong.
If fixing this issue is too difficult, that's fine with me.
One can
always use --prefix= as a workaround when configuring Python.
msg13880 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-06 09:54
Logged In: YES 
user_id=21627

I see. What you have been doing is indeed documented as
supported. Unfortunately, there is currently no way in which
distutils could find out what VERSION is. So if this is
intended to work, we need to expose VERSION somewhere.
msg13881 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-12 14:20
Logged In: YES 
user_id=6380

I don't know who added that to README, but that was never
inteded usage, so I'd suggest to undocument it. There's no
support for such usage and I don't think it's needed. If you
want to install a variant like that, use prefix=<something
else>.
msg13882 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-01-14 08:23
Logged In: YES 
user_id=21627

Assigning to Neil, since he documented that feature.
msg13883 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2003-01-15 16:08
Logged In: YES 
user_id=35752

I've removed that section from the README.
History
Date User Action Args
2022-04-10 16:06:06adminsetgithub: 37720
2003-01-05 17:10:16pearucreate