fix(export): use python -m nbdev.export instead of nbdev_export command

The nbdev_export command wasn't in PATH in CI. Using sys.executable
with -m nbdev.export ensures we use the same Python environment that's
running tito, which is more reliable across different environments.

Fixed in:
- tito/commands/dev/export.py (both _export_all_modules and _run_nbdev_export)
- tito/commands/module/workflow.py (_export_notebook)
This commit is contained in:
Vijay Janapa Reddi
2026-01-29 14:19:26 -05:00
parent 2546b54bba
commit 2ec60a6f5c
2 changed files with 9 additions and 3 deletions

View File

@@ -208,8 +208,10 @@ class DevExportCommand(BaseCommand):
# Step 2: Export all using nbdev_export
console.print("🔄 Exporting all notebooks to tinytorch package...")
try:
# Use sys.executable to ensure we use the same Python that's running tito
import sys
result = subprocess.run(
["nbdev_export"],
[sys.executable, "-m", "nbdev.export"],
capture_output=True,
text=True,
cwd=Path.cwd()
@@ -240,6 +242,7 @@ class DevExportCommand(BaseCommand):
def _run_nbdev_export(self, notebook_paths: list, console) -> int:
"""Run nbdev_export on the given notebooks."""
import sys
success_count = 0
for notebook_path_str in notebook_paths:
@@ -254,8 +257,9 @@ class DevExportCommand(BaseCommand):
if export_target != "unknown":
ensure_writable_target(export_target)
# Use sys.executable to ensure we use the same Python that's running tito
result = subprocess.run(
["nbdev_export", "--path", notebook_path_str],
[sys.executable, "-m", "nbdev.export", "--path", notebook_path_str],
capture_output=True,
text=True,
cwd=Path.cwd()

View File

@@ -1110,10 +1110,12 @@ class ModuleWorkflowCommand(BaseCommand):
ensure_writable_target(export_target)
# Run nbdev_export directly on the student's notebook
# Use sys.executable to ensure we use the same Python that's running tito
import sys
self.console.print(f"[dim]📦 Exporting {notebook_path.name} → tinytorch/core/...[/dim]")
result = subprocess.run(
["nbdev_export", "--path", str(notebook_path)],
[sys.executable, "-m", "nbdev.export", "--path", str(notebook_path)],
capture_output=True,
text=True,
cwd=Path.cwd()