Projet

Général

Profil

0001-misc-generate-a-version-number-that-s-compatible-wit.patch

Frédéric Péters, 07 août 2018 16:05

Télécharger (2,09 ko)

Voir les différences:

Subject: [PATCH] misc: generate a version number that's compatible with PEP
 440 (#25596)

 setup.py | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
setup.py
27 27
            os.remove('VERSION')
28 28

  
29 29
def get_version():
30
    '''Use the VERSION, if absent generates a version with git describe, if not
31
       tag exists, take 0.0- and add the length of the commit log.
32
    '''
30 33
    if os.path.exists('VERSION'):
31
        version_file = open('VERSION', 'r')
32
        version = version_file.read()
33
        version_file.close()
34
        return version
34
        with open('VERSION', 'r') as v:
35
            return v.read()
35 36
    if os.path.exists('.git'):
36
        p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE)
37
        p = subprocess.Popen(['git','describe','--dirty=.dirty','--match=v*'],
38
                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
37 39
        result = p.communicate()[0]
38 40
        if p.returncode == 0:
39
            version = str(result.split()[0][1:])
40
            version = version.replace('-', '.')
41
            result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
42
            if '-' in result: # not a tagged version
43
                real_number, commit_count, commit_hash = result.split('-', 2)
44
                version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
45
            else:
46
                version = result
41 47
            return version
42
    return '0'
48
        else:
49
            return '0.0.post%s' % len(
50
                    subprocess.check_output(
51
                            ['git', 'rev-list', 'HEAD']).splitlines())
52
    return '0.0'
43 53

  
44 54
def data_tree(destdir, sourcedir):
45 55
    extensions = ['.css', '.png', '.jpeg', '.jpg', '.gif', '.xml', '.html', '.js']
46
-