Skip to content

Instantly share code, notes, and snippets.

@dmgolembiowski
Created June 5, 2021 05:30
Show Gist options
  • Save dmgolembiowski/11d6ed04516c3751023e54981d8f5e67 to your computer and use it in GitHub Desktop.
Save dmgolembiowski/11d6ed04516c3751023e54981d8f5e67 to your computer and use it in GitHub Desktop.
MODULE_ROOT_DIRECTORY = "my_app" # ./my_app/__main__.py
HAS_REQUIREMENTS = False
def make_dist():
return default_python_distribution()
def make_exe(dist):
policy = dist.make_python_packaging_policy()
policy.allow_files = True
policy.bytecode_optimize_level_one = True
policy.extension_module_filter = "all"
policy.include_classified_resources = True
policy.include_distribution_sources = True # False
policy.include_distribution_resources = True # False
policy.include_file_resources = False
policy.include_non_distribution_sources = True
policy.resources_location = "in-memory"
python_config = dist.make_python_interpreter_config()
python_config.module_search_paths = ["$ORIGIN/lib", "$ORIGIN/include"]
python_config.run_module = MODULE_ROOT_DIRECTORY
exe = dist.to_python_executable(
name=MODULE_ROOT_DIRECTORY,
packaging_policy=policy,
config=python_config,
)
if HAS_REQUIREMENTS:
# exe.add_python_resources(exe.pip_download(["library_without_dunder_file_dunder==1.1.1"]))
exe.add_python_resources(exe.pip_install(["-r", "requirements.txt"]))
exe.add_python_resources(exe.read_package_root(
path="./",
packages=[MODULE_ROOT_DIRECTORY],
))
exe.add_python_resources(exe.read_virtualenv(path="./"))
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
files = FileManifest()
files.add_python_resource(".", exe)
return files
register_target("dist", make_dist)
register_target("exe", make_exe, depends=["dist"])
register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"], default=True)
resolve_targets()
PYOXIDIZER_VERSION = "0.10.3"
PYOXIDIZER_COMMIT = "UNKNOWN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment