disable coercion from str->bytes, fix coercion from str->object
[cython.git] / Cython / Compiler / CmdLine.py
index a423d2acd1622d2357955afb923fcee7ca0ee8d8..de431c04e557682440065e3ef75075f140839219 100644 (file)
@@ -38,8 +38,10 @@ Options:
   -a, --annotate                 Produce a colorized HTML version of the source.
   --line-directives              Produce #line directives pointing to the .pyx source
   --cplus                        Output a c++ rather than c file.
-  -X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
+  --embed                        Embed the Python interpreter in a main() method.
+  --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
 """
+
 #The following experimental options are supported only on MacOSX:
 #  -C, --compile    Compile generated .c file to .o file
 #  -X, --link       Link .o file to produce extension module (implies -C)
@@ -80,10 +82,16 @@ def parse_command_line(args):
             elif option in ("-C", "--compile"):
                 options.c_only = 0
             elif option in ("-X", "--link"):
+                if option == "-X":
+                    print >>sys.stderr, "Deprecation warning: The -X command line switch will be changed to a"
+                    print >>sys.stderr, "shorthand for --directive in Cython 0.12. Please use --link instead."
+                    print >>sys.stderr
                 options.c_only = 0
                 options.obj_only = 0
             elif option in ("-+", "--cplus"):
                 options.cplus = 1
+            elif option == "--embed":
+                Options.embed = True
             elif option.startswith("-I"):
                 options.include_path.append(get_param(option))
             elif option == "--include-dir":
@@ -118,7 +126,7 @@ def parse_command_line(args):
                 options.emit_linenums = True
             elif option in ("-X", "--directive"):
                 try:
-                    options.pragma_overrides = Options.parse_option_list(pop_arg())
+                    options.compiler_directives = Options.parse_option_list(pop_arg())
                 except ValueError, e:
                     sys.stderr.write("Error in compiler directive: %s\n" % e.message)
                     sys.exit(1)
@@ -145,5 +153,9 @@ def parse_command_line(args):
         sys.exit(1)
     if len(sources) == 0 and not options.show_version:
         bad_usage()
+    if Options.embed and len(sources) > 1:
+        sys.stderr.write(
+            "cython: Only one source file allowed when using -embed\n")
+        sys.exit(1)
     return options, sources