ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

git_version.py uses 'git describe --exclude' which is not available in git 2.11.0 #702

Open dwalton76 opened 4 years ago

dwalton76 commented 4 years ago

system info

Image file:         ev3dev-stretch-ev3-generic-2018-12-14
Kernel version:     4.14.117-ev3dev-2.3.4-ev3
Brickman:           0.10.2
BogoMIPS:           148.88
Bluetooth:          
Board:              board0
BOARD_INFO_HW_REV=7
BOARD_INFO_MODEL=LEGO MINDSTORMS EV3
BOARD_INFO_ROM_REV=6
BOARD_INFO_SERIAL_NUM=0016533F8FD1
BOARD_INFO_TYPE=main

sudo python3 setup.py install fails due to

robot@ev3dev:~/ev3dev-lang-python$ sudo python3 setup.py install
Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    version=git_version(),
  File "/home/robot/ev3dev-lang-python/git_version.py", line 67, in git_version
    raise ValueError("Cannot find the version number!")
ValueError: Cannot find the version number!

This is happening because git describe no longer supports the --exclude option

robot@ev3dev:~/ev3dev-lang-python$ git describe --exclude ev3dev-* --abbrev=4
error: unknown option `exclude'
usage: git describe [<options>] [<commit-ish>...]
   or: git describe [<options>] --dirty

    --contains            find the tag that comes after the commit
    --debug               debug search strategy on stderr
    --all                 use any ref
    --tags                use any tag, even unannotated
    --long                always use long format
    --first-parent        only follow first parent
    --abbrev[=<n>]        use <n> digits to display SHA-1s
    --exact-match         only output exact matches
    --candidates <n>      consider <n> most recent tags (default: 10)
    --match <pattern>     only consider tags matching <pattern>
    --always              show abbreviated commit object as fallback
    --dirty[=<mark>]      append <mark> on dirty working tree (default: "-dirty")

robot@ev3dev:~/ev3dev-lang-python$ 

We need to update git_version.py to not use the --exclude option

dwalton76 commented 4 years ago

We started using the --exclude option about 6 weeks ago via this commit https://github.com/ev3dev/ev3dev-lang-python/commit/3cf0281752be26b30433698105b147fe31aa2771#diff-1f1a2d73d07f51e31bc8eb6ebe9ad868

WasabiFan commented 4 years ago

What version of git are you using? This flag was added in git 2.13.0, and hasn't been removed as far as I can tell. https://github.com/git/git/blob/master/Documentation/RelNotes/2.13.0.txt#L34

dwalton76 commented 4 years ago

The latest and greatest ev3dev image only has git 2.11.0 :( I must have misread something that made me think it was removed...will update the issue title.

WasabiFan commented 4 years ago

Can't you upgrade git? Is it in the package repositories? sudo apt install git

dwalton76 commented 4 years ago

No, that is the latest git package available on the latest ev3dev.

WasabiFan commented 4 years ago

It looks like a newer version is available in stretch-backports but 2.11 was the version they cut off at for stretch. You can find instructions to install from backports here: https://backports.debian.org/Instructions/

That change is necessary to make sure that published packages include the right version number while still successfully building. I don't see a clear way to solve this issue without the git flag unless we had git return all the tags and then manually did some filtering. Since this won't impact users and is easy to work around I don't think this is particularly high priority but it would be nice to find a replacement.

ddemidov commented 4 years ago

git describe --match <pattern> was there before exclude. Would it be possible to use it with a negative regex pattern?

ddemidov commented 4 years ago

Correction: exclude and match use glob patterns (similar to bash ones), not regexps.

ddemidov commented 4 years ago
git describe --match '[0-9]*'

seems to work, although it is not the same as

git describe --exclude ev3dev-*
dwalton76 commented 4 years ago

What is the problem the exclude is trying to solve? I get the same output on my laptop with or without it

dwalton@laptop:ev3dev-lang-python$ git describe --exclude ev3dev-* --abbrev=4
2.0.0beta2-66-g77cb
dwalton@laptop:ev3dev-lang-python$ 
dwalton@laptop:ev3dev-lang-python$ git describe --abbrev=4
2.0.0beta2-66-g77cb
dwalton@laptop:ev3dev-lang-python$ 
dwalton@laptop:ev3dev-lang-python$ git --version
git version 2.17.1
dwalton@laptop:ev3dev-lang-python$ 
dwalton76 commented 4 years ago

There aren't any directories or files that match ev3dev-* that would be why

dwalton@laptop:ev3dev-lang-python$ ls ev3dev-*
ls: cannot access 'ev3dev-*': No such file or directory
dwalton@laptop:ev3dev-lang-python$ 
dlech commented 4 years ago

It is filtering out the debian package tags.

dwalton76 commented 4 years ago

Ack on that being for the tags but I am still missing something...git describe --exclude ev3dev-* --abbrev=4 and git describe --abbrev=4 both give me the exact same output.

dwalton@laptop:ev3dev-lang-python$ git describe --exclude refs/ev3dev-* --abbrev=4
2.0.0beta2-84-ge4a8
dwalton@laptop:ev3dev-lang-python$ 
dwalton@laptop:ev3dev-lang-python$ git describe --abbrev=4
2.0.0beta2-84-ge4a8
dwalton@laptop:ev3dev-lang-python$ 

Where the tags are:

dwalton@laptop:ev3dev-lang-python$ git tag
0.4.1
0.4.2
0.4.3
0.5.0
0.6.0
0.7.0
0.8.0
0.8.1
1.0.0
1.1.0
1.1.1
1.2.0
2.0.0-beta1
2.0.0beta1
2.0.0beta2
debian/0.5.0
debian/0.6.0
debian/0.7.0_rc1
ev3dev-stretch/1.2.0
ev3dev-stretch/2.0.0_beta1
ev3dev-stretch/2.0.0_beta2
v0.4.0
dwalton@laptop:ev3dev-lang-python$ 

Note that 2.0.0beta2 does not contain an underscore where ev3dev-stretch/2.0.0_beta2 does...so the 2.0.0beta2-84-ge4a8 returned by git describe is not using the ev3dev-stretch/2.0.0_beta2 it is using 2.0.0beta2.

There must be some other environment where the --exclude is needed.

Anyway, thoughts on how to make sudo python3 setup.py install on an ev3dev work again?

WasabiFan commented 4 years ago

It was dependent on the ordering of the tags. In past releases I believe I had created the tags in the "wrong" order such that at the time it built the Debian package it picked up the previous tagged version number — I only created the tag it was looking for afterward. This resulted in the wrong version number within the package's __version__, I believe. I created the requisite tag beforehand this time, but that caused the build to fail because now the "most recent" tag was the one prefixed with stretch, and the setuptools handler didn't understand that format. So I changed the release script to ignore those tags.

To get it working on ev3dev, if @ddemidov's suggestion doesn't work, you can install a newer git version from stretch backports. I linked the page above.