Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Other changes:
([2169](https://github.com/bazelbuild/rules_python/issues/2169)).
* (workspace) Corrected protobuf's name to com_google_protobuf, the name is
hardcoded in Bazel, WORKSPACE mode.
* (pypi): {bzl:obj}`compile_pip_requirements` no longer fails on Windows when `--enable_runfiles` is not enabled.
* (pypi): {bzl:obj}`compile_pip_requirements` now correctly updates files in the source tree on Windows when `--windows_enable_symlinks` is not enabled.
* (repositories): Add libs/python3.lib and pythonXY.dll to the `libpython` target
defined by a repository template. This enables stable ABI builds of Python extensions
on Windows (by defining Py_LIMITED_API).
Expand Down
13 changes: 10 additions & 3 deletions python/private/pypi/dependency_resolver/dependency_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,26 @@ def main(

if UPDATE:
print("Updating " + requirements_file_relative)

# Make sure the output file for pip_compile exists. It won't if we are on Windows and --enable_runfiles is not set.
if not os.path.exists(requirements_file_relative):
os.makedirs(os.path.dirname(requirements_file_relative), exist_ok=True)
shutil.copy(resolved_requirements_file, requirements_file_relative)

if "BUILD_WORKSPACE_DIRECTORY" in os.environ:
workspace = os.environ["BUILD_WORKSPACE_DIRECTORY"]
requirements_file_tree = os.path.join(workspace, requirements_file_relative)
absolute_output_file = Path(requirements_file_relative).absolute()
# In most cases, requirements_file will be a symlink to the real file in the source tree.
# If symlinks are not enabled (e.g. on Windows), then requirements_file will be a copy,
# and we should copy the updated requirements back to the source tree.
if not os.path.samefile(resolved_requirements_file, requirements_file_tree):
if not absolute_output_file.samefile(requirements_file_tree):
atexit.register(
lambda: shutil.copy(
resolved_requirements_file, requirements_file_tree
absolute_output_file, requirements_file_tree
)
)
cli(argv)
cli(argv, standalone_mode = False)
requirements_file_relative_path = Path(requirements_file_relative)
content = requirements_file_relative_path.read_text()
content = content.replace(absolute_path_prefix, "")
Expand Down