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:
parent
69af57dedf
commit
26662f7df3
3
.gitignore
vendored
3
.gitignore
vendored
@ -44,3 +44,6 @@ nosetests.xml
|
|||||||
|
|
||||||
# Node
|
# Node
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
# git_hash
|
||||||
|
git_hash.py
|
||||||
|
28
setup.py
28
setup.py
@ -4,6 +4,8 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from setuptools.command.test import test as TestCommand
|
from setuptools.command.test import test as TestCommand
|
||||||
import glob
|
import glob
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from pywb import __version__
|
from pywb import __version__
|
||||||
|
|
||||||
@ -21,7 +23,6 @@ class PyTest(TestCommand):
|
|||||||
from gevent.monkey import patch_all; patch_all()
|
from gevent.monkey import patch_all; patch_all()
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
os.environ.pop('PYWB_CONFIG_FILE', None)
|
os.environ.pop('PYWB_CONFIG_FILE', None)
|
||||||
cmdline = ' --cov-config .coveragerc --cov pywb'
|
cmdline = ' --cov-config .coveragerc --cov pywb'
|
||||||
@ -32,11 +33,36 @@ class PyTest(TestCommand):
|
|||||||
sys.exit(errcode)
|
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):
|
def load_requirements(filename):
|
||||||
with open(filename, 'rt') as fh:
|
with open(filename, 'rt') as fh:
|
||||||
return fh.read().rstrip().split('\n')
|
return fh.read().rstrip().split('\n')
|
||||||
|
|
||||||
|
|
||||||
|
generate_git_hash_py('pywb')
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pywb',
|
name='pywb',
|
||||||
version=__version__,
|
version=__version__,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user