On Apr 25, 2008, at 10:11 AM, Stefan Behnel wrote: > Hi, > > I just checked in a little fix to allow running cython directly > on .py files > (instead of requiring .pyx files). That gave me the idea of > actually running > it on Cython itself, since people have been complaining from time > to time that > the compiler is slow for certain sources. > > There are a couple of things in the sources that do not compile, I > attached a > log. Some of them should get fixed in the sources (like tuples in > function > signatures, which go away in Py3), but some also show stuff that > Cython does > not currently support, so there are things to implement. > > It would be cool if we could get Cython into compiling itself. I > think that's > a target worth going for, and I'm close to believing that it's not > far away at > all.
That would be very cool, and it's something I've been thinking about too. Most of the stuff that is broken is on our todo list already. - Robert > > Stefan > Compiling Cython/Plex/Actions.py > Compiling Cython/Plex/DFA.py > Compiling Cython/Plex/Errors.py > Compiling Cython/Plex/__init__.py > Compiling Cython/Plex/Lexicons.py > Compiling Cython/Plex/Machines.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > return tuple(result) > > def ranges_to_string(self, range_list): > return string.join(map(self.range_to_string, range_list), ",") > > def range_to_string(self, (c1, c2)): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Plex/ > Machines.py:261:31: Declarator should be empty > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > return tuple(result) > > def ranges_to_string(self, range_list): > return string.join(map(self.range_to_string, range_list), ",") > > def range_to_string(self, (c1, c2)): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Plex/ > Machines.py:261:31: Expected ')' > Compiling Cython/Plex/Regexps.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > RE, starting at |initial_state| and ending at |final_state|. > If |match_bol| is true, the RE must be able to match at the > beginning of a line. If nocase is true, upper and lower case > letters should be treated as equivalent. > """ > raise exceptions.UnimplementedMethod("%s.build_machine not > implemented" % > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Plex/ > Regexps.py:125:24: undeclared name not builtin: exceptions > Compiling Cython/Plex/Scanners.py > Compiling Cython/Plex/test_tm.py > Compiling Cython/Plex/Timing.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > import os > from sys import platform, exit, stderr > > if platform == 'mac': > import MacOS > def time(): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Plex/ > Timing.py:10:2: def statement not allowed here > Compiling Cython/Plex/Traditional.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > # > # Traditional Regular Expression Syntax > # > #===================================================================== > == > > from Regexps import * > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Plex/ > Traditional.py:9:20: 'import *' not supported > Compiling Cython/Plex/Transitions.py > Compiling Cython/Compiler/Annotate.py > Compiling Cython/Compiler/Builtin.py > Compiling Cython/Compiler/CmdLine.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > # specified (ie Module.SubModule.factory) and the > containing module > # will be imported. This option can be repeated > to add more transforms, > # transforms for the same phase will be used in > the order they are given. > > def bad_usage(): > print >>sys.stderr, usage > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > CmdLine.py:50:10: 'print >>' not yet implemented > Compiling Cython/Compiler/Code.py > Compiling Cython/Compiler/ControlFlow.py > Compiling Cython/Compiler/DebugFlags.py > Compiling Cython/Compiler/Errors.py > Compiling Cython/Compiler/ExprNodes.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > '**': operator.pow, > '>>': operator.rshift, > '-': operator.sub, > #'/': operator.truediv, > '^': operator.xor, > 'in': lambda x, y: x in y, > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > ExprNodes.py:2900:10: Expected an identifier or literal > Compiling Cython/Compiler/__init__.py > Compiling Cython/Compiler/Lexicon.py > Compiling Cython/Compiler/Main.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > # Cython Top Level > # > > import os, sys, re, codecs > if sys.version_info[:2] < (2, 2): > print >>sys.stderr, "Sorry, Cython requires Python 2.2 or later" > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Main.py:7:10: 'print >>' not yet implemented > Compiling Cython/Compiler/ModuleNode.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > if entry.defined_in_pxd: > return 1 > return 0 > > def generate_h_code(self, env, options, result): > def h_entries(entries, pxd = 0): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > ModuleNode.py:63:8: def statement not allowed here > Compiling Cython/Compiler/Naming.py > Compiling Cython/Compiler/Nodes.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > if attrnames is None: > raise InternalError("Children access not implemented > for %s" % \ > self.__class__.__name__) > for name in attrnames: > a = AttributeAccessor(self, name) > yield a > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Nodes.py:134:18: Syntax error in simple statement list > Compiling Cython/Compiler/Options.py > Compiling Cython/Compiler/Parsing.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > if kind != 'c': > strings = [value] > while s.sy == 'BEGIN_STRING': > next_kind, next_value = p_string_literal(s) > if next_kind == 'c': > self.error( > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Parsing.py:526:20: undeclared name not builtin: self > Compiling Cython/Compiler/PyrexTypes.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > "bhilL?fd?", # explicitly signed > ) > > sign_words = ("unsigned ", "", "signed ") > > def __init__(self, rank, signed = 1, pymemberdef_typecode = None): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > PyrexTypes.py:356:36: Empty declarator > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > typedef_flag = 0 > to_py_function = "PyInt_FromLong" > from_py_function = "__pyx_PyInt_AsLong" > exception_value = -1 > > def __init__(self, rank, signed, pymemberdef_typecode = None, > is_returncode = 0): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > PyrexTypes.py:391:35: Empty declarator > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > widest_type = type2 > else: > widest_type = type1 > return widest_type > > def simple_c_type(signed, longness, name): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > PyrexTypes.py:1106:24: Empty declarator > Compiling Cython/Compiler/Scanning.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > from Cython.Plex import Scanner > from Cython.Plex.Errors import UnrecognizedInput > from Errors import CompileError, error > from Lexicon import string_prefixes, make_lexicon > > plex_version = getattr(Plex, '_version', None) > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Scanning.py:20:22: Call with wrong number of arguments (expected 2, > got 3) > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > # Try to open pickled lexicon file and verify that > # it matches the source file. Returns the opened > # file if successful, otherwise None. ??? > f = None > result = None > if os.path.exists(lexicon_pickle): > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Scanning.py:64:36: undeclared name not builtin: lexicon_pickle > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > # file if successful, otherwise None. ??? > f = None > result = None > if os.path.exists(lexicon_pickle): > try: > f = open(lexicon_pickle, "rb") > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Scanning.py:66:35: undeclared name not builtin: lexicon_pickle > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > else: > print("Lexicon hash mismatch:") ### > print(" expected " + expected_hash) ### > print(" got " + actual_hash) ### > except IOError, e: > print("Warning: Unable to read pickled lexicon " + > lexicon_pickle) > > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Scanning.py:76:77: undeclared name not builtin: lexicon_pickle > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > f.close() > return result > > def try_to_unpickle_lexicon(): > global lexicon, lexicon_pickle, lexicon_hash > dir = os.path.dirname(__file__) > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Scanning.py:84:34: undeclared name not builtin: __file__ > Compiling Cython/Compiler/Symtab.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > import re > from Errors import warning, error, InternalError > import Options > import Naming > import PyrexTypes > from PyrexTypes import * > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Symtab.py:10:23: 'import *' not supported > Compiling Cython/Compiler/Transform.py > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > def process_node(self, node, name): > """Override this method to process nodes. name specifies > which kind of relation the > parent has with child. This method should always return the > node which the parent > should use for this relation, which can either be the same > node, None to remove > the node, or a different node.""" > raise InternalError("Not implemented") > ^ > ------------------------------------------------------------ > > /home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ > Transform.py:60:27: undeclared name not builtin: InternalError > Compiling Cython/Compiler/TypeSlots.py > Compiling Cython/Compiler/Version.py > _______________________________________________ > Cython-dev mailing list > Cython-dev@codespeak.net > http://codespeak.net/mailman/listinfo/cython-dev _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev