#!/usr/bin/env python3

# Test if Units/python/__init__.py needs to be re-generated, which it must
# whenever Units/libinc/Units.hh is updated.

import subprocess
import os
import pathlib

autogen = subprocess.run( 'sb_utilstests_printunitpy',
                          capture_output = True,
                          text = True,
                          check = True ).stdout

current = ( pathlib.Path( os.environ['SBLD_INSTALL_PREFIX'] ) / 'python' / 'Units' / '__init__.py' ).read_text()

if autogen != current:
    raise SystemExit('Units.hh changed! Units/__init__.py must be updated'
                     ' with output of sb_utilstests_printunitpy command')
