-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Replace Python 2 with Python 3 #11202
Comments
We certainly are fine with requiring python3 to build bazel. I don't think we are ready to commit to requiring users to make that switch yet. As long as PRs only fix our build process, this should not be a problem. |
One year later... Any progress here? Python 2.7 was discontinued on January 1, 2020: [1]. |
@davido I just grepped for remaining python2 pieces in our code and couldn't find anything that looked too critical. A few references in j2objc stuff and one explicit call to python2.7 in the BUILD file used to build Debian packages for Bazel releases, that I can clean up. Do you have anything specific in mind? |
We should also replace |
Exactly, we have similar request here: [1]. And I've sent similar CL: [2]. [1] https://crbug.com/gerrit/14175 |
Related to #11202. PiperOrigin-RevId: 369427107
Somehow related: I cannot build Bazel without installing "python". Consider this docker image: [1] (you could do the same on Ubuntu 20.04). If you remove python from the list of installed modules, and just leave python3, then the Bazel build would fail with the error: python is not installed. Why it's still needed? I would have expected, that Bazel could just be built with only Python3 installed. [1] https://github.com/davido/fedora-bazel-docker |
@davido there's a Debian/Ubuntu package that takes care of this. [1] Now, long-term it would probably be best for Bazel to just look for Python 3 directly but this is a reasonably easy interim fix. |
Thanks for pointing this out. Yeah, also on Fedora, actually "python" is a link to python3:
When building
|
I can confirm, that this diff fixed the problem for me: diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
index 9a178cee3a..743bb88862 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
@@ -45,7 +45,7 @@ import net.starlark.java.eval.StarlarkValue;
category = DocCategory.PROVIDER)
public interface PyRuntimeInfoApi<FileT extends FileApi> extends StarlarkValue {
- static final String DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python";
+ static final String DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3";
@StarlarkMethod(
name = "interpreter_path",
I can build Bazel itself and Gerrit Code Review without installing
|
Seems like a trivial and reasonable patch if Python 3 is the default anyway. |
I think Bazel has migrated to Python3, please reopen if things still need python2 |
Description of the problem / feature request:
Python 2 has reached end-of-life and operating systems are actively removing legacy Python code and support. Please accept #11201 to convert all legacy Python 2 code in Bazel to Python 3. The patch is relatively trivial.
Feature requests: what underlying problem are you trying to solve with this feature?
Python 2 EOL
What operating system are you running Bazel on?
Debian Unstable
Have you found anything relevant by searching the web?
Yes, please see above.
Any other information, logs, or outputs that you want to share?
An alternate solution is to allow Bazel to dynamically adapt to the version of Python requested by the user. This might have been advisable a year or two ago but at this point I don't think it is worth the effort to support an obsolete version of Python.
The text was updated successfully, but these errors were encountered: