File size: 1,422 Bytes
d35e174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""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)