timestral-mlx / scripts /build_wheel.py
jbilcke's picture
Publish all four Timestral MLX FP32 models, pipeline, original licences and validation
d35e174 verified
Raw History Blame Contribute Delete
1.42 kB
"""Build from an explicit clean temporary tree, excluding Apple filesystem metadata."""
import shutil
import subprocess
import sys
import tempfile
import zipfile
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory(prefix='timestral-build-') as tmp:
stage=Path(tmp)
for name in ('pyproject.toml','README.md','LICENSE','LICENSE-WEIGHTS','NOTICE','MANIFEST.in'):
shutil.copyfile(ROOT/name,stage/name)
(stage/'timestral_mlx').mkdir()
for path in (ROOT/'timestral_mlx').glob('*.py'):
if not path.name.startswith('._'):
shutil.copyfile(path,stage/'timestral_mlx'/path.name)
subprocess.run([sys.executable,'-m','build','--wheel','--no-isolation','--outdir',str(stage/'wheelhouse'),str(stage)],check=True)
(ROOT/'dist').mkdir(exist_ok=True)
for wheel in (stage/'wheelhouse').glob('*.whl'):
shutil.copyfile(wheel,ROOT/'dist'/wheel.name)
for path in (ROOT/'dist').glob('*.whl'):
if path.name.startswith('._'): continue
with zipfile.ZipFile(path) as z:
assert not any(any(p.startswith('._') or p in {'.DS_Store','__MACOSX'} for p in name.split('/')) for name in z.namelist())
assert any(name.endswith('/licenses/LICENSE-WEIGHTS') for name in z.namelist())
assert any(name.endswith('/licenses/NOTICE') for name in z.namelist())
print(f'Wheel inventory verified: {path.name}',flush=True)