setup.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2019 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. import sys,os,subprocess
  19. from shutil import copy2
  20. ver = sys.version_info[:2]
  21. min_ver = (3,5)
  22. if ver[0] < min_ver[0] or ver[1] < min_ver[1]:
  23. m = '{}.{}: wrong Python version. MMGen requires Python {M}.{m} or greater\n'
  24. sys.stderr.write(m.format(*ver,M=min_ver[0],m=min_ver[1]))
  25. sys.exit(1)
  26. have_arm = subprocess.check_output(['uname','-m']).strip() == b'aarch64'
  27. have_msys2 = subprocess.check_output(['uname','-s']).strip()[:7] == b'MSYS_NT'
  28. from distutils.core import setup,Extension
  29. from distutils.command.build_ext import build_ext
  30. from distutils.command.install_data import install_data
  31. # install extension module in repository after building
  32. class my_build_ext(build_ext):
  33. def build_extension(self,ext):
  34. build_ext.build_extension(self,ext)
  35. ext_src = self.get_ext_fullpath(ext.name)
  36. ext_dest = os.path.join('mmgen','secp256k1.so')
  37. try: os.unlink(ext_dest)
  38. except: pass
  39. os.chmod(ext_src,0o755)
  40. print('copying {} to {}'.format(ext_src,ext_dest))
  41. copy2(ext_src,ext_dest)
  42. class my_install_data(install_data):
  43. def run(self):
  44. for f in 'mmgen.cfg','mnemonic.py','mn_wordlist.c':
  45. os.chmod(os.path.join('data_files',f),0o644)
  46. install_data.run(self)
  47. module1 = Extension(
  48. name = 'mmgen.secp256k1',
  49. sources = ['extmod/secp256k1mod.c'],
  50. libraries = ['secp256k1'],
  51. library_dirs = ['/usr/local/lib',r'c:\msys\local\lib'],
  52. # mingw32 needs this, Linux can use it, but it breaks mingw64
  53. include_dirs = ['/usr/local/include',r'c:\msys\local\include'],
  54. )
  55. from mmgen.globalvars import g
  56. setup(
  57. name = 'mmgen',
  58. description = 'A complete Bitcoin offline/online wallet solution for the command line',
  59. version = g.version,
  60. author = g.author,
  61. author_email = g.email,
  62. url = g.proj_url,
  63. license = 'GNU GPL v3',
  64. platforms = 'Linux, MS Windows, Raspberry Pi/Raspbian, Orange Pi/Armbian',
  65. keywords = g.keywords,
  66. cmdclass = { 'build_ext': my_build_ext, 'install_data': my_install_data },
  67. ext_modules = [] if have_msys2 else [module1],
  68. data_files = [('share/mmgen', [
  69. 'data_files/mmgen.cfg', # source files must have 0644 mode
  70. 'data_files/mn_wordlist.c',
  71. 'data_files/mnemonic.py'
  72. ]),],
  73. py_modules = [
  74. 'mmgen.__init__',
  75. 'mmgen.addr',
  76. 'mmgen.altcoin',
  77. 'mmgen.bech32',
  78. 'mmgen.color',
  79. 'mmgen.common',
  80. 'mmgen.crypto',
  81. 'mmgen.ed25519',
  82. 'mmgen.ed25519ll_djbec',
  83. 'mmgen.exception',
  84. 'mmgen.filename',
  85. 'mmgen.globalvars',
  86. 'mmgen.keccak',
  87. 'mmgen.license',
  88. 'mmgen.mn_electrum',
  89. 'mmgen.mn_tirosh',
  90. 'mmgen.obj',
  91. 'mmgen.opts',
  92. 'mmgen.protocol',
  93. 'mmgen.regtest',
  94. 'mmgen.rpc',
  95. 'mmgen.seed',
  96. 'mmgen.sha2',
  97. 'mmgen.term',
  98. 'mmgen.tool',
  99. 'mmgen.tw',
  100. 'mmgen.tx',
  101. 'mmgen.util',
  102. 'mmgen.altcoins.__init__',
  103. 'mmgen.altcoins.eth.__init__',
  104. 'mmgen.altcoins.eth.contract',
  105. 'mmgen.altcoins.eth.obj',
  106. 'mmgen.altcoins.eth.tx',
  107. 'mmgen.altcoins.eth.tw',
  108. 'mmgen.altcoins.eth.pyethereum.__init__',
  109. 'mmgen.altcoins.eth.pyethereum.transactions',
  110. 'mmgen.altcoins.eth.pyethereum.utils',
  111. 'mmgen/altcoins/eth/rlp/__init__',
  112. 'mmgen/altcoins/eth/rlp/atomic',
  113. 'mmgen/altcoins/eth/rlp/codec',
  114. 'mmgen/altcoins/eth/rlp/exceptions',
  115. 'mmgen/altcoins/eth/rlp/sedes/__init__',
  116. 'mmgen/altcoins/eth/rlp/sedes/big_endian_int',
  117. 'mmgen/altcoins/eth/rlp/sedes/binary',
  118. 'mmgen/altcoins/eth/rlp/sedes/boolean',
  119. 'mmgen/altcoins/eth/rlp/sedes/lists',
  120. 'mmgen/altcoins/eth/rlp/sedes/raw',
  121. 'mmgen/altcoins/eth/rlp/sedes/serializable',
  122. 'mmgen/altcoins/eth/rlp/sedes/text',
  123. 'mmgen.main',
  124. 'mmgen.main_addrgen',
  125. 'mmgen.main_addrimport',
  126. 'mmgen.main_autosign',
  127. 'mmgen.main_passgen',
  128. 'mmgen.main_regtest',
  129. 'mmgen.main_split',
  130. 'mmgen.main_tool',
  131. 'mmgen.main_txbump',
  132. 'mmgen.main_txcreate',
  133. 'mmgen.main_txdo',
  134. 'mmgen.main_txsend',
  135. 'mmgen.main_txsign',
  136. 'mmgen.main_wallet',
  137. 'mmgen.txsign',
  138. 'mmgen.share.__init__',
  139. 'mmgen.share.Opts',
  140. ],
  141. scripts = [
  142. 'cmds/mmgen-addrgen',
  143. 'cmds/mmgen-keygen',
  144. 'cmds/mmgen-passgen',
  145. 'cmds/mmgen-addrimport',
  146. 'cmds/mmgen-passchg',
  147. 'cmds/mmgen-regtest',
  148. 'cmds/mmgen-subwalletgen',
  149. 'cmds/mmgen-walletchk',
  150. 'cmds/mmgen-walletconv',
  151. 'cmds/mmgen-walletgen',
  152. 'cmds/mmgen-split',
  153. 'cmds/mmgen-txcreate',
  154. 'cmds/mmgen-txbump',
  155. 'cmds/mmgen-txsign',
  156. 'cmds/mmgen-txsend',
  157. 'cmds/mmgen-txdo',
  158. 'cmds/mmgen-tool',
  159. 'cmds/mmgen-autosign'
  160. ]
  161. )