GoogleCloudPlatform / gsutil

A command line tool for interacting with cloud storage services.
Apache License 2.0
876 stars 335 forks source link

gsutil 5.31 doesn't work with Python 3.12.7 in alpine #1808

Open cHiv0rz opened 2 weeks ago

cHiv0rz commented 2 weeks ago

Context

Python 3.12.7 is the default python version in alpine 3:20, and it breaks gsutil on its version 5.31. Looking into the code, it seems 3 weeks ago this check was added.

Why is the incompatibility issue on this version? Because gsutil 5.30 works fine with Python 3.12.6

Thanks

NachE commented 2 weeks ago

It looks like gsutil is incompatible with Python 3.12 due to the removal of the imp module, as described here: https://issuetracker.google.com/issues/303737178. Python 3.12.6 shouldn't work either, since the imp module was removed starting with Python 3.12.0.

cHiv0rz commented 2 weeks ago

"Shouldn't" but it works, because I actually using it in version 5.30 with Python 3.12.6, at least for "normal" usage like list files, copy, move, etc. What specific function is failing? maybe we can throw the error only on that part, and not break the whole utility?

cHiv0rz commented 2 weeks ago

In addition, I found this meta issue which says the problem with Python 3.12 on gsutil is fixed here: https://github.com/GoogleCloudPlatform/gsutil/issues/1695

So sorry If i'm missing something, but still don't understand the check

ElijahLynn commented 2 weeks ago

Just ran gcloud components update at the request of the prompt today and now getting:

Error: gsutil requires Python version 2.7 or 3.5-3.11, but a different version is installed.
You are currently running Python 3.12
Follow the steps below to resolve this issue:
    1. Switch to Python 3.5-3.11 using your Python version manager or install an appropriate version.
    2. If you are unsure how to manage Python versions, visit [https://cloud.google.com/storage/docs/gsutil_install#specifications] for detailed instructions.

python3 --version
Python 3.12.5

Debugging now. But just wanted to pass on feedback this is frustrating, as I'm doing a time sensitive task and now gsutil doesn't work for my task.

ElijahLynn commented 2 weeks ago

I just applied https://github.com/GoogleCloudPlatform/gsutil/pull/1809 but with this addition https://github.com/GoogleCloudPlatform/gsutil/pull/1809/files#r1806891229 to /opt/homebrew/Caskroom/google-cloud-sdk/436.0.0/google-cloud-sdk/platform/gsutil/gsutil.py and I am up and running again.

NachE commented 2 weeks ago

My fault while testing 😅

joshheinrichs-shopify commented 2 weeks ago

the gsutil wrapper that google-cloud-sdk packages thinks that 3.12 works, so if python or python3 points to 3.12, it'll use 3.12 and then explode. it won't go digging for python3.11 even if it's installed. it seems to treat 3.12 as a last resort, but doesn't consider python3 / python may be pointing at 3.12:

CLOUDSDK_PYTHON=$(order_python python3 python python3.11 python3.10 python3.9 python3.8 python3.12)
bennett39 commented 6 days ago

For anyone who reached this page looking for a quick fix, reverting the version of my gcloud components got me running again on python 3.12:

gcloud components update --version 494.0.0