Add timestamp offset for block header
[p2pool.git] / setup.py
1 import os
2 import shutil
3 import sys
4 import zipfile
5 import platform
6
7 from distutils.core import setup
8 from distutils.sysconfig import get_python_lib
9 import py2exe
10
11 version = __import__('p2pool').__version__
12 im64 = '64' in platform.architecture()[0]
13
14 if os.path.exists('INITBAK'):
15     os.remove('INITBAK')
16 os.rename(os.path.join('p2pool', '__init__.py'), 'INITBAK')
17 try:
18     open(os.path.join('p2pool', '__init__.py'), 'wb').write('__version__ = %r%s%sDEBUG = False%s' % (version, os.linesep, os.linesep, os.linesep))
19     mfcdir = get_python_lib() + '\pythonwin\\'
20     mfcfiles = [os.path.join(mfcdir, i) for i in ["mfc90.dll", "mfc90u.dll", "mfcm90.dll", "mfcm90u.dll", "Microsoft.VC90.MFC.manifest"]]
21     bundle = 1
22     if im64:
23         bundle = bundle + 2
24     sys.argv[1:] = ['py2exe']
25     setup(name='p2pool',
26         version=version,
27         description='Peer-to-peer Bitcoin mining pool',
28         author='Forrest Voight',
29         author_email='forrest@forre.st',
30         url='http://p2pool.forre.st/',
31         data_files=[
32             ('', ['README.md']),
33             ("Microsoft.VC90.MFC", mfcfiles),
34             ('web-static', [
35                 'web-static/d3.v2.min.js',
36                 'web-static/favicon.ico',
37                 'web-static/graphs.html',
38                 'web-static/index.html',
39                 'web-static/share.html',
40             ]),
41         ],
42
43         console=['run_p2pool.py'],
44         options=dict(py2exe=dict(
45             bundle_files=bundle,
46             dll_excludes=['w9xpopen.exe', "mswsock.dll", "MSWSOCK.dll"],
47             includes=['twisted.web.resource', 'ltc_scrypt'],
48         )),
49         zipfile=None,
50     )
51 finally:
52     os.remove(os.path.join('p2pool', '__init__.py'))
53     os.rename('INITBAK', os.path.join('p2pool', '__init__.py'))
54
55 win = '32'
56 if im64:
57     win = '64'
58
59 dir_name = 'p2pool_win' + win + '_' + version
60
61 if os.path.exists(dir_name):
62     shutil.rmtree(dir_name)
63 os.rename('dist', dir_name)
64
65 with zipfile.ZipFile(dir_name + '.zip', 'w', zipfile.ZIP_DEFLATED) as zf:
66     for dirpath, dirnames, filenames in os.walk(dir_name):
67         for filename in filenames:
68             zf.write(os.path.join(dirpath, filename))
69
70 print dir_name