|
36 | 36 |
|
37 | 37 | KNOWN_BACKENDS = {"cpu", "cuda", "metal", "neuron", "rocm", "xpu", "npu"} |
38 | 38 |
|
| 39 | +# Exclude patter for bytecode. These are not included in kernel builds, |
| 40 | +# but builds not done using kernel-builder might accidentally include |
| 41 | +# bytcode. So these patterns are used to ensure that they are never |
| 42 | +# downloaded. |
| 43 | +_BYTECODE_IGNORE_PATTERNS = ["*.pyc", "**/__pycache__/**"] |
| 44 | + |
39 | 45 |
|
40 | 46 | def _check_trust_remote_code(repo_id: str, trust_remote_code: bool | list[str]) -> None: |
41 | 47 | """Check whether a kernel repository is trusted. |
@@ -302,7 +308,7 @@ def install_kernel( |
302 | 308 | _validate_variant_dependencies(Path(metadata_path).parent) |
303 | 309 |
|
304 | 310 | allow_patterns = [f"build/{variant.variant_str}/*"] |
305 | | - ignore_patterns = ["*.pyc", "**/__pycache__/**"] |
| 311 | + ignore_patterns = _BYTECODE_IGNORE_PATTERNS |
306 | 312 |
|
307 | 313 | repo_path = Path( |
308 | 314 | str( |
@@ -368,7 +374,7 @@ def _resolve_local_variant_path( |
368 | 374 | ) |
369 | 375 |
|
370 | 376 | allow_patterns = [f"build/{variant.variant_str}/*"] |
371 | | - ignore_patterns = ["*.pyc", "**/__pycache__/**"] |
| 377 | + ignore_patterns = _BYTECODE_IGNORE_PATTERNS |
372 | 378 | repo_path = Path( |
373 | 379 | str( |
374 | 380 | api.snapshot_download( |
@@ -420,7 +426,7 @@ def install_kernel_all_variants( |
420 | 426 | repo_id, |
421 | 427 | repo_type="kernel", |
422 | 428 | allow_patterns="build/*", |
423 | | - ignore_patterns=["*.pyc", "**/__pycache__/**"], |
| 429 | + ignore_patterns=_BYTECODE_IGNORE_PATTERNS, |
424 | 430 | cache_dir=CACHE_DIR, |
425 | 431 | revision=revision, |
426 | 432 | local_files_only=local_files_only, |
|
0 commit comments