Monkey-patch click instead of forking.

This commit is contained in:
Richard Kiss 2021-03-18 14:25:33 -07:00 committed by Justin England
parent 77e38fc109
commit be4af4128c
2 changed files with 18 additions and 1 deletions

View file

@ -23,7 +23,7 @@ dependencies = [
"setproctitle==1.2.2", # Gives the chia processes readable names
"sortedcontainers==2.3.0", # For maintaining sorted mempools
"websockets==8.1.0", # For use in wallet RPC and electron UI
"click@https://github.com/Chia-Network/click/tarball/master#egg=package-1.0", # For the CLI
"click==7.1.2", # For the CLI
]
upnp_dependencies = [

View file

@ -20,6 +20,22 @@ from src.util.default_root import DEFAULT_ROOT_PATH
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
def monkey_patch_click():
# this hacks around what seems to be an incompatibility between the python from `pyinstaller`
# and `click`
#
# Not 100% sure on the details, but it seems that `click` performs a check on start-up
# that `codecs.lookup(locale.getpreferredencoding()).name != 'ascii'`, and refuses to start
# if it's not. The python that comes with `pyinstaller` fails this check.
#
# This will probably cause problems with the command-line tools that use parameters that
# are not strict ascii. The real fix is likely with the `pyinstaller` python.
import click.core
click.core._verify_python3_env = lambda *args, **kwargs: 0
@click.group(
help=f"\n Manage chia blockchain infrastructure ({__version__})\n",
epilog="Try 'chia start node', 'chia netspace -d 192', or 'chia show -s'",
@ -56,6 +72,7 @@ cli.add_command(farm_cmd)
def main() -> None:
monkey_patch_click()
cli() # pylint: disable=no-value-for-parameter