Projet

Général

Profil

0001-setup.py-use-a-PEP440-compatible-get_version-69795.patch

Benjamin Dauvergne, 03 octobre 2022 11:14

Télécharger (1,92 ko)

Voir les différences:

Subject: [PATCH] setup.py: use a PEP440 compatible get_version() (#69795)

 setup.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
setup.py
67 67

  
68 68
def get_version():
69 69
    """Use the VERSION, if absent generates a version with git describe, if not
70
    tag exists, take 0.0.0- and add the length of the commit log.
70
    tag exists, take 0.0- and add the length of the commit log.
71 71
    """
72 72
    if os.path.exists('VERSION'):
73 73
        with open('VERSION') as v:
74 74
            return v.read()
75 75
    if os.path.exists('.git'):
76 76
        p = subprocess.Popen(
77
            ['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE, stderr=subprocess.PIPE
77
            ['git', 'describe', '--dirty=.dirty', '--match=v*'],
78
            stdout=subprocess.PIPE,
79
            stderr=subprocess.PIPE,
78 80
        )
79 81
        result = p.communicate()[0]
80 82
        if p.returncode == 0:
81
            return result.decode('ascii').split()[0][1:].replace('-', '.')
83
            result = result.decode('ascii').strip()[1:]  # strip spaces/newlines and initial v
84
            if '-' in result:  # not a tagged version
85
                real_number, commit_count, commit_hash = result.split('-', 2)
86
                version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
87
            else:
88
                version = result
89
            return version
82 90
        else:
83
            return '0.0.0-%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
84
    return '0.0.0'
91
            return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
92
    return '0.0'
85 93

  
86 94

  
87 95
setup(
88
-