Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform.libc_ver() fails on Cygwin #40115

Closed
quiver mannequin opened this issue Apr 2, 2004 · 6 comments
Closed

platform.libc_ver() fails on Cygwin #40115

quiver mannequin opened this issue Apr 2, 2004 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@quiver
Copy link
Mannequin

quiver mannequin commented Apr 2, 2004

BPO 928297
Nosy @malemburg

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/malemburg'
closed_at = <Date 2007-01-13.19:29:39.000>
created_at = <Date 2004-04-02.14:55:32.000>
labels = ['library']
title = 'platform.libc_ver() fails on Cygwin'
updated_at = <Date 2007-01-13.19:29:39.000>
user = 'https://bugs.python.org/quiver'

bugs.python.org fields:

activity = <Date 2007-01-13.19:29:39.000>
actor = 'lemburg'
assignee = 'lemburg'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2004-04-02.14:55:32.000>
creator = 'quiver'
dependencies = []
files = []
hgrepos = []
issue_num = 928297
keywords = []
message_count = 6.0
messages = ['20413', '20414', '20415', '20416', '20417', '20418']
nosy_count = 2.0
nosy_names = ['lemburg', 'quiver']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue928297'
versions = ['Python 2.4']

@quiver
Copy link
Mannequin Author

quiver mannequin commented Apr 2, 2004

>>> import platform
>>> platform.libc_ver()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/platform.py", line 134, in libc_ver
    f = open(executable,'rb')
IOError: [Errno 2] No such file or 
directory: '/usr/bin/python'

The problem is that on Cygwin sys.executable
returns /path/to/python, but since Cygwin is running on
Windows, sys.executable is a symbolic link
to /path/to/python.exe.

>>> import os, sys
>>> os.path.exists(sys.executable)
True
>>> os.path.isfile(sys.executable)
True
>>> file(sys.executable)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or 
directory: '/usr/bin/python'
>>> os.path.islink(sys.executable)
True
>>> os.path.realpath(sys.executable)
'/usr/bin/python2.3.exe'
>>> file(sys.executable + '.exe')
<open file '/usr/bin/python.exe', mode 'r' at 0xa100ca0>

Following is the info about the machine I tested:

>>> from platform import *
>>> platform()
'CYGWIN_NT-5.0-1.5.7-0.109-3-2-i686-32bit'
>>> python_compiler()
'GCC 3.3.1 (cygming special)'
>>> python_build()
(1, 'Dec 30 2003 08:29:25')
>>> python_version()
'2.3.3'
>>> uname()
('CYGWIN_NT-5.0', 'my_user_name', '1.5.7
(0.109/3/2)', '2004-01-30 19:32', 'i686', '')

@quiver quiver mannequin closed this as completed Apr 2, 2004
@quiver quiver mannequin assigned malemburg Apr 2, 2004
@quiver quiver mannequin added the stdlib Python modules in the Lib dir label Apr 2, 2004
@malemburg
Copy link
Member

Logged In: YES
user_id=38388

Patches are welcome :-)

I don't have cygwin installed, so there's nothing much
I can do about this.

@quiver
Copy link
Mannequin Author

quiver mannequin commented Apr 3, 2004

Logged In: YES
user_id=671362

First, I need to correct my previous post. 'symbolic' was
unrelated.
Python on Cygwin does't like exe files that doesn't end
with '.exe'.
I think changing fileobject.c to support I/O exe files on
Cygwin whether it ends with '.exe' or not is the way to go.

Is there anyone who can do that? It's beyoond my skill level.

$ ls -l /usr/bin/python*
lrwxrwxrwx  1 abel  Users    24 Jan  1 01:34 /usr/bin/python -
> python2.3.exe
lrwxrwxrwx  1 abel  Users    24 Jan  1 
01:34 /usr/bin/python.exe -> python2.3.exe
-rwxrwxrwx  1 abel  Users  4608 Dec 30 
22:32 /usr/bin/python2.3.exe
>>> file('/usr/bin/python')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: '/usr/bin/python'
>>> file('/usr/bin/python.exe')
<open file '/usr/bin/python.exe', mode 'r' at 0xa069320>
>>> file('/usr/bin/python2.3')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or 
directory: '/usr/bin/python2.3'
>>> file('/usr/bin/python2.3.exe')
<open file '/usr/bin/python2.3.exe', mode 'r' at 0xa0c8de0>

@malemburg
Copy link
Member

Logged In: YES
user_id=38388

Would applying os.path.realpath() to sys.executable before
trying to open that file fix the problem on Cygwin ?

Another question: does using libc_ver() even make sense on
cygwin ?

libc_ver() was never intended to be used on non-*nix
platforms. I don't even know whether it works on other
platforms than Linux.

@quiver
Copy link
Mannequin Author

quiver mannequin commented Jul 29, 2004

Logged In: YES
user_id=671362

Sorry for my late response, Marc.

Would applying os.path.realpath() to sys.executable before
trying to open that file fix the problem on Cygwin ?

That change fixes the IO problem. After this, it doesn't raise
IOError. The result of platform.libc_ver() is as follows:

>>> import platform
>>> platform.libc_ver()
('', '')

Another question: does using libc_ver() even make sense on
cygwin ?

As far as I have checked, it doesn't look like so. According to
the Cygwin FAQ[*], Cygwin doesn't use glibc, although it
says that there's a counterpart(called ``newlib'') in Cygwin. C
runtime embedded into cygwin1.dll uses newlib.

Experienced C & Cygwin programmers might anser this
question more precisely.

[*] Where is glibc? :
http://rustam.uwp.edu/support/faq.html#SEC88

@malemburg
Copy link
Member

Since Cygwin doesn't appear to use the GLibC, there's no surprise in libc_ver() not returning any useful information.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant