Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

pass path to _get_pandoc_version() on windows correctly #345

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions pypandoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ def _ensure_pandoc_path() -> None:
search_paths = ["pandoc", included_pandoc]
pf = "linux" if sys.platform.startswith("linux") else sys.platform
try:
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc"))
if pf == "win32":
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc.exe"))
else:
search_paths.append(os.path.join(DEFAULT_TARGET_FOLDER[pf], "pandoc"))
except: # noqa
# not one of the know platforms...
pass
Expand All @@ -689,16 +692,19 @@ def _ensure_pandoc_path() -> None:
# Also add the interpreter script path, as that's where pandoc could be
# installed if it's an environment and the environment wasn't activated
if pf == "win32":
search_paths.append(os.path.join(sys.exec_prefix, "Scripts", "pandoc"))
search_paths.append(os.path.join(sys.exec_prefix, "Scripts", "pandoc.exe"))

# Since this only runs on Windows, use Windows slashes
if os.getenv('ProgramFiles', None):
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\Pandoc"))
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\pandoc.exe"))
search_paths.append(os.path.expandvars("${ProgramFiles}\\Pandoc\\Pandoc.exe"))
if os.getenv('ProgramFiles(x86)', None):
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\Pandoc"))
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\pandoc.exe"))
search_paths.append(os.path.expandvars("${ProgramFiles(x86)}\\Pandoc\\Pandoc.exe"))

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