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
py/makeversionhdr.py: pass --git-dir ./.git #5002
Conversation
Thanks for the patch.
I'm not familiar with buildroot. Can you please explain why git doesn't look up the inner-most repo and instead goes to the global one? |
git can not get the version of micropython because buildroot downloads the tarball from https://github.com/micropython/micropython/releases/download/v1.9.4/micropython-1.9.4.tar.gz. This tarball does not contain any git repository. As a result, the git commands retrieve the version from the upper (and only) git repo (which is buildroot). Currently, we have the following patch on buildroot : https://git.buildroot.net/buildroot/tree/package/micropython/0001-fix-version.patch However, this solution can't be merged upstream as it completely disables git. I would like to keep non-upstreamable patches as low as possible in buildroot hence this PR. |
Ok, thanks for the explanation. So the issue arises when the uPy git repo is not there, but a more global one is. Unfortunately the patch here does not work (even though the CI passes) because all code is built in a subdirectory (eg |
I think there is two options:
|
A relative path seems like a bad idea, who knows what the working directory could be. So a way to override this via the build system seems more interesting? |
It could be possible in the Makefile to use the existing |
Indeed, but it might still be interesting to have this as a separate Makefile variable which can be overridden. I can imagine if people build MicroPython as part of something bigger they want it to have the same version (i.e. the 'problem' which gets fixed here can be a feuture for some). |
I updated the PR, now there is a PY_GIT_PATH variable that is set by default to $(TOP)/.git |
To make this work for the msvc port you need similar changes in genhdr.targets: under the first
|
micropython can be embedded in a more global git project such as buildroot. In this case, micropython retrieves the version of this global project. Fix this issue by adding PY_GIT_DIR variable and passing it to --git-dir to ensure that git commands take the current working directory as the git directory Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Thanks for your review, here is a new iteration. |
Thanks for updating the PR. It looks good, except that I would suggest that the variable names be changed to If you agree (or have a better suggestion), I'm happy to make the change during merge. |
I agree with your suggestion. |
I just noticed that it's possible to specify the git dir with the
That solution doesn't require any changes here, and is possibly more flexible...? |
The only drawback is that we'll have to set this variable in our buildroot file (in micropython.mk). I'll check if this is "acceptable" for the other buildroot contributors and I'll get back to you. Can you keep this PR open until then? |
Yes, it's not as "automagic" as the solution in this PR. But less code (here in this repo I mean) is easier to maintain :)
For sure. I was about to merge it but noticed this other solution. |
@ffontaine did you find out if the simpler solution is acceptable? |
Drop patch and set GIT_DIR as suggested by upstream during review of an upstreamable solution, see micropython/micropython#5002 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Reviewed-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Simpler solution has been merged in buildroot, so I'll close this PR, thanks for your support. |
Good to know! |
Create first BLE-only board, Micro:Bit v2
micropython can be embedded in a more global git project such as
buildroot. In this case, micropython retrieves the version of this
global project. Fix this issue by passing --git-dir ./.git to ensure
that git commands take the current working directory as the git
directory
Signed-off-by: Fabrice Fontaine fontaine.fabrice@gmail.com