Checking for libc vs. glibc using Python
Mark C Favas
mark at chem.uwa.edu.au
Thu Oct 21 10:24:48 EDT 1999
Charles G Waldman <cgw at fnal.gov> writes:
>M.-A. Lemburg writes:
> > Is it possible to examine a Python interpreter and check whether
> > it was compiled against libc5 or glibc2 (libc6) on Linux/*BSD/etc. ?
> >
> > I'm currently using this hack, but would appreciate a more
> > elegant and portable solution:
> > def system_nm(progfile):
>I would use "ldd" instead of "nm". It's another hack, not much more
>elegant, but a little more portable. In particular it doesn't require
>that python was compiled -g.
The problem is that nm is far more generally available than ldd... so ldd
in fcat is less portable.... (I've not seen a *nix (or Tru64!) that doesn't
have nm, but very few that have ldd - I thought it was a Sunism...)
>I'm not sure how much the ldd output varies on different unices
>(haven't tried this on BSD), but I think it should be pretty easy to
>find a portable way search for the libc.so.* line in the output and
>figure out the libc version.
>This will fail if libc is linked statically, as far as I know this is
>rarely done. It's still less of a restriction than requiring python
>to be built with debugging info.
>It's still not exactly elegant but possibly a little more portable than
>what you were doing.
--
Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas
Phone - +61 9 380 3482 / \ Department of Chemistry
Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia
v Nedlands
Loc - 31.97 S, 115.81 E Western Australia 6009
More information about the Python-list
mailing list