Skip to content

Commit 75b2358

Browse files
committed
tasks: adapt PyInstaller to support "strictdoc server" command
Closes #835
1 parent c0a0ed4 commit 75b2358

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

tasks.py

+9
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,14 @@ def release_pyinstaller(context):
496496
# """
497497
# Solution found here:
498498
# https://stackoverflow.com/a/64473931/598057
499+
#
500+
# The --hidden-import strictdoc.server.app flag is needed because without
501+
# it, the following is produced:
502+
# ERROR: Error loading ASGI app. Could not import
503+
# module "strictdoc.server.app".
504+
# Solution found here: https://stackoverflow.com/a/71340437/598057
505+
# This behavior is not surprising because that's how the uvicorn loads the
506+
# application separately from the parent process.
499507
command = f"""
500508
pip install pyinstaller &&
501509
pyinstaller
@@ -504,6 +512,7 @@ def release_pyinstaller(context):
504512
--noconfirm
505513
--additional-hooks-dir developer/pyinstaller_hooks
506514
--distpath {path_to_pyi_dist}
515+
--hidden-import strictdoc.server.app
507516
--add-data strictdoc/export/html/templates:templates/html
508517
--add-data strictdoc/export/rst/templates:templates/rst
509518
--add-data strictdoc/export/html/_static:_static

tests/unit_server/strictdoc/server/01_hello_world/test_01_hello_world.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from fastapi.testclient import TestClient
44

5+
from strictdoc import environment
56
from strictdoc.cli.cli_arg_parser import ServerCommandConfig
67
from strictdoc.core.project_config import ProjectConfig
78
from strictdoc.server.app import create_app
@@ -11,6 +12,7 @@
1112

1213
def test_get_document():
1314
config = ServerCommandConfig(
15+
environment=environment,
1416
input_path=PATH_TO_THIS_TEST_FOLDER,
1517
output_path=os.path.join(PATH_TO_THIS_TEST_FOLDER, "output"),
1618
reload=False,

tests/unit_server/strictdoc/server/02_export_document_to_reqif/test_02_export_document_to_reqif.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from fastapi.testclient import TestClient
66

7+
from strictdoc import environment
78
from strictdoc.cli.cli_arg_parser import ServerCommandConfig
89
from strictdoc.core.project_config import ProjectConfig
910
from strictdoc.server.app import create_app
@@ -16,6 +17,7 @@ def test_export_document_to_reqif():
1617
shutil.rmtree(PATH_TO_OUTPUT_FOLDER, ignore_errors=True)
1718

1819
config = ServerCommandConfig(
20+
environment=environment,
1921
input_path=PATH_TO_THIS_TEST_FOLDER,
2022
output_path=PATH_TO_OUTPUT_FOLDER,
2123
reload=False,

0 commit comments

Comments
 (0)