Skip to content

Commit

Permalink
version finder now calls git-describe; py2exe build script fixed up
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Mar 5, 2012
1 parent a39fd88 commit fa89639
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
5 changes: 5 additions & 0 deletions p2pool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import os
import sys
import traceback
import subprocess

def _get_version():
try:
return subprocess.check_output(['git', 'describe', '--always', '--dirty'], cwd=os.path.dirname(os.path.abspath(__file__))).strip()
except:
pass
try:
root_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
git_dir = os.path.join(root_dir, '.git')
Expand Down
25 changes: 9 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import os
import subprocess
import sys

subprocess.check_call(['git', 'checkout', 'p2pool/__init__.py'])
version = __import__('p2pool').__version__
open('p2pool/__init__.py', 'wb').write('__version__ = %r%s%sDEBUG = False%s' % (version, os.linesep, os.linesep, os.linesep))

from distutils.core import setup
import py2exe

def get_version():
root_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
git_dir = os.path.join(root_dir, '.git')
head = open(os.path.join(git_dir, 'HEAD')).read().strip()
prefix = 'ref: '
if head.startswith(prefix):
path = head[len(prefix):].split('/')
return open(os.path.join(git_dir, *path)).read().strip()[:7]
else:
return head[:7]

open('p2pool/__init__.py', 'wb').write('__version__ = %r\r\n\r\nDEBUG = False\r\n' % get_version())

sys.argv[1:] = ['py2exe']
setup(name='p2pool',
version='1.0',
version=version,
description='Peer-to-peer Bitcoin mining pool',
author='Forrest Voight',
author_email='[email protected]',
Expand All @@ -35,5 +27,6 @@ def get_version():
zipfile=None,
)

os.rename('dist', 'p2pool_win32_' + get_version())
print 'p2pool_win32_' + get_version()
dir_name = 'p2pool_win32_' + version
print dir_name
os.rename('dist', dir_name)

0 comments on commit fa89639

Please sign in to comment.