1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

setup: generate current git_hash into autogenerated 'pywb.git_hash' file, add to .gitignore

This commit is contained in:
Ilya Kreymer 2017-03-28 10:31:43 -07:00
parent 69af57dedf
commit 26662f7df3
2 changed files with 30 additions and 1 deletions

3
.gitignore vendored
View File

@ -44,3 +44,6 @@ nosetests.xml
# Node
node_modules/
# git_hash
git_hash.py

View File

@ -4,6 +4,8 @@
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import glob
import os
import sys
from pywb import __version__
@ -21,7 +23,6 @@ class PyTest(TestCommand):
from gevent.monkey import patch_all; patch_all()
import pytest
import sys
import os
os.environ.pop('PYWB_CONFIG_FILE', None)
cmdline = ' --cov-config .coveragerc --cov pywb'
@ -32,11 +33,36 @@ class PyTest(TestCommand):
sys.exit(errcode)
def get_git_short_hash():
import subprocess
try:
hash_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).rstrip()
if sys.version_info >= (3, 0):
hash_id = hash_id.decode('utf-8')
return hash_id
except:
return ''
def generate_git_hash_py(pkg, filename='git_hash.py'):
try:
git_hash = get_git_short_hash()
with open(os.path.join(pkg, filename), 'wt') as fh:
fh.write('git_hash = "{0}"\n'.format(git_hash))
except:
pass
def load_requirements(filename):
with open(filename, 'rt') as fh:
return fh.read().rstrip().split('\n')
generate_git_hash_py('pywb')
setup(
name='pywb',
version=__version__,