PureOne's picture
Publish Qyxo-Zhaenivoth Guard v1.0.0 research release
25c6e75 verified
Raw History Blame Contribute Delete
2.17 kB
#!/usr/bin/env python3
"""Install the bundled wheel into a project-local virtual environment."""
import argparse
import os
from pathlib import Path
import subprocess
import sys
def main():
if sys.version_info < (3, 10):
print('Python 3.10 or newer is required.', file=sys.stderr)
return 2
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--fast', action='store_true', help='install optional NumPy filter (may require network)')
parser.add_argument('--no-demo', action='store_true', help='install and run doctor only')
args = parser.parse_args()
root = Path(__file__).resolve().parents[1]
version = (root / 'VERSION').read_text().strip()
wheels = list((root / 'wheels').glob(f'qyxo_zhaenivoth_guard-{version}-*.whl'))
if len(wheels) != 1:
print('Expected one bundled release wheel; use python -m pip install . instead.', file=sys.stderr)
return 2
environment = root / '.venv'
python = environment / ('Scripts/python.exe' if os.name == 'nt' else 'bin/python')
try:
if not python.is_file():
subprocess.run([sys.executable, '-m', 'venv', str(environment)], check=True)
install = [str(python), '-m', 'pip', 'install']
if args.fast:
install.append(str(wheels[0]) + '[filter]')
else:
# The exact package has no runtime dependencies. The local wheel
# can be installed without an index or a compiler.
install += ['--no-index', '--no-deps', str(wheels[0])]
subprocess.run(install, check=True)
subprocess.run([str(python), '-m', 'qzguard', 'doctor'], cwd=str(root.parent), check=True)
if not args.no_demo:
subprocess.run([str(python), '-m', 'qzguard', 'demo', '--backend',
'filtered' if args.fast else 'exact'], cwd=str(root.parent), check=True)
except (OSError, subprocess.CalledProcessError) as exc:
print(f'Installation did not complete: {exc}', file=sys.stderr)
return 2
print(f'Ready. Run: {python} -m qzguard --help')
return 0
if __name__ == '__main__':
raise SystemExit(main())