##// END OF EJS Templates
packaging: add support for PyOxidizer...
packaging: add support for PyOxidizer I've successfully built Mercurial on the development tip of PyOxidizer on Linux and Windows. It mostly "just works" on Linux. Windows is a bit more finicky. In-memory resource files are probably not all working correctly due to bugs in PyOxidizer's naming of modules. PyOxidizer now now supports installing files next to the produced binary. (We do this for templates in the added file.) So a workaround should be available. Also, since the last time I submitted support for PyOxidizer, PyOxidizer gained the ability to auto-generate Rust projects to build executables. So we don't need to worry about vendoring any Rust code to initially support PyOxidizer. However, at some point we will likely want to write our own command line driver that embeds a Python interpreter via PyOxidizer so we can run Rust code outside the confines of a Python interpreter. But that will be a follow-up. I would also like to add packaging.py CLI commands to build PyOxidizer distributions. This can come later, if ever. PyOxidizer's new "targets" feature makes it really easy to define packaging tasks in its Starlark configuration file. While not much is implemented yet, eventually we should be able to produce MSIs, etc using a `pyoxidizer build` one-liner. We'll get there... Differential Revision: https://phab.mercurial-scm.org/D7450

File last commit:

r43346:2372284d default
r44697:281b6690 default
Show More
__init__.py
57 lines | 1.5 KiB | text/x-python | PythonLexer
Gregory Szorc
automation: perform tasks on remote machines...
r42191 # __init__.py - High-level automation interfaces
#
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# no-check-code because Python 3 native.
import pathlib
import secrets
Augie Fackler
formatting: blacken the codebase...
r43346 from .aws import AWSConnection
Gregory Szorc
automation: perform tasks on remote machines...
r42191
class HGAutomation:
"""High-level interface for Mercurial automation.
Holds global state, provides access to other primitives, etc.
"""
def __init__(self, state_path: pathlib.Path):
self.state_path = state_path
state_path.mkdir(exist_ok=True)
def default_password(self):
"""Obtain the default password to use for remote machines.
A new password will be generated if one is not stored.
"""
p = self.state_path / 'default-password'
try:
with p.open('r', encoding='ascii') as fh:
data = fh.read().strip()
if data:
return data
except FileNotFoundError:
pass
password = secrets.token_urlsafe(24)
with p.open('w', encoding='ascii') as fh:
fh.write(password)
fh.write('\n')
p.chmod(0o0600)
return password
Augie Fackler
formatting: blacken the codebase...
r43346 def aws_connection(self, region: str, ensure_ec2_state: bool = True):
Gregory Szorc
automation: perform tasks on remote machines...
r42191 """Obtain an AWSConnection instance bound to a specific region."""
Gregory Szorc
automation: don't create resources when deleting things...
r42463 return AWSConnection(self, region, ensure_ec2_state=ensure_ec2_state)