pyoxidizer.bzl
59 lines
| 1.7 KiB
| text/x-python
|
PythonLexer
Gregory Szorc
|
r45129 | ROOT = CWD + "/../.." | ||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | def make_exe(): | ||
dist = default_python_distribution() | ||||
code = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()" | ||||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | config = PythonInterpreterConfig( | ||
raw_allocator = "system", | ||||
run_eval = code, | ||||
# We want to let the user load extensions from the file system | ||||
filesystem_importer = True, | ||||
# We need this to make resourceutil happy, since it looks for sys.frozen. | ||||
sys_frozen = True, | ||||
legacy_windows_stdio = True, | ||||
Gregory Szorc
|
r45128 | ) | ||
exe = dist.to_python_executable( | ||||
Gregory Szorc
|
r45129 | name = "hg", | ||
resources_policy = "prefer-in-memory-fallback-filesystem-relative:lib", | ||||
config = config, | ||||
# Extension may depend on any Python functionality. Include all | ||||
# extensions. | ||||
Gregory Szorc
|
r45128 | extension_module_filter = "all", | ||
) | ||||
Gregory Szorc
|
r45129 | exe.add_python_resources(dist.pip_install([ROOT])) | ||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | return exe | ||
def make_install(exe): | ||||
m = FileManifest() | ||||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | # `hg` goes in root directory. | ||
m.add_python_resource(".", exe) | ||||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | templates = glob( | ||
include = [ROOT + "/mercurial/templates/**/*"], | ||||
strip_prefix = ROOT + "/mercurial/", | ||||
) | ||||
m.add_manifest(templates) | ||||
Gregory Szorc
|
r45128 | |||
Gregory Szorc
|
r45129 | return m | ||
Gregory Szorc
|
r45128 | |||
def make_embedded_resources(exe): | ||||
return exe.to_embedded_resources() | ||||
Gregory Szorc
|
r45129 | register_target("exe", make_exe) | ||
register_target("app", make_install, depends = ["exe"], default = True) | ||||
register_target("embedded", make_embedded_resources, depends = ["exe"], default_build_script = True) | ||||
Gregory Szorc
|
r45128 | resolve_targets() | ||
# END OF COMMON USER-ADJUSTED SETTINGS. | ||||
# | ||||
# Everything below this is typically managed by PyOxidizer and doesn't need | ||||
# to be updated by people. | ||||
PYOXIDIZER_VERSION = "0.7.0-pre" | ||||
PYOXIDIZER_COMMIT = "c772a1379c3026314eda1c8ea244b86c0658951d" | ||||