Skip to content

Instantly share code, notes, and snippets.

@jeffro256
Last active October 30, 2025 16:24
Show Gist options
  • Select an option

  • Save jeffro256/543932a8b9de3a42ce474e7aa9184c86 to your computer and use it in GitHub Desktop.

Select an option

Save jeffro256/543932a8b9de3a42ce474e7aa9184c86 to your computer and use it in GitHub Desktop.
FCMP++ Alpha Stressnet Builder Script
#!/usr/bin/env python3
import argparse
import contextlib
import os
import requests
import subprocess
MONERO_REMOTE = 'seraphis-migration'
MONERO_REPO = 'https://github.com/{}/monero.git'.format(MONERO_REMOTE)
MONERO_BRANCH = 'fcmp++-alpha-stressnet'
MONERO_GUI_REMOTE = 'origin'
MONERO_GUI_REPO = 'https://github.com/monero-project/monero-gui.git'
MONERO_GUI_BRANCH = 'master'
DEFAULT_OUTPUT_DIR = 'fcmp++-stressnet'
MONERO_GUI_SUBDIR = 'monero-gui-repo'
@contextlib.contextmanager
def pushd(new_dir, make = False):
previous_dir = os.getcwd()
if make:
os.makedirs(new_dir, exist_ok=True)
os.chdir(new_dir)
try:
yield
finally:
os.chdir(previous_dir)
def cmd(*args, check=True, **kwargs):
return subprocess.run(*args, check=check, **kwargs)
def parse_args():
parser = argparse.ArgumentParser(
prog='Monero CARROT/FCMP++ Alpha Stressnet Builder',
description='Builds binaries for the Monero CARROT/FCMP++ Alpha Stressnet')
parser.add_argument('-o', '--output-dir', default=DEFAULT_OUTPUT_DIR, help='Directory for build and binary files')
parser.add_argument('-d', '--debug-build', action='store_true', help='Build in debug mode, instead release mode')
parser.add_argument('--no-gui', action='store_true', help='Skip building GUI')
parser.add_argument('-j', '--parallel', type=int, default=1, help='Number of build threads')
return parser.parse_args()
def install_monero_dependencies(gui):
print("Have you installed the following Monero dependencies?:")
print(" * Git")
print(" * GCC")
print(" * CMake")
print(" * pkg-config")
print(" * Boost")
print(" * OpenSSL")
print(" * ZMQ")
print(" * Unbound")
print(" * Sodium")
if gui:
print(" Qt, v5.9.7 or greater")
y = input("Installed (y/n)? ")
if y.lower() != 'y':
print("See the following links to install Monero dependencies on your machine:")
print(" * https://github.com/monero-project/monero?tab=readme-ov-file#dependencies")
print(" * https://github.com/monero-project/monero-gui/?tab=readme-ov-file#compiling-the-monero-gui-from-source")
print("Dependencies not installed, stopping...")
exit(1)
def install_rust():
has_rust = True
try:
cmd(['cargo', '--version'])
except:
has_rust = False
if has_rust:
return
y = input("Rust toolchain is missing. Would you like to install it now (y/n)?")
if y.lower() != 'y':
print("Dependencies not installed, stopping...")
exit(1)
rust_script = requests.get("https://sh.rustup.rs").text
cmd(['sh'], input=rust_script.encode())
def main():
args = parse_args()
assert args.parallel is None or args.parallel > 0
install_monero_dependencies(not args.no_gui)
install_rust()
build_type = 'Debug' if args.debug_build else 'Release'
with pushd(args.output_dir, make = True):
# Clone, pull, & checkout relevant source code
monero_gui_dir = os.path.join(os.getcwd(), MONERO_GUI_SUBDIR)
if not os.path.exists(monero_gui_dir):
cmd(['git', 'clone', '--recursive', MONERO_GUI_REPO, monero_gui_dir])
with pushd(monero_gui_dir):
cmd(['git', 'checkout', MONERO_GUI_BRANCH])
cmd(['git', 'pull'])
with pushd('monero'):
try:
cmd(['git', 'remote', 'add', MONERO_REMOTE, MONERO_REPO])
except:
pass
cmd(['git', 'fetch', '--all'])
cmd(['git', 'checkout', MONERO_BRANCH])
cmd(['git', 'reset', '--hard', '{}/{}'.format(MONERO_REMOTE, MONERO_BRANCH)])
cmd(['git', 'submodule', 'update', '--init', '--force'])
print("Source code pulled!")
# Configure
cmake_config_cmd = ['cmake', '-D', 'CMAKE_BUILD_TYPE='+build_type]
if args.no_gui:
cmake_config_cmd.append(os.path.join(monero_gui_dir, 'monero'))
else: # yes GUI
cmake_config_cmd.extend(['-D', 'DEV_MODE=ON', '-D', 'MANUAL_SUBMODULES=ON'])
cmake_config_cmd.append(os.path.join(monero_gui_dir))
cmd(cmake_config_cmd)
print("Configuration completed!")
# Build
cmd(['cmake', '--build', '.' ] + (['--parallel', str(args.parallel)] if args.parallel is not None else []))
with pushd('bin'):
assert os.path.exists('monerod')
assert os.path.exists('monero-wallet-cli')
assert os.path.exists('monero-wallet-rpc')
if not args.no_gui:
assert os.path.exists('monero-wallet-gui')
monero_bin_path = os.getcwd()
print("Compilation completed!")
# Goodbye
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("Binaries are in directory:", monero_bin_path)
print("Happy stressing!")
if __name__ == '__main__':
main()
@moneroexamples
Copy link

Shouldn't BUILD_TYPE=release be export BUILD_TYPE=release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment