##// END OF EJS Templates
packaging: enable rust extensions on centos...
packaging: enable rust extensions on centos Test on CentOS 7, repository with ~170000 tracked files, no untracked files: 10 runs with this enabled: -- Run #0 time: 0.6519973278045654 -- Run #1 time: 0.6933724880218506 -- Run #2 time: 0.7512078285217285 -- Run #3 time: 0.7517638206481934 -- Run #4 time: 0.5966529846191406 -- Run #5 time: 0.5960886478424072 -- Run #6 time: 0.5940573215484619 -- Run #7 time: 0.5963726043701172 -- Run #8 time: 0.6048009395599365 -- Run #9 time: 0.603604793548584 10 runs without this enabled: -- Run #0 time: 2.127584457397461 -- Run #1 time: 2.066192865371704 -- Run #2 time: 2.0831892490386963 -- Run #3 time: 2.077716588973999 -- Run #4 time: 2.07608962059021 -- Run #5 time: 2.072899341583252 -- Run #6 time: 2.094369888305664 -- Run #7 time: 2.067504644393921 -- Run #8 time: 2.069610834121704 -- Run #9 time: 2.0567898750305176 Differential Revision: https://phab.mercurial-scm.org/D9294

File last commit:

r46539:926c7ed4 default
r46547:eccbfa7e default
Show More
pyoxidizer.bzl
116 lines | 3.7 KiB | text/x-python | PythonLexer
Gregory Szorc
hgcli: customize for Mercurial...
r45129 ROOT = CWD + "/../.."
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 # Code to run in Python interpreter.
RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
set_build_path(ROOT + "/build/pyoxidizer")
def make_distribution():
return default_python_distribution()
def make_distribution_windows():
Rodrigo Damazio Bovendorp
pyoxidizer: formatting bazel definitions...
r45339 return default_python_distribution(flavor = "standalone_dynamic")
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 def resource_callback(policy, resource):
Augie Fackler
pyoxidizer: default to one-file binary on non-Windows platforms...
r46435 if not IS_WINDOWS:
resource.add_location = "in-memory"
return
Augie Fackler
pyoxidizer: run buildifier...
r46491
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 # We use a custom resource routing policy to influence where things are loaded
# from.
#
# 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
# parts of Mercurial and some 3rd party packages aren't yet compatible
# with memory loading.
#
# For Python extension modules, we load from the filesystem because
# this yields greatest compatibility.
if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
if resource.is_stdlib:
resource.add_location = "in-memory"
else:
resource.add_location = "filesystem-relative:lib"
elif type(resource) == "PythonExtensionModule":
resource.add_location = "filesystem-relative:lib"
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 def make_exe(dist):
Rodrigo Damazio Bovendorp
pyoxidizer: formatting bazel definitions...
r45339 """Builds a Rust-wrapped Mercurial binary."""
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 packaging_policy = dist.make_python_packaging_policy()
Augie Fackler
pyoxidizer: run buildifier...
r46491
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 # Extension may depend on any Python functionality. Include all
# extensions.
packaging_policy.extension_module_filter = "all"
Gregory Szorc
pyoxidizer: update to PyOxidizer 0.9...
r46341 packaging_policy.resources_location = "in-memory"
Augie Fackler
pyoxidizer: default to one-file binary on non-Windows platforms...
r46435 if IS_WINDOWS:
packaging_policy.resources_location_fallback = "filesystem-relative:lib"
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 packaging_policy.register_resource_callback(resource_callback)
Gregory Szorc
pyoxidizer: update to PyOxidizer 0.9...
r46341 config = dist.make_python_interpreter_config()
config.raw_allocator = "system"
Augie Fackler
pyoxidizer: switch to modern config using run_command instead of run_mode...
r46436 config.run_command = RUN_CODE
Augie Fackler
pyoxidizer: run buildifier...
r46491
Gregory Szorc
pyoxidizer: update to PyOxidizer 0.9...
r46341 # We want to let the user load extensions from the file system
config.filesystem_importer = True
Augie Fackler
pyoxidizer: run buildifier...
r46491
Gregory Szorc
pyoxidizer: update to PyOxidizer 0.9...
r46341 # We need this to make resourceutil happy, since it looks for sys.frozen.
config.sys_frozen = True
config.legacy_windows_stdio = True
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128
exe = dist.to_python_executable(
Gregory Szorc
hgcli: customize for Mercurial...
r45129 name = "hg",
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 packaging_policy = packaging_policy,
Gregory Szorc
hgcli: customize for Mercurial...
r45129 config = config,
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128 )
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 # Add Mercurial to resources.
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 exe.add_python_resources(exe.pip_install(["--verbose", ROOT]))
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270
# On Windows, we install extra packages for convenience.
Gregory Szorc
pyoxidizer: produce working Python 3 Windows installers (issue6366)...
r46277 if IS_WINDOWS:
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 exe.add_python_resources(
Matt Harbison
pyoxidizer: point to the py3 requirements instead of py2 on Windows...
r46539 exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]),
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 )
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128
Gregory Szorc
hgcli: customize for Mercurial...
r45129 return exe
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 def make_manifest(dist, exe):
Gregory Szorc
hgcli: customize for Mercurial...
r45129 m = FileManifest()
m.add_python_resource(".", exe)
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 return m
Gregory Szorc
hgcli: add stub PyOxidizer project...
r45128
def make_embedded_resources(exe):
return exe.to_embedded_resources()
Gregory Szorc
packaging: support building Inno installer with PyOxidizer...
r45270 register_target("distribution_posix", make_distribution)
register_target("distribution_windows", make_distribution_windows)
register_target("exe_posix", make_exe, depends = ["distribution_posix"])
register_target("exe_windows", make_exe, depends = ["distribution_windows"])
register_target(
"app_posix",
make_manifest,
depends = ["distribution_posix", "exe_posix"],
default = "windows" not in BUILD_TARGET_TRIPLE,
)
register_target(
"app_windows",
make_manifest,
depends = ["distribution_windows", "exe_windows"],
default = "windows" in BUILD_TARGET_TRIPLE,
)
Gregory Szorc
hgcli: add stub PyOxidizer project...
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.
Gregory Szorc
pyoxidizer: update to PyOxidizer 0.9...
r46341 PYOXIDIZER_VERSION = "0.9.0"
PYOXIDIZER_COMMIT = "1fbc264cc004226cd76ee452e0a386ffca6ccfb1"