build: fix py versions in buildroot builds #12235
Merged
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.
The python version numbers are now generated from git tags. That means you have to run git commands with a cwd inside the git directory. While building on buildroot, this was not happening because when buildroot builds out-of-tree projects it does so after first rsync'ing their contents (i.e. not the .git directory) into the build directory.
That means that when we called the version machinery in the buildroot make scripts to do things like create /etc/VERSION.json everything worked, because those makefiles explicitly ran the script in the external tree; but when buildroot called setup.py build, that happened in the build directory which is inside the buildroot directory and therefore the scripts would pick up the latest tag from buildroot, since that tag scheme matches the robot-stack tag scheme.
The way to fix this is to make sure the version runs inside the source directory when building on buildroot. This could be done a couple ways; in my opinion, this is a nice combination of minimally altering the python code that is reused outside of buildroot while still keeping things obvious: adding an optional environment variable respected by the setup.pys (rather than the build script, which would make the environment variable hard to find) that can change the location of the git calls.
Testing
This PR will be built by buildroot. We need to make sure that the output of that build has the correct wheel versions.
Risks
Minimal if the above all works. Flex doesn't use the same processes so it should be unaffected.