From 141a811ba6af0aa54f550911af37d5220f8b0e87 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Thu, 30 Dec 2021 19:27:04 +0000 Subject: [PATCH] Enable creating a binary with PyOxidizer With PyOxidizer 0.18.0 AppName in setup.py has to be changed to the all lower case "linkchecker". Application translations do not work. better_exchook2.fallback_findfile() may still need converting, first needs a test. --- MANIFEST.in | 1 + linkcheck/command/arg_parser.py | 6 ++++-- pyoxidizer.bzl | 13 +++++++++++++ setup.py | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 pyoxidizer.bzl diff --git a/MANIFEST.in b/MANIFEST.in index 6086421e..59a2d997 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,7 @@ include Dockerfile include MANIFEST.in include Makefile include install-rpm.sh +include pyoxidizer.bzl include .project include .pydevproject include .yamllint diff --git a/linkcheck/command/arg_parser.py b/linkcheck/command/arg_parser.py index edb36068..672dd242 100644 --- a/linkcheck/command/arg_parser.py +++ b/linkcheck/command/arg_parser.py @@ -19,7 +19,7 @@ Create command line arguments. import argparse -from .. import checker, logconf, logger +from .. import checker, logconf, logger, COMMAND_NAME from ..cmdline import LCArgumentParser @@ -205,7 +205,9 @@ class ArgParser(LCArgumentParser): def __init__(self): super().__init__( - epilog=Epilog, formatter_class=argparse.RawDescriptionHelpFormatter + epilog=Epilog, + formatter_class=argparse.RawDescriptionHelpFormatter, + prog=COMMAND_NAME, ) # ================== general options ===================== diff --git a/pyoxidizer.bzl b/pyoxidizer.bzl new file mode 100644 index 00000000..15df924f --- /dev/null +++ b/pyoxidizer.bzl @@ -0,0 +1,13 @@ +def make_exe(): + dist = default_python_distribution() + python_config = dist.make_python_interpreter_config() + python_config.run_module = "linkcheck" + exe = dist.to_python_executable( + name="linkchecker", + config=python_config, + ) + exe.add_python_resources(exe.pip_install([CWD])) + return exe + +register_target("exe", make_exe) +resolve_targets() diff --git a/setup.py b/setup.py index 8aa05fad..a0f1d865 100755 --- a/setup.py +++ b/setup.py @@ -47,6 +47,10 @@ else: # the application name AppName = "LinkChecker" +if "PYOXIDIZER" in os.environ: + # Name with capitals not supported by PyOxidizer 0.18.0 + # https://github.com/indygreg/PyOxidizer/issues/488 + AppName = AppName.lower() Description = "check links in web documents or full websites" RELEASE_DATE_FILE = "_release_date"