[GRASS-dev] grass7 on mac OSX

William Kyngesburye woklist at kyngchaos.com
Fri Jun 4 18:08:58 EDT 2010


On Jun 4, 2010, at 1:04 PM, Glynn Clements wrote:

> 
> Barton Michael wrote:
> 
>> Once you or others think there is a potential fix for GRASS for OSX,
>> I'm happy to give it a try.
> 
> Can you try the latest version? It will still fail, but it should
> provide more information (specifically, the "invalid \x escape"
> exception should now report the string that it's trying to decode).
> 
> ctypesgen ignores errors from the preprocessor, but errors within
> ctypesgen itself (e.g. the decoding error) tend to be fatal.
> 
> FWIW, the code acknowledges that the decoding may not be quite right
> (it decodes string literals according to Python's syntax, which is
> modelled on C but may have subtle differences):
> 
>        # Unescaping probably not perfect but close enough.
>        value = value[1:-1].decode('string_escape')
> 
> The Python language reference says of \x escapes:
> 
> 	Unlike in Standard C, exactly two hex digits are required
> 
> Assuming that's the issue, it should suffice to replace the above
> with:
> 
> 	try:
> 	    value = value[1:-1].decode('string_escape')
> 	except ValueError, e:
> 	    value = re.sub(r'\\x([0-9a-fA-F])(?![0-9a-fA-F])',
> 	                   r'\x0\1',
> 	                   value[1:-1]).decode('string_escape')
> 

I had to restore the -U __GNUC__.  Without it, I get a lot of syntax errors in GRASS headers.  With, though I get that unknown architecture error in nviz.py.  The ctypesgen authors seem to be aware of and patch OSX issues, but maybe they never tried it with system framework headers.

Besides that, both with and without __GNUC__, there is the escape error in nviz.py:

Error: gcc -E: /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FixMath.h:93:6: error: #error "Unknown architecture."
Traceback (most recent call last):
  File "./ctypesgen.py", line 134, in <module>
    descriptions=ctypesgencore.parser.parse(options.headers,options)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/__init__.py", line 21, in parse
    parser.parse()
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/datacollectingparser.py", line 67, in parse
    ctypesparser.CtypesParser.parse(self,f.name,None)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/cparser.py", line 113, in parse
    self.preprocessor_parser.parse(filename)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 195, in parse
    token = self.lexer.token()
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/preprocessor.py", line 51, in token
    result = lex.Lexer.token(self)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/lex.py", line 297, in token
    newtok = func(tok)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py", line 237, in t_ANY_string_literal
    t.value = StringLiteral(t.value)
  File "/Users/Shared/src/GRASS/svn/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py", line 63, in __new__
    raise ValueError("invalid \\x escape in %s" % value)
ValueError: invalid \x escape in ".HFS+ Private Directory Data\xd"

I found that string in /usr/include/hfs/hfs_format.h:

#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"

Probably included somewhere in the trail from ApplicationServices.h.  Looks like a single-digit escape, so I tried your re.sub above.  It then makes it thru that ValueError, but then there are tons of syntax errors in system headers.  One example:

Error: /System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:820: Syntax error at '{'
Error: /System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:821: Syntax error at '>='

This is the code there:

CF_INLINE Boolean CFStringIsSurrogateHighCharacter(UniChar character) {
    return ((character >= 0xD800UL) && (character <= 0xDBFFUL) ? true : false);
}

There are more similar CF_INLINE definitions earlier, but they are inside a #ifdef CF_INLINE.

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

The equator is so long, it could encircle the earth completely once.



More information about the grass-dev mailing list