summaryrefslogtreecommitdiff
path: root/Cython/Compiler/CmdLine.py
diff options
context:
space:
mode:
Diffstat (limited to 'Cython/Compiler/CmdLine.py')
-rw-r--r--Cython/Compiler/CmdLine.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py
index ffff6a61c..c330fcc05 100644
--- a/Cython/Compiler/CmdLine.py
+++ b/Cython/Compiler/CmdLine.py
@@ -4,11 +4,17 @@
from __future__ import absolute_import
+import sys
import os
from argparse import ArgumentParser, Action, SUPPRESS
from . import Options
+if sys.version_info < (3, 3):
+ # TODO: This workaround can be removed in Cython 3.1
+ FileNotFoundError = IOError
+
+
class ParseDirectivesAction(Action):
def __call__(self, parser, namespace, values, option_string=None):
old_directives = dict(getattr(namespace, self.dest,
@@ -145,6 +151,12 @@ def create_cython_argparser():
dest='compile_time_env', type=str,
action=ParseCompileTimeEnvAction,
help='Provides compile time env like DEF would do.')
+ parser.add_argument("--module-name",
+ dest='module_name', type=str, action='store',
+ help='Fully qualified module name. If not given, is '
+ 'deduced from the import path if source file is in '
+ 'a package, or equals the filename otherwise.')
+ parser.add_argument('-M', '--depfile', action='store_true', help='produce depfiles for the sources')
parser.add_argument('sources', nargs='*', default=[])
# TODO: add help
@@ -203,6 +215,10 @@ def parse_command_line_raw(parser, args):
def parse_command_line(args):
parser = create_cython_argparser()
arguments, sources = parse_command_line_raw(parser, args)
+ for source in sources:
+ if not os.path.exists(source):
+ import errno
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), source)
options = Options.CompilationOptions(Options.default_options)
for name, value in vars(arguments).items():
@@ -222,5 +238,10 @@ def parse_command_line(args):
if len(sources) == 0 and not options.show_version:
parser.error("cython: Need at least one source file\n")
if Options.embed and len(sources) > 1:
- parser.error("cython: Only one source file allowed when using -embed\n")
+ parser.error("cython: Only one source file allowed when using --embed\n")
+ if options.module_name:
+ if options.timestamps:
+ parser.error("cython: Cannot use --module-name with --timestamps\n")
+ if len(sources) > 1:
+ parser.error("cython: Only one source file allowed when using --module-name\n")
return options, sources