Issue #765 resolved

os.path.relpath() in gettext builder

created an issue

This line: {{{


generate "#: file1:line1\n#: file2:line2 ..."

pofile.write(u"#: %s\n" % "\n#: ".join("%s:%s" % (path.relpath(source, self.outdir), line) for source, line, _ in positions))

}}} in sphinx/builders/

Throws an exception on W32: {{{ File "%PYTHONPATH%\lib\", line 512, in relpath % (path_prefix, start_prefix)) ValueError: path is on drive %DRIVE1%:, start on drive %DRIVE2%: }}} because `source' is absolute path, and self.outdir is also an absolute path (even if sphinx-build was invoked with relative paths for source and output directories), and they could be (and are, in my case) on different drives.

If being able to express source path as relative to self.outdir is a requirement, then i simply don't know how this is going to be fixed. Otherwise, you can catch ValueError here (sticking to better-to-ask-forgiveness-than-to-ask-permission line) and output source path as-is.

Comments (3)

  1. LRN reporter

    The reason why this is happening is that sphinx doc refers to a number of messages (for ext.pot and web.pot) that come not from its own documentation rst file, but from sphinx itself, for example:

    %PYTHONPATH%\lib\site-packages\sphinx-1.1predev_20110917-py2.7.egg\sphinx\domains\ of

    These references might (and do) point to the drive different from the one where documentation rst files are located

    I've made a quick hack (as described in my previous post), and was able to build the .pot files successfully. Looking at them, i see now that these paths are put in comments for translatable messages. I am not familiar enough with gettext toolset to be able to claim that these paths will never be read by any piece of software, and that they are there only for translator's convenience, but from my experience it is so. That makes my hack a viable fix, that could be applied to the tip (sorry, don't have any patches for you, too lazy for that).

  2. Log in to comment