Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Make zip_plugin_files.py Python 3 compatible #978

Closed
wants to merge 1 commit into from

Conversation

jin
Copy link
Member

@jin jin commented Jul 11, 2019

Bazel 0.27.0 introduced an incompatible change flag that forces the host python to be python3. This changes the way encoding/decoding is done, causing failures as seen in #976 (comment):

$ bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-latest --experimental_google_legacy_api
INFO: Analyzed target //aswb:aswb_bazel_zip (62 packages loaded, 2243 targets configured).
INFO: Found 1 target...
ERROR: /Users/jingwen/code/intellij/aswb/BUILD:234:1: Creating final plugin zip archive failed (Exit 1) zip_plugin_files failed: error executing command bazel-out/host/bin/build_defs/zip_plugin_files --output bazel-out/darwin-fastbuild/bin/aswb/aswb_bazel.zip aspect/WORKSPACE aswb/aspect/WORKSPACE aspect/artifacts.bzl aswb/aspect/artifacts.bzl ... (remaining 20 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 38, in <module>
    main()
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 35, in main
    outfile.writestr(zipinfo, input_file.read(), zipfile.ZIP_DEFLATED)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 39: ordinal not in range(128)
----------------
Note: The failure of target //build_defs:zip_plugin_files (with exit code 1) may have been caused by the fact that it is a Python 2 program that was built in the host configuration, which uses Python 3. You can change the host configuration (for the entire build) to instead use Python 2 by setting --host_force_python=PY2.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See https://github.com/bazelbuild/bazel/issues/7899 for more information.
----------------
Target //aswb:aswb_bazel_zip failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 347.553s, Critical Path: 91.50s
INFO: 370 processes: 348 darwin-sandbox, 22 worker.
FAILED: Build did NOT complete successfully

This PR fixes that breakage by extending the decoder character set from ascii to latin1, allowing zip_plugin_files.py to be used with Python 3 directly.

@ghost ghost closed this in 4f31673 Jul 12, 2019
liucijus pushed a commit to wix-playground/intellij that referenced this pull request Aug 21, 2019
…import bazelbuild#978)

Bazel 0.27.0 introduced an incompatible change flag that forces the host python to be python3. This changes the way encoding/decoding is done, causing failures as seen in bazelbuild#976 (comment):

```
$ bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-latest --experimental_google_legacy_api
INFO: Analyzed target //aswb:aswb_bazel_zip (62 packages loaded, 2243 targets configured).
INFO: Found 1 target...
ERROR: /Users/jingwen/code/intellij/aswb/BUILD:234:1: Creating final plugin zip archive failed (Exit 1) zip_plugin_files failed: error executing command bazel-out/host/bin/build_defs/zip_plugin_files --output bazel-out/darwin-fastbuild/bin/aswb/aswb_bazel.zip aspect/WORKSPACE aswb/aspect/WORKSPACE aspect/artifacts.bzl aswb/aspect/artifacts.bzl ... (remaining 20 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 38, in <module>
    main()
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 35, in main
    outfile.writestr(zipinfo, input_file.read(), zipfile.ZIP_DEFLATED)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 39: ordinal not in range(128)
----------------
Note: The failure of target //build_defs:zip_plugin_files (with exit code 1) may have been caused by the fact that it is a Python 2 program that was built in the host configuration, which uses Python 3. You can change the host configuration (for the entire build) to instead use Python 2 by setting --host_force_python=PY2.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See bazelbuild/bazel#7899 for more information.
----------------
Target //aswb:aswb_bazel_zip failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 347.553s, Critical Path: 91.50s
INFO: 370 processes: 348 darwin-sandbox, 22 worker.
FAILED: Build did NOT complete successfully
```

This PR fixes that breakage by extending the decoder to from using ascii to direct bytes, allowing zip_plugin_files.py to be used with Python 3 directly.

Closes bazelbuild#978

PiperOrigin-RevId: 257788170
liucijus added a commit to wix-playground/intellij that referenced this pull request Aug 21, 2019
krlvi pushed a commit to krlvi/intellij that referenced this pull request Sep 20, 2019
…import bazelbuild#978)

Bazel 0.27.0 introduced an incompatible change flag that forces the host python to be python3. This changes the way encoding/decoding is done, causing failures as seen in bazelbuild#976 (comment):

```
$ bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-latest --experimental_google_legacy_api
INFO: Analyzed target //aswb:aswb_bazel_zip (62 packages loaded, 2243 targets configured).
INFO: Found 1 target...
ERROR: /Users/jingwen/code/intellij/aswb/BUILD:234:1: Creating final plugin zip archive failed (Exit 1) zip_plugin_files failed: error executing command bazel-out/host/bin/build_defs/zip_plugin_files --output bazel-out/darwin-fastbuild/bin/aswb/aswb_bazel.zip aspect/WORKSPACE aswb/aspect/WORKSPACE aspect/artifacts.bzl aswb/aspect/artifacts.bzl ... (remaining 20 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 38, in <module>
    main()
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 35, in main
    outfile.writestr(zipinfo, input_file.read(), zipfile.ZIP_DEFLATED)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 39: ordinal not in range(128)
----------------
Note: The failure of target //build_defs:zip_plugin_files (with exit code 1) may have been caused by the fact that it is a Python 2 program that was built in the host configuration, which uses Python 3. You can change the host configuration (for the entire build) to instead use Python 2 by setting --host_force_python=PY2.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See bazelbuild/bazel#7899 for more information.
----------------
Target //aswb:aswb_bazel_zip failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 347.553s, Critical Path: 91.50s
INFO: 370 processes: 348 darwin-sandbox, 22 worker.
FAILED: Build did NOT complete successfully
```

This PR fixes that breakage by extending the decoder to from using ascii to direct bytes, allowing zip_plugin_files.py to be used with Python 3 directly.

Closes bazelbuild#978

PiperOrigin-RevId: 257788170
aradchykov pushed a commit to aradchykov/intellij that referenced this pull request Oct 6, 2019
…import bazelbuild#978)

Bazel 0.27.0 introduced an incompatible change flag that forces the host python to be python3. This changes the way encoding/decoding is done, causing failures as seen in bazelbuild#976 (comment):

```
$ bazel build //aswb:aswb_bazel_zip --define=ij_product=android-studio-latest --experimental_google_legacy_api
INFO: Analyzed target //aswb:aswb_bazel_zip (62 packages loaded, 2243 targets configured).
INFO: Found 1 target...
ERROR: /Users/jingwen/code/intellij/aswb/BUILD:234:1: Creating final plugin zip archive failed (Exit 1) zip_plugin_files failed: error executing command bazel-out/host/bin/build_defs/zip_plugin_files --output bazel-out/darwin-fastbuild/bin/aswb/aswb_bazel.zip aspect/WORKSPACE aswb/aspect/WORKSPACE aspect/artifacts.bzl aswb/aspect/artifacts.bzl ... (remaining 20 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 38, in <module>
    main()
  File "/private/var/tmp/_bazel_jingwen/a7f9cfb321ff8f053a43633ca4d90cc9/sandbox/darwin-sandbox/379/execroot/intellij_with_bazel/bazel-out/host/bin/build_defs/zip_plugin_files.runfiles/intellij_with_bazel/build_defs/zip_plugin_files.py", line 35, in main
    outfile.writestr(zipinfo, input_file.read(), zipfile.ZIP_DEFLATED)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 39: ordinal not in range(128)
----------------
Note: The failure of target //build_defs:zip_plugin_files (with exit code 1) may have been caused by the fact that it is a Python 2 program that was built in the host configuration, which uses Python 3. You can change the host configuration (for the entire build) to instead use Python 2 by setting --host_force_python=PY2.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See bazelbuild/bazel#7899 for more information.
----------------
Target //aswb:aswb_bazel_zip failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 347.553s, Critical Path: 91.50s
INFO: 370 processes: 348 darwin-sandbox, 22 worker.
FAILED: Build did NOT complete successfully
```

This PR fixes that breakage by extending the decoder to from using ascii to direct bytes, allowing zip_plugin_files.py to be used with Python 3 directly.

Closes bazelbuild#978

PiperOrigin-RevId: 257788170
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants