Fall back to cpu_count when psutil is unavailable at build time#419
Open
OuariachiRafik wants to merge 1 commit into
Open
Fall back to cpu_count when psutil is unavailable at build time#419OuariachiRafik wants to merge 1 commit into
OuariachiRafik wants to merge 1 commit into
Conversation
build_game_engine.sh imports psutil to decide compilation parallelism, but psutil is not guaranteed to be present in the build environment (e.g. under PEP 517 build isolation), causing 'ModuleNotFoundError: No module named psutil' and aborting the build before compilation. Wrap the import in a try/except that falls back to multiprocessing.cpu_count(), completing the existing TODO. Fixes google-research#414. Signed-off-by: Hammadi Rafik Ouariachi <hrafik1122@gmail.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed the CLA ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pip install gfootballcan fail with:gfootball/build_game_engine.shruns an inline Python snippet that importspsutilto size compilation parallelism.psutilis a runtime dependency,so it is not guaranteed to be present in the build environment — under
PEP 517 build isolation it is absent, and the build aborts before any C++
compilation. Reported in #414.
Fix
Wrap the
psutilimport in atry/except ImportErrorand fall back tomultiprocessing.cpu_count()when it is unavailable, with an outer shellguard falling back to
1. This completes the existing# TODO: Try importing psutil and if failed fall back to ...in the same file.Behavior is unchanged when psutil is present.
Testing
Reproduced #414 in a clean environment without psutil in the build environment.
Before: the build failed at
running build_extwith the psutil error.After: the build proceeds past the parallelism step into the C++/cmake stage
(the psutil error no longer occurs).
Fixes #414.