On 3-feb-2006, at 20:51, Bob Ippolito wrote:
Since this is GCC, the #ifndef __LITTLE_ENDIAN__ branch is always false... so I'm making this a compile-time not configure-time value, but I left in the configure-time stuff for other platforms.Did you test this? I'd be surprised if distutils honours the ifdef statement. Luckily the easiest way to find the byteorder is sys.byteorder.Yes, I ran the test suite on PPC with a PPC-built build and on i386 with and without Rosetta on a i386 build... I didn't test the PPC- built version on an i386, but I'm going to assume it works for now since the two possible outputs above are logically equivalent.
I meant fetching WORDS_BIGENDIAN using distutils :-). Not that I think anyone actually does this. I had no doubt about your trick w.r.t. building python or extensions.
distutils does know how to parse and find pyconfig.h (sysconfig.parse_config_h, get_config_h_filename), but Python itself only uses that functionality in the main setup.py. Surprisingly, the main setup.py parses pyconfig.h twice (once with distutils, once without -- good job there), but it of course doesn't go anywhere near WORDS_BIGENDIAN.Packages that use WORDS_BIGENDIAN from distutils are broken. There's nothing we can do to fix that short of patching the package. Fortunately I don't think any package is dumb enough to do that.
We could patch distutils to derive WORDS_BIGENDIAN from sys.byteorder.
Packages that do something with sys.byteorder at setup.py time are probably going to be broken also... but I've never seen that either.
These are not broken, its just harder to create universal binaries for them. I know that cElementTree uses sys.byteorder to calculate the right flags for compiling expat and wouldn't be surprised if other packages that wrap expat use the same mechanism.
I have a patched version of pyconfig.h that #includes "macosx- config.h" at the end. This file redefines a number of values based on the cpu-type. Anyone that grabs CPU information from pyconfig.h will get the values from the platform that was used to generate pyconfig.h (an intel system in my case). I like your trick better, mine is a bit too elaborate and not needed until someone wants to do a ppc64 build.sys.byteorder is actually determined at runtime: unsigned long number = 1; char *value; s = (char *) &number; if (s[0] == 0) value = "big"; else value = "little"; PyDict_SetItemString(sysdict, "byteorder", v = PyString_FromString(value)); Py_XDECREF(v);
I know that. I've looked into eliminating WORDS_BIGENDIAN and the SIZEOF_* defines and decided this was a bit too much work for now. Odly enough WORDS_BIGENDIAN is used elsewhere in the sourcecode, not using that define here just complicates the code.
Ronald
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig