diff --git a/IPython/extensions/cythonmagic.py b/IPython/extensions/cythonmagic.py index 8eff5e2..1df58e2 100644 --- a/IPython/extensions/cythonmagic.py +++ b/IPython/extensions/cythonmagic.py @@ -147,6 +147,10 @@ class CythonMagics(Magics): "multiple times)." ) @magic_arguments.argument( + '-n', '--module_name', action='append', default=[], + help="Specify a name for the Cython module." + ) + @magic_arguments.argument( '-L', dest='library_dirs', metavar='dir', action='append', default=[], help="Add a path to the list of libary directories (can be specified " "multiple times)." @@ -204,7 +208,10 @@ class CythonMagics(Magics): # key which is hashed to determine the module name. key += time.time(), - module_name = "_cython_magic_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() + if args.module_name: + module_name = str(args.module_name[0]) + else: + module_name = "_cython_magic_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() module_path = os.path.join(lib_dir, module_name + self.so_ext) have_module = os.path.isfile(module_path)