rules_python
rules_python copied to clipboard
extended-length path with forward slash on windows
🐞 bug report
Affected Rule
The issue is caused by the rule: `py_binary`Is this a regression?
No.Description
I'm using py_binary
to run sphinx to generate docs, and sphinx will try to open template file with path from path.join(<package_path>, <template_name>)
at here, the <package_path>
is changed into extended-length path by rules_python, and the <template_name>
would contains forward slashes like partials/_head_css_variables.html
in furo, as a result, the final file path would be like:
\\?\C:\Temp\Bazel.runfiles_8zw7lmen\runfiles\requirements\pypi__furo\furo\theme\furo\partials/_head_css_variables.html
but extended-length path is not support forward slashes.
what's the better way to fix this bug?
🌍 Your Environment
Operating System:
Windows
Output of bazel version
:
4.1.0
Rules_python version:
0.8.0
related issue: https://github.com/bazelbuild/bazel/issues/2504
Thanks for your issue report.
is changed into extended-length path by rules_python,
Where in the code do you think this is happening? I must profess ignorance of Windows' extended-length path functionality.
Sorry,I read the code of rules_python and found that py_binary is just a simple wrapper for the rules in bazel native. So the path might be modified here by bazel:
def GetWindowsPathWithUNCPrefix(path):
"""Adds UNC prefix after getting a normalized absolute Windows path.
No-op for non-Windows platforms or if running under python2.
"""
path = path.strip()
# No need to add prefix for non-Windows platforms.
# And \\?\ doesn't work in python 2 or on mingw
if not IsWindows() or sys.version_info[0] < 3:
return path
# import sysconfig only now to maintain python 2.6 compatibility
import sysconfig
if sysconfig.get_platform() == 'mingw':
return path
# Lets start the unicode fun
unicode_prefix = '\\\\?\\'
if path.startswith(unicode_prefix):
return path
# os.path.abspath returns a normalized absolute path
return unicode_prefix + os.path.abspath(path)
Maybe we should move this issue to bazel repo.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"