Skip to content
Open
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
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ common --incompatible_python_disallow_native_rules
common --incompatible_no_implicit_file_export

build --lockfile_mode=update

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
startup --windows_enable_symlinks
4 changes: 4 additions & 0 deletions .bcr/gazelle/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ bcr_test_module:
platform: ${{ platform }}
bazel: ${{ bazel }}
shell_commands:
# Add an empty line in case the bazelrc is missing a trailing newline
- "echo '' >> .bazelrc"
- "echo 'common --override_module=rules_python=' >> .bazelrc"
- "bazel run //:gazelle_python_manifest.update"
- "bazel run //:gazelle -- update"
batch_commands:
# Add an empty line in case the bazelrc is missing a trailing newline
- "echo '' >> .bazelrc"
- "echo common --override_module=rules_python= >> .bazelrc"
- "bazel run //:gazelle_python_manifest.update"
- "bazel run //:gazelle -- update"
Expand Down
4 changes: 4 additions & 0 deletions examples/build_file_generation/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ build --enable_runfiles
common --noenable_bzlmod
common --enable_workspace
common --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ test --test_output=errors --enable_runfiles
# Windows requires these for multi-python support:
build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions examples/multi_python_versions/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ build --enable_runfiles

coverage --java_runtime_version=remotejdk_11
common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions examples/pip_parse/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# https://docs.bazel.build/versions/main/best-practices.html#using-the-bazelrc-file
try-import %workspace%/user.bazelrc
common --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions examples/pip_parse_vendored/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ build --enable_runfiles
common --noenable_bzlmod
common --enable_workspace
common --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions examples/pip_repository_annotations/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ common --noenable_bzlmod
common --enable_workspace
common --legacy_external_runfiles=false
common --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions gazelle/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ build --@rules_python//python/config_settings:incompatible_default_to_explicit_i
build --enable_runfiles

common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions gazelle/examples/bzlmod_build_file_generation/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ common:bazel7.x --incompatible_python_disallow_native_rules
# rules_python code. In the BCR presubmits, this override is removed
# and the bazel_dep version of rules_python is used.
common --override_module=rules_python=../../../

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module(
# For typical setups you set the version.
# See the releases page for available versions.
# https://github.com/bazel-contrib/rules_python/releases
bazel_dep(name = "rules_python", version = "1.4.0")
bazel_dep(name = "rules_python", version = "1.7.0")

# The following stanza defines the dependency rules_python_gazelle_plugin.
# For typical setups you set the version.
Expand Down
4 changes: 3 additions & 1 deletion python/private/build_data_writer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ if (-not [string]::IsNullOrEmpty($InfoFilePath) -and (Test-Path $InfoFilePath))
# Use .NET to write file to avoid PowerShell encoding/locking quirks
# We use UTF8 without BOM for compatibility with how the bash script writes (and
# what consumers expect).
# We join with `n to ensure Unix-style line endings are used even on Windows.
$Utf8NoBom = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($OutputPath, $Lines, $Utf8NoBom)
$Content = [string]::Join("`n", $Lines) + "`n"
[System.IO.File]::WriteAllText($OutputPath, $Content, $Utf8NoBom)

$Acl = Get-Acl $OutputPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Read", "Allow")
Expand Down
28 changes: 26 additions & 2 deletions python/private/stage2_bootstrap_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,39 @@ def get_build_data(self):
if is_windows():
path = os.path.normpath(path)
try:
path = os.path.dirname(__file__)
path = os.path.join(path, "print_build_data.build_data.txt")
# Use utf-8-sig to handle Windows BOM
with open(path, encoding="utf-8-sig") as fp:
return fp.read()
with open(path, 'rb') as fp:
data = fp.read()
return data.decode('utf-8-sig')
except Exception as exc:
if hasattr(exc, "add_note"):
exc.add_note(f"version: {sys.version}")
exc.add_note(f"path: {path}")
exc.add_note(f"runfiles lookup path: {rlocation_path}")
exc.add_note(f"exists: {os.path.exists(path)}")
exc.add_note(f"lexists: {os.path.lexists(path)}")
exc.add_note(f"islink: {os.path.islink(path)}")
exc.add_note(f"isfile: {os.path.isfile(path)}")
if hasattr(os.path, "isjunction"):
exc.add_note(f"isjunction: {os.path.isjunction(path)}")
can_read = os.access(path, os.R_OK)
exc.add_note(f"readable: {can_read}")
try:
exc.add_note(f"stat: {os.stat(path)}")
except Exception as e:
exc.add_note(f"stat error: {e}")
try:
exc.add_note(f"lstat: {os.lstat(path)}")
except Exception as e:
exc.add_note(f"lstat error: {e}")
try:
import subprocess
out = subprocess.check_output(f'dir "{os.path.dirname(path)}"', shell=True)
exc.add_note(f"dir: {out.decode('utf-8', 'replace')}")
except Exception as e:
exc.add_note(f"dir error: {e}")
raise


Expand Down
4 changes: 4 additions & 0 deletions tests/integration/compile_pip_requirements/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ test --test_output=errors
# Windows requires these for multi-python support:
build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
test --test_output=errors
common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions tests/integration/local_toolchains/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ build --enable_runfiles
common:bazel7.x --incompatible_python_disallow_native_rules
build --//:py=local
common --announce_rc

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions tests/integration/pip_parse/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ build --enable_runfiles
try-import %workspace%/user.bazelrc

common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false
4 changes: 4 additions & 0 deletions tests/integration/py_cc_toolchain_registered/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This aids debugging on failure
build --toolchain_resolution_debug=python
common:bazel7.x --incompatible_python_disallow_native_rules

# See issue 3567. Disable implicit python zip creation.
common --build_python_zip=false
common --@rules_python//python/config_settings:build_python_zip=false