diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2017-02-12 13:37:43 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-02-12 13:37:43 +0100 |
commit | ba00ebef16f7b86c595498a3807e709e6d9c9228 (patch) | |
tree | a72705fac97444e24a0066be3f476c52d589c3da /Cython/Compiler/ModuleNode.py | |
parent | f03092b145754ab47071b919ddf5f13da1e898ff (diff) | |
download | cython-ba00ebef16f7b86c595498a3807e709e6d9c9228.tar.gz |
Remove duplicated file path handling code when generating file path tables.
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index b02a69f9f..c11ad43bc 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -739,27 +739,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln_openmp("#include <omp.h>") def generate_filename_table(self, code): - import os.path as path - - full_module_path = path.join(*self.full_module_name.split('.')) - module_abspath = path.splitext(path.abspath( - self.compilation_source.source_desc.get_filenametable_entry()))[0] - root_path = module_abspath[:-len(full_module_path)] - workdir = path.abspath(os.getcwd()) + os.sep - if root_path.startswith(workdir): - # prefer relative paths to current directory (which is most likely the project root) - root_path = workdir - + from os.path import isabs, basename code.putln("") code.putln("static const char *%s[] = {" % Naming.filetable_cname) if code.globalstate.filename_list: for source_desc in code.globalstate.filename_list: - file_abspath = path.abspath(source_desc.get_filenametable_entry()) - if file_abspath.startswith(root_path): - filename = file_abspath[len(root_path):] - else: - filename = path.basename(file_abspath) - escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"') + file_path = source_desc.get_filenametable_entry() + if isabs(file_path): + file_path = basename(file_path) # never include absolute paths + escaped_filename = file_path.replace("\\", "\\\\").replace('"', r'\"') code.putln('"%s",' % escaped_filename) else: # Some C compilers don't like an empty array |