Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Stop shipping test suites in the wheel and the sdist (#10060)

Daniel Han6179e0461066
diff --git a/.github/workflows/wheel-smoke.yml b/.github/workflows/wheel-smoke.yml
index b57a3bd0a6e..41bab003cd8 100644
--- a/.github/workflows/wheel-smoke.yml
+++ b/.github/workflows/wheel-smoke.yml
@@ -21,6 +21,7 @@ on:
pull_request:
paths:
- 'pyproject.toml'
+ - 'MANIFEST.in'
- 'studio/**'
- 'unsloth/**'
- 'unsloth_cli/**'
@@ -29,6 +30,7 @@ on:
branches: [main]
paths:
- 'pyproject.toml'
+ - 'MANIFEST.in'
- 'studio/**'
- 'unsloth/**'
- 'unsloth_cli/**'
@@ -119,6 +121,46 @@ jobs:
sys.exit(0 if all(checks.values()) else 1)
PY
+ - name: No test suites in wheel or sdist
+ # tests/security/fixtures embeds a real supply-chain IOC literal, which got
+ # the published sdist flagged by antivirus vendors (discussion #9577).
+ run: |
+ python - <<'PY'
+ import glob, sys, tarfile, zipfile
+
+ def is_test(path):
+ return "tests" in path.strip("/").split("/")
+
+ def report(label, names):
+ offenders = sorted(n for n in names if is_test(n))
+ ioc = sorted(n for n in names if "malicious_" in n)
+ print(f"{label}: {len(offenders)} test paths, {len(ioc)} IOC fixtures")
+ for n in offenders[:20]:
+ print(f" {n}")
+ if len(offenders) > 20:
+ print(f" ... and {len(offenders) - 20} more")
+ for n in ioc:
+ print(f" IOC {n}")
+ return not offenders and not ioc
+
+ ok = True
+ wheels = glob.glob("dist/unsloth-*.whl")
+ sdists = glob.glob("dist/unsloth-*.tar.gz")
+ if not wheels or not sdists:
+ print("FAIL: expected one wheel and one sdist in dist/")
+ sys.exit(2)
+ with zipfile.ZipFile(wheels[0]) as z:
+ ok &= report(f"wheel {wheels[0]}", z.namelist())
+ with tarfile.open(sdists[0]) as t:
+ # Every sdist member carries an "unsloth-<version>/" prefix.
+ ok &= report(
+ f"sdist {sdists[0]}",
+ [n.split("/", 1)[1] for n in t.getnames() if "/" in n],
+ )
+ print("PASS" if ok else "FAIL: test files are being shipped")
+ sys.exit(0 if ok else 1)
+ PY
+
- name: Unsloth backend import smoke
# Imports `studio.backend.main:app` from the freshly-installed wheel in
# a clean venv. This catches the class of bug that 2026.5.1 shipped with:
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 00000000000..c8da64c7502
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
+
+# The only veto that travels inside the sdist, so it holds for the wheel too:
+# `python -m build` rebuilds the wheel from the sdist, where exclude-package-data
+# and packages.find no longer bite (no .git tree for the file finder).
+prune tests
+prune studio/backend/tests
+prune studio/backend/hub/tests
+prune studio/frontend/tests
+prune unsloth_cli/tests
+prune unsloth/kernels/moe/tests
+
+# Backstop for a suite added anywhere else later. `prune` and a `*` glob are both
+# single-level, so this needs `**`, and it cannot see a root-level tests/ at all.
+global-exclude */tests/**
diff --git a/pyproject.toml b/pyproject.toml
index f3b318580cb..4f1a5cb7021 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -84,18 +84,17 @@ exclude = [
"tests*",
"studio.backend.tests*",
"studio.backend.*.tests*",
+ "unsloth_cli.tests*",
+ "unsloth.kernels.moe.tests*",
"unsloth_compiled_cache*",
"*.unsloth_compiled_cache*",
"*.node_modules",
"*.node_modules.*",
]
-# packages.find only decides what is importable. include-package-data then hands
-# every tracked file to the nearest parent package that survived, so dropping
-# studio.backend.tests above just re-shipped the same 505 files as data of
-# studio.backend (pypa/setuptools#3260). exclude-package-data has the highest
-# precedence of the file selection options, so the veto has to be repeated here.
-# Source layout, not the wheel, so the sdist keeps the suites either way.
+# Excluding a tests package above is not enough: include-package-data re-ships its
+# files as data of the surviving parent (pypa/setuptools#3260), and only
+# exclude-package-data outranks that.
[tool.setuptools.exclude-package-data]
"studio.backend" = ["tests/*"]
"studio.backend.hub" = ["tests/*"]