emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

[bazel] Use hermetic Python #1333

Open kon72 opened 5 months ago

kon72 commented 5 months ago

This change removes the dependency on system Python.

Also fixes an issue where the build fails on Windows with --incompatible_strict_action_env flag specified:

'py' is not recognized as an internal or external command,
operable program or batch file.
walkingeyerobot commented 5 months ago

This change looks good, but it looks like the test failures are real. The Linux one is complaining because the user is root and the new python is insisting it shouldn't be run as root; this might just be a configuration issue? The Windows one is complaining about actual dependency failures. These need to be addressed before we can merge. I can take a closer look later this week if needed.

kalmard0 commented 2 weeks ago

Would changing the CI user to non-root be an acceptable solution here?

walkingeyerobot commented 2 weeks ago

I'm not terribly familiar with the inner workings of the CI, but it sounds ok to me? I don't expect many folks are running bazel as root in the real world. @sbc100 @trybka do you have any concerns here?

allsey87 commented 2 weeks ago

@kon72 @kalmard0 was there an attempt to just use the Python interpreter directly instead of defining EMSDK_PYTHON and using the existing scripts? I think this could be done via py_binary and then passed as the tool argument (instead of path) for clang_tool etc in toolchain.bzl.

This way we could remove all the sh and bat scripts and a bunch of logic for switching between the two depending on the OS.

allsey87 commented 2 weeks ago

Would changing the CI user to non-root be an acceptable solution here?

I'm not terribly familiar with the inner workings of the CI, but it sounds ok to me? I don't expect many folks are running bazel as root in the real world. @sbc100 @trybka do you have any concerns here?

@kalmard0 @walkingeyerobot the reason why the non-arm version of CircleCI appears to be due to the ubuntu executor using a Docker image on the CircleCI instance. I would suggest changing this back to a standard Ubuntu image unless there is a well-known reason for using Docker here.

Moreover, the windows test is probably failing since it is pinned at quite an old version of Bazel which is probably not compatible with the python_rules version that we are using in this PR.

walkingeyerobot commented 2 weeks ago

If you wanted to send a PR that updates the bazel version, I'd be happy to accept it. The ubuntu image thing would be more of a question for @sbc100 I think.

allsey87 commented 2 weeks ago

If you wanted to send a PR that updates the bazel version, I'd be happy to accept it. The ubuntu image thing would be more of a question for @sbc100 I think.

I'll put it together tomorrow. Bazel 5.4.0 (used by CircleCI on Windows) is not covered by rules_python's support policy.

@sbc100 @walkingeyerobot could you two decide on what the minimum supported version of Bazel should be for emsdk? This support matrix might help.

walkingeyerobot commented 6 days ago

Let's bump it to bazel 7 then. Seems to be the oldest version that's still under active support.