Skip to content

Commit b2dcce2

Browse files
pass path to _get_pandoc_version() on windows correctly (#345)
1 parent 67d0ba1 commit b2dcce2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pypandoc/__init__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,10 @@ def _ensure_pandoc_path() -> None:
679679
search_paths = ["pandoc", included_pandoc]
680680
pf = "linux" if sys.platform.startswith("linux") else sys.platform
681681
try:
682-
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc"))
682+
if pf == "win32":
683+
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc.exe"))
684+
else:
685+
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc"))
683686
except: # noqa
684687
# not one of the know platforms...
685688
pass
@@ -689,16 +692,19 @@ def _ensure_pandoc_path() -> None:
689692
# Also add the interpreter script path, as that's where pandoc could be
690693
# installed if it's an environment and the environment wasn't activated
691694
if pf == "win32":
692-
search_paths.append(os.path.join(sys.exec_prefix, "Scripts", "pandoc"))
695+
search_paths.append(os.path.join(sys.exec_prefix, "Scripts", "pandoc.exe"))
693696

694697
# Since this only runs on Windows, use Windows slashes
695698
if os.getenv('ProgramFiles', None):
696-
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\Pandoc"))
699+
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\pandoc.exe"))
700+
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\Pandoc.exe"))
697701
if os.getenv('ProgramFiles(x86)', None):
698-
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\Pandoc"))
702+
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\pandoc.exe"))
703+
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\Pandoc.exe"))
699704

700705
# bin can also be used on windows (conda at least has it in path), so
701706
# include it unconditionally
707+
search_paths.append(os.path.join(sys.exec_prefix, "bin", "pandoc.exe"))
702708
search_paths.append(os.path.join(sys.exec_prefix, "bin", "pandoc"))
703709
# If a user added the complete path to pandoc to an env, use that as the
704710
# only way to get pandoc so that a user can overwrite even a higher

0 commit comments

Comments
 (0)