Fix needed to fix this error with Windows build. See http://stackoverflow.com/questio...
[p2pool.git] / setup.py
1 import os
2 import shutil
3 import sys
4 import zipfile
5
6 from distutils.core import setup
7 import py2exe
8
9 version = __import__('p2pool').__version__
10
11 if os.path.exists('INITBAK'):
12     os.remove('INITBAK')
13 os.rename(os.path.join('p2pool', '__init__.py'), 'INITBAK')
14 try:
15     open(os.path.join('p2pool', '__init__.py'), 'wb').write('__version__ = %r%s%sDEBUG = False%s' % (version, os.linesep, os.linesep, os.linesep))
16     
17     sys.argv[1:] = ['py2exe']
18     setup(name='p2pool',
19         version=version,
20         description='Peer-to-peer Bitcoin mining pool',
21         author='Forrest Voight',
22         author_email='forrest@forre.st',
23         url='http://p2pool.forre.st/',
24         data_files=[
25             ('', ['README']),
26             ('web-static', [
27                 'web-static/d3.v2.min.js',
28                 'web-static/graphs.html',
29                 'web-static/index.html',
30                 'web-static/share.html',
31             ]),
32         ],
33         
34         console=['run_p2pool.py'],
35         options=dict(py2exe=dict(
36             bundle_files=1,
37             dll_excludes=['w9xpopen.exe', "mswsock.dll", "MSWSOCK.dll"],
38             includes=['twisted.web.resource', 'ltc_scrypt'],
39         )),
40         zipfile=None,
41     )
42 finally:
43     os.remove(os.path.join('p2pool', '__init__.py'))
44     os.rename('INITBAK', os.path.join('p2pool', '__init__.py'))
45
46 dir_name = 'p2pool_win32_' + version
47
48 if os.path.exists(dir_name):
49     shutil.rmtree(dir_name)
50 os.rename('dist', dir_name)
51
52 with zipfile.ZipFile(dir_name + '.zip', 'w', zipfile.ZIP_DEFLATED) as zf:
53     for dirpath, dirnames, filenames in os.walk(dir_name):
54         for filename in filenames:
55             zf.write(os.path.join(dirpath, filename))
56
57 print dir_name