Details
Details
- Reviewers
Alphare - Group Reviewers
hg-reviewers - Commits
- rHG5d73d3053d92: pyoxidizer: run buildifier
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
Alphare |
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hgcli/pyoxidizer.bzl (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
ec452e17ccbd | fae02ffcbae8 | Augie Fackler | Nov 19 2020, 2:55 PM |
def make_distribution_windows(): | def make_distribution_windows(): | ||||
return default_python_distribution(flavor = "standalone_dynamic") | return default_python_distribution(flavor = "standalone_dynamic") | ||||
def resource_callback(policy, resource): | def resource_callback(policy, resource): | ||||
if not IS_WINDOWS: | if not IS_WINDOWS: | ||||
resource.add_location = "in-memory" | resource.add_location = "in-memory" | ||||
return | return | ||||
# We use a custom resource routing policy to influence where things are loaded | # We use a custom resource routing policy to influence where things are loaded | ||||
# from. | # from. | ||||
# | # | ||||
# For Python modules and resources, we load from memory if they are in | # For Python modules and resources, we load from memory if they are in | ||||
# the standard library and from the filesystem if not. This is because | # the standard library and from the filesystem if not. This is because | ||||
# parts of Mercurial and some 3rd party packages aren't yet compatible | # parts of Mercurial and some 3rd party packages aren't yet compatible | ||||
# with memory loading. | # with memory loading. | ||||
# | # | ||||
# For Python extension modules, we load from the filesystem because | # For Python extension modules, we load from the filesystem because | ||||
# this yields greatest compatibility. | # this yields greatest compatibility. | ||||
if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"): | if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"): | ||||
if resource.is_stdlib: | if resource.is_stdlib: | ||||
resource.add_location = "in-memory" | resource.add_location = "in-memory" | ||||
else: | else: | ||||
resource.add_location = "filesystem-relative:lib" | resource.add_location = "filesystem-relative:lib" | ||||
elif type(resource) == "PythonExtensionModule": | elif type(resource) == "PythonExtensionModule": | ||||
resource.add_location = "filesystem-relative:lib" | resource.add_location = "filesystem-relative:lib" | ||||
def make_exe(dist): | def make_exe(dist): | ||||
"""Builds a Rust-wrapped Mercurial binary.""" | """Builds a Rust-wrapped Mercurial binary.""" | ||||
packaging_policy = dist.make_python_packaging_policy() | packaging_policy = dist.make_python_packaging_policy() | ||||
# Extension may depend on any Python functionality. Include all | # Extension may depend on any Python functionality. Include all | ||||
# extensions. | # extensions. | ||||
packaging_policy.extension_module_filter = "all" | packaging_policy.extension_module_filter = "all" | ||||
packaging_policy.resources_location = "in-memory" | packaging_policy.resources_location = "in-memory" | ||||
if IS_WINDOWS: | if IS_WINDOWS: | ||||
packaging_policy.resources_location_fallback = "filesystem-relative:lib" | packaging_policy.resources_location_fallback = "filesystem-relative:lib" | ||||
packaging_policy.register_resource_callback(resource_callback) | packaging_policy.register_resource_callback(resource_callback) | ||||
config = dist.make_python_interpreter_config() | config = dist.make_python_interpreter_config() | ||||
config.raw_allocator = "system" | config.raw_allocator = "system" | ||||
config.run_command = RUN_CODE | config.run_command = RUN_CODE | ||||
# We want to let the user load extensions from the file system | # We want to let the user load extensions from the file system | ||||
config.filesystem_importer = True | config.filesystem_importer = True | ||||
# We need this to make resourceutil happy, since it looks for sys.frozen. | # We need this to make resourceutil happy, since it looks for sys.frozen. | ||||
config.sys_frozen = True | config.sys_frozen = True | ||||
config.legacy_windows_stdio = True | config.legacy_windows_stdio = True | ||||
exe = dist.to_python_executable( | exe = dist.to_python_executable( | ||||
name = "hg", | name = "hg", | ||||
packaging_policy = packaging_policy, | packaging_policy = packaging_policy, | ||||
config = config, | config = config, |