[Distutils] platform management

Bill Janssen janssen at parc.com
Wed Mar 19 00:59:45 CET 2008

I don't think this is bike-shedding.

The debate about "AMD64" vs. "amd64" vs. "x86_64" reminded me that
I've been bit more and more frequently by bits of platform-specific
knowledge scattered around the standard library.  The latest is the
code in distutils.unixccompiler that tries to figure out what flags to
send to the linker in order to add a dynamic library path lookup to a
shared library.

There are lots of different ways of figuring out which platform is
being used, and they're all over the place.  The code in
distutils.unixccompiler uses "sys.platform[:6]", and looks for
"darwin"; the code in urllib.py uses "os.name", and expects it to be
"mac", but later looks for "sys.platform == 'darwin'; posixfile
believes that platforms come with version numbers ("linux2", "aix4");
pydoc and tarfile have tests for "sys.platform == 'mac'".  tempfile
looks at os.sys.platform *and* os.name.

Could well be that all of these are correct (I believe that "mac", for
instance, refers to the generations of the Mac OS before OS X).  But
it means that when someone tries to update "Python" to a new major
version release for, say, OS X, it's really easy to miss things.  And
the fact that the platform version is sometimes included and sometimes
not is also problematic; darwin9 is different from darwin8 in some
important aspects.

It would be nice to

  (a) come up with a list of standard platform symbols,
  (b) put those symbols somewhere in the documentation,
  (c) have one way of discovering them, via sys or os or platform or
      whichever module,
  (d) add a standard way of discovering the platform version, and
  (e) stamp out all the other ways that have crept in over the years.


More information about the Distutils-SIG mailing list