You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: numpy 1.26.0b1 fails to build from sdist when no git is present #24503
The version is missing from the sdist for 1.26b1, resulting in an attempt to get it via git. But that does not work because ...
<edit>
The gitversion.py script introduced in #24196 is broken when no git binary is available.
Reproduce the code example:
$ python3numpy/_build_utils/gitversion.py
Error message:
$ python3 numpy/_build_utils/gitversion.py
Traceback (most recent call last):
File "/sage/local/var/lib/sage/venv-python3.11/var/tmp/sage/build/numpy-1.26.0b1/src/numpy/_build_utils/gitversion.py", line 68, in<module>
version, git_hash = git_version(init_version())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/sage/local/var/lib/sage/venv-python3.11/var/tmp/sage/build/numpy-1.26.0b1/src/numpy/_build_utils/gitversion.py", line 53, in git_version
return version, git_hash
^^^^^^^^
UnboundLocalError: cannot access local variable 'git_hash' where it is not associated with a value
Thanks for the report @mkoeppe. That's a bug indeed. The gitversion.py script should check for a file containing the needed git hash (as was done with if fs.exists('_version_meson.py') before gh-24196). Building from an sdist should work when git is not installed.
changed the title [-]BUG: numpy 1.26.0b1 fails to build from sdist when no git is present[/-][+]BUG: numpy 1.26.0b1 sdist is misssing the git version[/+]on Aug 24, 2023
changed the title [-]BUG: numpy 1.26.0b1 sdist is misssing the git version[/-][+]BUG: numpy 1.26.0b1 fails to build from sdist when no git is present[/+]on Aug 24, 2023
The problem here was simply that gitversion.py is unconditionally triggered right at the top of meson.build, and the git_hash = '' for when git is not installed was in the wrong place. It was fixed with Matti's one-line patch, and nothing else was wrong.
Activity
rgommers commentedon Aug 23, 2023
Thanks for the report @mkoeppe. That's a bug indeed. The
gitversion.pyscript should check for a file containing the needed git hash (as was done withif fs.exists('_version_meson.py')before gh-24196). Building from an sdist should work whengitis not installed.@stefanv can you please have a look at this?
mattip commentedon Aug 23, 2023
While #24511, the sage build of 1.26b1 should not be hitting this. Are you building from the sdist or from a github archive?
mkoeppe commentedon Aug 23, 2023
Building from the sdist from PyPI. I've just added #24511 as a patch. Tests running at https://github.com/mkoeppe/sage/actions/runs/5954216252, I'll report back when finished
mkoeppe commentedon Aug 23, 2023
I confirm that this fixes the problem. Thanks for the quick fix @mattip
stefanv commentedon Aug 24, 2023
Thanks for handling it, @mattip
stefanv commentedon Aug 24, 2023
Note that the idea is to always generate the version and distribute it as part of the sdist. That way, the git hash should never be empty.
mattip commentedon Aug 24, 2023
So if the version is not in the sdist, I guess we should reopen this and figure out why it is missing.
[-]BUG: numpy 1.26.0b1 fails to build from sdist when no git is present[/-][+]BUG: numpy 1.26.0b1 sdist is misssing the git version[/+]rgommers commentedon Aug 24, 2023
It is present, Stefan's comment was only clarifying. I just checked it when working on the next fix (gh-24515),
version.pyis part of the sdist.[-]BUG: numpy 1.26.0b1 sdist is misssing the git version[/-][+]BUG: numpy 1.26.0b1 fails to build from sdist when no git is present[/+]rgommers commentedon Aug 24, 2023
The
meson.add_dist_scriptcall takes care of this. It should be robust.mattip commentedon Aug 24, 2023
Weird. @mkoeppe how did the sage build not find it? What is the command you are using to build NumPy 1.26b1?
mkoeppe commentedon Aug 24, 2023
@mattip Just using
python3 -m pip wheel.stefanv commentedon Aug 24, 2023
Does the above command go via setuptools? When I run:
it invokes Meson and builds the sdist that contains version.py.
mkoeppe commentedon Aug 24, 2023
No,
python3 -m pip wheeldoes not invoke setuptools. It runs the build system declared in pyproject.tomlrgommers commentedon Aug 25, 2023
The problem here was simply that
gitversion.pyis unconditionally triggered right at the top ofmeson.build, and thegit_hash = ''for whengitis not installed was in the wrong place. It was fixed with Matti's one-line patch, and nothing else was wrong.mattip commentedon Aug 25, 2023
That makes sense. Thanks for the explanation.
stefanv commentedon Aug 25, 2023
Thanks for checking that; I wasn't able to look at the time, but that sets my mind at ease.