giving up on using git revision in version number :( latest issue is when installing a package that calls git to compute a version number, but cwd is some other git project, you get the wrong thing

This commit is contained in:
Noah Levitt 2015-09-24 00:19:32 +00:00
parent 97a30eb319
commit a41c426b0a
6 changed files with 9 additions and 32 deletions

View File

@ -5,21 +5,6 @@ from setuptools.command.test import test as TestCommand
import sys
import setuptools
VERSION_BYTES = b'1.5'
def full_version_bytes():
import subprocess, time
try:
commit_num_bytes = subprocess.check_output(['git', 'rev-list', '--count', 'HEAD']).strip()
return VERSION_BYTES + b'.' + commit_num_bytes
except subprocess.CalledProcessError:
return VERSION_BYTES
version_bytes = full_version_bytes()
with open('warcprox/version.txt', 'wb') as out:
out.write(version_bytes)
out.write(b'\n');
# special class needs to be added to support the pytest written dump-anydbm tests
class PyTest(TestCommand):
def finalize_options(self):
@ -33,7 +18,7 @@ class PyTest(TestCommand):
sys.exit(errno)
setuptools.setup(name='warcprox',
version=version_bytes.decode('utf-8'),
version='1.5.0',
description='WARC writing MITM HTTP/S proxy',
url='https://github.com/internetarchive/warcprox',
author='Noah Levitt',
@ -41,7 +26,6 @@ setuptools.setup(name='warcprox',
long_description=open('README.rst').read(),
license='GPL',
packages=['warcprox'],
package_data={'warcprox':['version.txt']},
install_requires=[
'certauth>=1.1.0',
'warctools',

View File

@ -19,3 +19,4 @@ RUN mkdir -vp /etc/service/rethinkdb \
RUN apt-get -y install python-virtualenv git
RUN apt-get -y install python-gdbm python3-gdbm libpython2.7-dev libpython3.4-dev libffi-dev libssl-dev
RUN pip install devpi-client

View File

@ -10,11 +10,12 @@ user=$(id -un)
for python in python2.7 python3.4
do
docker run --rm -i -t --volume="$script_dir/..:/warcprox" internetarchive/rethinkdb /sbin/my_init -- \
bash -x -c "adduser --gecos=$user --disabled-password --quiet --uid=$uid $user \
bash -x -c " adduser --gecos=$user --disabled-password --quiet --uid=$uid $user \
&& sudo -u $user bash -x -c 'cd /warcprox \
&& devpi use --set-cfg http://crawl342.us.archive.org:9000/nlevitt/dev \
&& virtualenv -p $python /tmp/venv \
&& source /tmp/venv/bin/activate \
&& pip --log-file /tmp/pip.log install -r requirements.txt . pytest requests \
&& pip --log-file /tmp/pip.log install . pytest requests \
&& py.test tests \
&& py.test --rethinkdb-servers=localhost tests \
&& py.test --rethinkdb-servers=localhost --rethinkdb-big-table tests'"

View File

@ -1,15 +1,11 @@
from argparse import Namespace as _Namespace
from pkg_resources import get_distribution as _get_distribution
__version__ = _get_distribution('warcprox').version
def digest_str(hash_obj, base32):
import base64
return hash_obj.name.encode('utf-8') + b':' + (base64.b32encode(hash_obj.digest()) if base32 else hash_obj.hexdigest().encode('ascii'))
def _read_version_bytes():
import os
version_txt = os.path.sep.join(__file__.split(os.path.sep)[:-1] + ['version.txt'])
with open(version_txt, 'rb') as fin:
return fin.read().strip()
class Options(_Namespace):
def __getattr__(self, name):
try:
@ -17,9 +13,6 @@ class Options(_Namespace):
except AttributeError:
return None
version_bytes = _read_version_bytes().strip()
version_str = version_bytes.decode('utf-8')
# XXX linux-specific
def gettid():
try:

View File

@ -79,7 +79,7 @@ def _build_arg_parser(prog=os.path.basename(sys.argv[0])):
arg_parser.add_argument('--kafka-capture-feed-topic', dest='kafka_capture_feed_topic',
default=None, help='kafka capture feed topic')
arg_parser.add_argument('--version', action='version',
version="warcprox {}".format(warcprox.version_str))
version="warcprox {}".format(warcprox.__version__))
arg_parser.add_argument('-v', '--verbose', dest='verbose', action='store_true')
arg_parser.add_argument('-q', '--quiet', dest='quiet', action='store_true')

View File

@ -1,5 +1,3 @@
# vim:set sw=4 et:
from __future__ import absolute_import
import logging
@ -135,7 +133,7 @@ class WarcRecordBuilder:
headers.append((warctools.WarcRecord.DATE, warc_record_date))
warcinfo_fields = []
warcinfo_fields.append(b'software: warcprox ' + warcprox.version_bytes)
warcinfo_fields.append(b'software: warcprox ' + warcprox.__version__.encode('latin1'))
hostname = socket.gethostname()
warcinfo_fields.append('hostname: {}'.format(hostname).encode('latin1'))
warcinfo_fields.append('ip: {}'.format(socket.gethostbyname(hostname)).encode('latin1'))