Add PYINSTALLER_SPEC_PATH. Simplify & unify spec file.

This commit is contained in:
Richard Kiss 2021-03-23 12:18:08 -07:00 committed by Gene Hoffman
parent 73e83c8392
commit 7a970b8fe7
6 changed files with 201 additions and 488 deletions

View File

@ -66,7 +66,7 @@ pip install --no-index --find-links=.\win_build\ chia-blockchain
Write-Output " ---"
Write-Output "Use pyinstaller to create chia .exe's"
Write-Output " ---"
pyinstaller --log-level INFO daemon_windows.spec
pyinstaller --log-level INFO daemon.spec
Write-Output " ---"
Write-Output "Copy chia executables to chia-blockchain-gui\"

View File

@ -1,244 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
#from src.cmds.chia import SUBCOMMANDS
import pathlib
from pkg_resources import get_distribution
from os import listdir
from os.path import isfile, join
from PyInstaller.utils.hooks import copy_metadata
# Include all files that end with clvm.hex
puzzles_path = "../src/wallet/puzzles"
puzzle_dist_path = "./src/wallet/puzzles"
onlyfiles = [f for f in listdir(puzzles_path) if isfile(join(puzzles_path, f))]
hex_puzzles = []
for file in onlyfiles:
if file.endswith("clvm.hex"):
puzzle_path = f"{puzzles_path}/{file}"
hex_puzzles.append((puzzles_path, puzzle_dist_path))
build = pathlib.Path().absolute()
root = build.parent
version_data = copy_metadata(get_distribution("chia-blockchain"))[0]
SUBCOMMANDS = [
"configure",
"farm",
"init",
"keys",
"netspace",
"plots",
"run_daemon",
"show",
"start",
"stop",
"version",
"wallet",
]
block_cipher = None
subcommand_modules = [f"{root}/src.cmds.%s" % _ for _ in SUBCOMMANDS]
subcommand_modules.extend([f"src.cmds.%s" % _ for _ in SUBCOMMANDS])
other = ["aiter.active_aiter", "aiter.aiter_forker", "aiter.aiter_to_iter", "aiter.azip", "aiter.flatten_aiter", "aiter.gated_aiter",
"aiter.iter_to_aiter", "aiter.join_aiters", "aiter.map_aiter", "aiter.map_filter_aiter", "aiter.preload_aiter",
"aiter.push_aiter", "aiter.sharable_aiter", "aiter.stoppable_aiter", "pkg_resources.py2_warn"]
entry_points = ["src.cmds.chia",
"src.server.start_wallet",
"src.server.start_full_node",
"src.server.start_harvester",
"src.server.start_farmer",
"src.server.start_introducer",
"src.server.start_timelord",
"src.timelord_launcher",
"src.simulator.start_simulator"]
subcommand_modules.extend(other)
subcommand_modules.extend(entry_points)
daemon = Analysis([f"{root}/src/daemon/server.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[version_data, (f"../src/util/initial-config.yaml", f"./src/util/"), ] +
hex_puzzles,
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
full_node = Analysis([f"{root}/src/server/start_full_node.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
wallet = Analysis([f"{root}/src/server/start_wallet.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[(f"../mozilla-ca/cacert.pem", f"./mozilla-ca/"), (f"../src/ssl/dst_root_ca.pem", f"./src/ssl/"), (f"../src/ssl/chia_ca.key", f"./src/ssl/"), (f"../src/ssl/chia_ca.crt", f"./src/ssl/"), (f"../src/util/english.txt", f"./src/util/"), version_data ] + hex_puzzles,
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
chia = Analysis([f"{root}/src/cmds/chia.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
farmer = Analysis([f"{root}/src/server/start_farmer.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
harvester = Analysis([f"{root}/src/server/start_harvester.py"],
pathex=[f"{root}/venv/lib/python3.8/site-packages/aiter/", f"{root}"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
daemon_pyz = PYZ(daemon.pure, daemon.zipped_data,
cipher=block_cipher)
full_node_pyz = PYZ(full_node.pure, full_node.zipped_data,
cipher=block_cipher)
wallet_pyz = PYZ(wallet.pure, wallet.zipped_data,
cipher=block_cipher)
chia_pyz = PYZ(chia.pure, chia.zipped_data,
cipher=block_cipher)
farmer_pyz = PYZ(farmer.pure, farmer.zipped_data,
cipher=block_cipher)
harvester_pyz = PYZ(harvester.pure, harvester.zipped_data,
cipher=block_cipher)
daemon_exe = EXE(daemon_pyz,
daemon.scripts,
[],
exclude_binaries=True,
name='daemon',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
full_node_exe = EXE(full_node_pyz,
full_node.scripts,
[],
exclude_binaries=True,
name='start_full_node',
debug=False,
bootloader_ignore_signals=False,
strip=False)
wallet_exe = EXE(wallet_pyz,
wallet.scripts,
[],
exclude_binaries=True,
name='start_wallet',
debug=False,
bootloader_ignore_signals=False,
strip=False)
chia_exe = EXE(chia_pyz,
chia.scripts,
[],
exclude_binaries=True,
name='chia',
debug=False,
bootloader_ignore_signals=False,
strip=False)
farmer_exe = EXE(farmer_pyz,
farmer.scripts,
[],
exclude_binaries=True,
name='start_farmer',
debug=False,
bootloader_ignore_signals=False,
strip=False)
harvester_exe = EXE(harvester_pyz,
harvester.scripts,
[],
exclude_binaries=True,
name='start_harvester',
debug=False,
bootloader_ignore_signals=False,
strip=False)
coll = COLLECT(daemon_exe,
daemon.binaries,
daemon.zipfiles,
daemon.datas,
full_node_exe,
full_node.binaries,
full_node.zipfiles,
full_node.datas,
wallet_exe,
wallet.binaries,
wallet.zipfiles,
wallet.datas,
chia_exe,
chia.binaries,
chia.zipfiles,
chia.datas,
farmer_exe,
farmer.binaries,
farmer.zipfiles,
farmer.datas,
harvester_exe,
harvester.binaries,
harvester.zipfiles,
harvester.datas,
strip = False,
upx_exclude = [],
name = 'daemon'
)

View File

@ -1,242 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_submodules
from os import listdir
from os.path import isfile, join
from pkg_resources import get_distribution
from PyInstaller.utils.hooks import copy_metadata
# Include all files that end with clvm.hex
puzzles_path = "../src/wallet/puzzles"
puzzle_dist_path = "./src/wallet/puzzles"
onlyfiles = [f for f in listdir(puzzles_path) if isfile(join(puzzles_path, f))]
hex_puzzles = []
for file in onlyfiles:
if file.endswith("clvm.hex"):
hex_puzzles.append((f"{puzzles_path}/{file}", puzzle_dist_path))
keyring_imports = collect_submodules('keyring.backends')
# keyring uses entrypoints to read keyring.backends from metadata file entry_points.txt.
keyring_datas = copy_metadata('keyring')[0]
version_data = copy_metadata(get_distribution("chia-blockchain"))[0]
SUBCOMMANDS = [
"configure",
"farm",
"init",
"keys",
"netspace",
"plots",
"run_daemon",
"show",
"start",
"stop",
"version",
"wallet",
]
block_cipher = None
subcommand_modules = [f"../src.cmds.%s" % _ for _ in SUBCOMMANDS]
subcommand_modules.extend([f"src.cmds.%s" % _ for _ in SUBCOMMANDS])
other = ["aiter.active_aiter", "aiter.aiter_forker", "aiter.aiter_to_iter", "aiter.azip", "aiter.flatten_aiter", "aiter.gated_aiter",
"aiter.iter_to_aiter", "aiter.join_aiters", "aiter.map_aiter", "aiter.map_filter_aiter", "aiter.preload_aiter",
"aiter.push_aiter", "aiter.sharable_aiter", "aiter.stoppable_aiter", "win32timezone", "win32cred", "pywintypes", "win32ctypes.pywin32", "pkg_resources.py2_warn"]
entry_points = ["aiohttp", "aiohttp",
"src.cmds.chia",
"src.server.start_wallet",
"src.server.start_full_node",
"src.server.start_harvester",
"src.server.start_farmer",
"src.server.start_introducer",
"src.server.start_timelord",
"src.timelord_launcher",
"src.util.bip39",
"src.simulator.start_simulator"]
subcommand_modules.extend(other)
subcommand_modules.extend(entry_points)
subcommand_modules.extend(keyring_imports)
daemon = Analysis([f"../src/daemon/server.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [("../venv\Lib\site-packages\\*dll", '.',), ("C:\Windows\System32\\msvcp140.dll", '.',) , ("C:\Windows\System32\\vcruntime140_1.dll", '.',)],
datas=[keyring_datas, version_data, (f"../src/util/initial-config.yaml", f"./src/util/") ] +
hex_puzzles,
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
full_node = Analysis([f"../src/server/start_full_node.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
wallet = Analysis([f"../src/server/start_wallet.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [],
datas=[(f"../mozilla-ca/cacert.pem", f"./mozilla-ca/"), (f"../src/ssl/dst_root_ca.pem", f"./src/ssl/"), (f"../src/ssl/chia_ca.key", f"./src/ssl/"), (f"../src/ssl/chia_ca.crt", f"./src/ssl/"), (f"../src/util/english.txt", f"./src/util/"), version_data ] + hex_puzzles,
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
chia = Analysis([f"../src/cmds/chia.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
farmer = Analysis([f"../src/server/start_farmer.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
harvester = Analysis([f"../src/server/start_harvester.py"],
pathex=[f"../venv/lib/python3.7/site-packages/aiter/", f"../"],
binaries = [],
datas=[version_data],
hiddenimports=subcommand_modules,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
daemon_pyz = PYZ(daemon.pure, daemon.zipped_data,
cipher=block_cipher)
full_node_pyz = PYZ(full_node.pure, full_node.zipped_data,
cipher=block_cipher)
wallet_pyz = PYZ(wallet.pure, wallet.zipped_data,
cipher=block_cipher)
chia_pyz = PYZ(chia.pure, chia.zipped_data,
cipher=block_cipher)
farmer_pyz = PYZ(farmer.pure, farmer.zipped_data,
cipher=block_cipher)
harvester_pyz = PYZ(harvester.pure, harvester.zipped_data,
cipher=block_cipher)
daemon_exe = EXE(daemon_pyz,
daemon.scripts,
[],
exclude_binaries=True,
name='daemon',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
full_node_exe = EXE(full_node_pyz,
full_node.scripts,
[],
exclude_binaries=True,
name='start_full_node',
debug=False,
bootloader_ignore_signals=False,
strip=False)
wallet_exe = EXE(wallet_pyz,
wallet.scripts,
[],
exclude_binaries=True,
name='start_wallet',
debug=False,
bootloader_ignore_signals=False,
strip=False)
chia_exe = EXE(chia_pyz,
chia.scripts,
[],
exclude_binaries=True,
name='chia',
debug=False,
bootloader_ignore_signals=False,
strip=False)
farmer_exe = EXE(farmer_pyz,
farmer.scripts,
[],
exclude_binaries=True,
name='start_farmer',
debug=False,
bootloader_ignore_signals=False,
strip=False)
harvester_exe = EXE(harvester_pyz,
harvester.scripts,
[],
exclude_binaries=True,
name='start_harvester',
debug=False,
bootloader_ignore_signals=False,
strip=False)
coll = COLLECT(daemon_exe,
daemon.binaries,
daemon.zipfiles,
daemon.datas,
full_node_exe,
full_node.binaries,
full_node.zipfiles,
full_node.datas,
wallet_exe,
wallet.binaries,
wallet.zipfiles,
wallet.datas,
chia_exe,
chia.binaries,
chia.zipfiles,
chia.datas,
farmer_exe,
farmer.binaries,
farmer.zipfiles,
farmer.datas,
harvester_exe,
harvester.binaries,
harvester.zipfiles,
harvester.datas,
strip = False,
upx_exclude = [],
name = 'daemon'
)

View File

@ -95,6 +95,7 @@ kwargs = dict(
]
},
package_data={
"src": ["pyinstaller.spec"],
"src.wallet.puzzles": ["*.clvm", "*.clvm.hex"],
"src.util": ["initial-*.yaml", "english.txt"],
"src.ssl": ["chia_ca.crt", "chia_ca.key", "dst_root_ca.pem"],

View File

@ -1,7 +1,9 @@
from pkg_resources import DistributionNotFound, get_distribution
from pkg_resources import DistributionNotFound, get_distribution, resource_filename
try:
__version__ = get_distribution("chia-blockchain").version
except DistributionNotFound:
# package is not installed
__version__ = "unknown"
PYINSTALLER_SPEC_PATH = resource_filename("src", "pyinstaller.spec")

196
src/pyinstaller.spec Normal file
View File

@ -0,0 +1,196 @@
# -*- mode: python ; coding: utf-8 -*-
import importlib
import pathlib
import platform
from pkg_resources import get_distribution
from os import listdir
from os.path import isfile, join
from PyInstaller.utils.hooks import collect_submodules, copy_metadata
THIS_IS_WINDOWS = platform.system().lower().startswith("win")
def dir_for_module(mod_name):
"""
This returns a path to a directory
"""
mod = importlib.import_module(mod_name)
return pathlib.Path(mod.__file__).parent
def path_for_file(mod_name, filename=None):
"""
This returns a path to a file (__init__.py by default)
"""
mod = importlib.import_module(mod_name)
# some modules, like `src.ssl` don't set mod.__file__ because there isn't actually
# any code in there. We have to look at mod.__path__ instead, which is a list.
# for now, we just take the first item, since this function isn't expected to
# return a list of paths, just one path.
# BRAIN DAMAGE
if mod.__file__ is None:
path = pathlib.Path(mod.__path__._path[0])
if filename is None:
raise ValueError("no file __init__.py in this module")
return path / filename
path = pathlib.Path(mod.__file__)
if filename is not None:
path = path.parent / filename
return path
# Include all files that end with clvm.hex
puzzles_path = dir_for_module("src.wallet.puzzles")
puzzle_dist_path = "./src/wallet/puzzles"
onlyfiles = [f for f in listdir(puzzles_path) if isfile(join(puzzles_path, f))]
root = pathlib.Path().absolute()
keyring_imports = collect_submodules("keyring.backends")
# keyring uses entrypoints to read keyring.backends from metadata file entry_points.txt.
keyring_datas = copy_metadata("keyring")[0]
version_data = copy_metadata(get_distribution("chia-blockchain"))[0]
block_cipher = None
other = ["pkg_resources.py2_warn"]
SERVERS = [
"wallet",
"full_node",
"harvester",
"farmer",
"introducer",
"timelord",
]
if THIS_IS_WINDOWS:
other.extend(["win32timezone", "win32cred", "pywintypes", "win32ctypes.pywin32"])
# TODO: collapse all these entry points into one `chia_exec` entrypoint that accepts the server as a parameter
entry_points = ["src.cmds.chia"] + [f"src.server.start_{s}" for s in SERVERS]
if THIS_IS_WINDOWS:
# this probably isn't necessary
entry_points.extend(["aiohttp", "src.util.bip39"])
hiddenimports = []
hiddenimports.extend(other)
hiddenimports.extend(entry_points)
hiddenimports.extend(keyring_imports)
binaries = []
if THIS_IS_WINDOWS:
binaries = [
(
dir_for_module("src").parent / "*.dll",
".",
),
(
"C:\\Windows\\System32\\msvcp140.dll",
".",
),
(
"C:\\Windows\\System32\\vcruntime140_1.dll",
".",
),
]
datas = [
(puzzles_path, puzzle_dist_path),
(path_for_file("mozilla-ca", "cacert.pem"), f"./mozilla-ca/"),
(path_for_file("src.ssl", "dst_root_ca.pem"), f"./src/ssl/"),
(path_for_file("src.ssl", "chia_ca.key"), f"./src/ssl/"),
(path_for_file("src.ssl", "chia_ca.crt"), f"./src/ssl/"),
(path_for_file("src.util", "english.txt"), f"./src/util/"),
version_data,
]
pathex = [root]
chia = Analysis(
[path_for_file("src.cmds.chia")],
pathex=pathex,
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
chia_pyz = PYZ(chia.pure, chia.zipped_data, cipher=block_cipher)
chia_exe = EXE(
chia_pyz,
chia.scripts,
[],
exclude_binaries=True,
name="chia",
debug=False,
bootloader_ignore_signals=False,
strip=False,
)
COLLECT_ARGS = [
chia_exe,
chia.binaries,
chia.zipfiles,
chia.datas,
]
for server in SERVERS:
analysis = Analysis(
[path_for_file(f"src.server.start_{server}")],
pathex=pathex,
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(analysis.pure, analysis.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
analysis.scripts,
[],
exclude_binaries=True,
name=f"start_{server}",
debug=False,
bootloader_ignore_signals=False,
strip=False,
)
COLLECT_ARGS.extend([exe, analysis.binaries, analysis.zipfiles, analysis.datas])
COLLECT_KWARGS = dict(
strip=False,
upx_exclude=[],
name="daemon",
)
coll = COLLECT(*COLLECT_ARGS, **COLLECT_KWARGS)