# general


08/01/2022, 2:05 PM
I recently upgraded from pants 2.11 to 2.12, and I'm getting an error with my proto -> python generation. The generated python code has the following invalid import:
Copy code
from google.protobuf.internal import builder as _builder
E   ImportError: cannot import name 'builder' from 'google.protobuf.internal'
I'm using
in the project. Unfortunately I have a requirement in the project that requires
(due to Tensorflow) so I can't bump this. Anyone have any suggestions? 🙏
Current best guess is I need to specify a version of protoc somewhere in my pants.toml? When I generate the python code using
directly (version 3.19.4), I don't get the invalid import. So my guess is that pants 2.12 bumped the version of protoc that is used.


08/01/2022, 2:19 PM
yeah, your guess is correct. we’re in a similar situation, here’s what I added to my
to fix it:
Copy code
version = "3.9.2"
# NOTE: Since we're using a non-default version of protoc, we have to specify the sha256 and size
# of the download for each platform here.
# Downloads are coming from:
# <{version}-protoc-{version}-{platform}.zip>
# For each download we want to support,
#   1. Download it
#   2. Use `sha256sum` to compute the sha
#   3. Use `wc -c` to compute the size
#   4. Update the table here to match
known_versions = [
    "3.9.2|linux_arm64 |55dba3d64d45fc79e4c93d376b2e578dfec913eaa2b6f071beb2460956a17db6|1443656",
    "3.9.2|macos_arm64 |f02de67311645bbc5a05d8dfc6f7ea6fe56f0db38546cb5327d1544a798a5612|2862486",
Also this, though I’m not sure if I’m just repeating the default configs here:
Copy code
linux_arm64 = "linux-aarch_64"
linux_x86_64 = "linux-x86_64"
# NOTE: arm64-native protoc not available until v3.20.1, so we also download the x86_64
# binary when running on M1.
macos_arm64 = "osx-x86_64"
macos_x86_64 = "osx-x86_64"


08/01/2022, 2:20 PM
@sparse-lifeguard-95737 thanks so much Dan!
FWIW at least in my case (needed 3.19.4) I didn't need to repeat those default url platform mappings.