Skip to content

Commit

Permalink
CFR: Build as a self-contained program using PyInstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
seut authored and amotl committed Jul 8, 2024
1 parent 33ded9c commit 58c2bf2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- MongoDB: Added adapter amalgamating PyMongo to use CrateDB as backend
- SQLAlchemy: Clean up and refactor SQLAlchemy polyfills
to `cratedb_toolkit.util.sqlalchemy`
- CFR: Build as a self-contained program using PyInstaller

## 2024/06/18 v0.0.14
- Add `ctk cfr` and `ctk wtf` diagnostics programs
Expand Down
8 changes: 8 additions & 0 deletions cratedb_toolkit/cfr/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2021-2024, Crate.io Inc.
# Distributed under the terms of the AGPLv3 license, see LICENSE.
import logging
import multiprocessing
import sys

import click
Expand Down Expand Up @@ -77,3 +78,10 @@ def sys_import(ctx: click.Context, source: str):
except Exception as ex:
error_logger(ctx)(ex)
sys.exit(1)


if getattr(sys, "frozen", False):
# https://github.com/pyinstaller/pyinstaller/issues/6368
multiprocessing.freeze_support()
# https://stackoverflow.com/questions/45090083/freeze-a-program-created-with-pythons-click-pacage
cli(sys.argv[1:])
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ all = [
"cratedb-toolkit[full,influxdb,mongodb]",
]
cfr = [
"pandas<3,>=1",
"pyarrow<17",
"pandas<2.2",
"pyarrow<16.1",
]
cloud = [
"croud==1.11.1",
Expand Down Expand Up @@ -167,6 +167,9 @@ release = [
"build<2",
"twine<6",
]
release-cfr = [
"pyinstaller<7",
]
service = [
"fastapi<0.112",
"uvicorn<0.31",
Expand Down Expand Up @@ -195,6 +198,7 @@ documentation = "https://github.com/crate-workbench/cratedb-toolkit"
homepage = "https://github.com/crate-workbench/cratedb-toolkit"
repository = "https://github.com/crate-workbench/cratedb-toolkit"
[project.scripts]
cratedb-cfr = "cratedb_toolkit.cfr.cli:cli"
cratedb-retention = "cratedb_toolkit.retention.cli:cli"
cratedb-toolkit = "cratedb_toolkit.cli:cli"
cratedb-wtf = "cratedb_toolkit.wtf.cli:cli"
Expand Down Expand Up @@ -355,3 +359,5 @@ release = [
]

test = { cmd = "pytest" }

build-cfr = { cmd = "pyinstaller cratedb_toolkit/cfr/cli.py --onefile --name cratedb-cfr"}

0 comments on commit 58c2bf2

Please sign in to comment.