Complete worked example
python
import json
from pathlib import Path
import subprocess
import sys
import venv
def inspect_example(rows, minimum):
project = Path('project').resolve()
subprocess.run([sys.executable, '-m', 'build', '--no-isolation', '--wheel', '--outdir', 'dist'],
cwd=project, capture_output=True, text=True, check=True)
wheel = next((project / 'dist').glob('*.whl'))
environment = Path('installed').resolve()
venv.EnvBuilder(with_pip=True).create(environment)
python = environment / ('Scripts/python.exe' if sys.platform == 'win32' else 'bin/python')
subprocess.run([str(python), '-I', '-m', 'pip', 'install', '--no-index', '--no-deps', str(wheel)],
capture_output=True, text=True, check=True)
outside = Path('outside').resolve()
outside.mkdir()
script = environment / ('Scripts/pye-report.exe' if sys.platform == 'win32' else 'bin/pye-report')
command = [str(script), '--minimum', str(minimum)]
run = subprocess.run(command, cwd=outside, input=json.dumps(rows),
capture_output=True, text=True, check=True)
metadata = subprocess.run([str(python), '-I', '-c',
"from importlib.metadata import version; print(version('applydjinn-owned-report'))"],
cwd=outside, capture_output=True, text=True, check=True)
return {'report': json.loads(run.stdout), 'version': metadata.stdout.strip()}- Reasoning
- The driver builds and installs the exact local wheel into a fresh environment, then runs the generated pye-report console command from an outside directory. This verifies the declared entry-point target rather than merely importing its function in the checkout.