misc: update setup.py to our newest standards
This commit is contained in:
parent
35867e5dc9
commit
a952caabfc
31
setup.py
31
setup.py
|
@ -1,18 +1,36 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from distutils.command.sdist import sdist
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
VERSION = '0.1'
|
||||
class eo_sdist(sdist):
|
||||
def run(self):
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
version = get_version()
|
||||
version_file = open('VERSION', 'w')
|
||||
version_file.write(version)
|
||||
version_file.close()
|
||||
sdist.run(self)
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
|
||||
def get_version():
|
||||
if os.path.exists('VERSION'):
|
||||
version_file = open('VERSION', 'r')
|
||||
version = version_file.read()
|
||||
version_file.close()
|
||||
return version
|
||||
if os.path.exists('.git'):
|
||||
p = subprocess.Popen(['git','describe','--dirty'], stdout=subprocess.PIPE)
|
||||
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
if result:
|
||||
return result.split()[0].replace('-','.')
|
||||
return VERSION
|
||||
if p.returncode == 0:
|
||||
version = result.split()[0][1:]
|
||||
version = version.replace('-', '.')
|
||||
return version
|
||||
return '0'
|
||||
|
||||
setup(name='scrutiny',
|
||||
version=get_version(),
|
||||
|
@ -27,4 +45,7 @@ setup(name='scrutiny',
|
|||
'django >= 1.7, < 1.8',
|
||||
'gadjo',
|
||||
],
|
||||
cmdclass={
|
||||
'sdist': eo_sdist,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue