1 |
1 |
#! /usr/bin/env python
|
2 |
2 |
# -*- coding: utf-8 -*-
|
3 |
3 |
|
4 |
|
import glob
|
5 |
4 |
import os
|
6 |
|
import re
|
7 |
5 |
import subprocess
|
8 |
6 |
import sys
|
9 |
7 |
|
... | ... | |
13 |
11 |
from distutils.cmd import Command
|
14 |
12 |
from setuptools import setup, find_packages
|
15 |
13 |
|
|
14 |
|
16 |
15 |
class eo_sdist(sdist):
|
17 |
16 |
def run(self):
|
18 |
17 |
if os.path.exists('VERSION'):
|
19 |
18 |
os.remove('VERSION')
|
20 |
19 |
version = get_version()
|
21 |
|
version_file = open('VERSION', 'w')
|
22 |
|
version_file.write(version)
|
23 |
|
version_file.close()
|
|
20 |
with open('VERSION', 'w') as fd:
|
|
21 |
fd.write(version)
|
|
22 |
with open('welco/version.py', 'w') as fd:
|
|
23 |
fd.write('VERSION = %r' % version)
|
24 |
24 |
sdist.run(self)
|
25 |
25 |
if os.path.exists('VERSION'):
|
26 |
26 |
os.remove('VERSION')
|
27 |
27 |
|
|
28 |
|
28 |
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 |
'''
|
29 |
33 |
if os.path.exists('VERSION'):
|
30 |
|
version_file = open('VERSION', 'r')
|
31 |
|
version = version_file.read()
|
32 |
|
version_file.close()
|
33 |
|
return version
|
|
34 |
with open('VERSION', 'r') as v:
|
|
35 |
return v.read()
|
34 |
36 |
if os.path.exists('.git'):
|
35 |
|
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE)
|
|
37 |
p = subprocess.Popen(
|
|
38 |
['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
|
39 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
36 |
40 |
result = p.communicate()[0]
|
37 |
41 |
if p.returncode == 0:
|
38 |
|
version = result.split()[0][1:]
|
39 |
|
version = version.replace('-', '.')
|
|
42 |
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
|
43 |
if '-' in result: # not a tagged version
|
|
44 |
real_number, commit_count, commit_hash = result.split('-', 2)
|
|
45 |
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
|
46 |
else:
|
|
47 |
version = result
|
40 |
48 |
return version
|
41 |
|
return '0'
|
|
49 |
else:
|
|
50 |
return '0.0.post%s' % len(
|
|
51 |
subprocess.check_output(
|
|
52 |
['git', 'rev-list', 'HEAD']).splitlines())
|
|
53 |
return '0.0'
|
|
54 |
|
42 |
55 |
|
43 |
56 |
class compile_translations(Command):
|
44 |
57 |
description = 'compile message catalogs to MO files via django compilemessages'
|
45 |
|
-
|