Skip to content

Commit d071bb7

Browse files
fix(cli): use absolute import in generated Python build scripts (#1505)
Fixes the generated Python build scripts to use an absolute import (from template import template) instead of a relative one, which broke python build_dev.py with ImportError: attempted relative import with no known parent package since the files are emitted as flat siblings with no package. This reverts an unintended change from #954 that was flagged by Cursor Bugbot at the time but not addressed. Fixes #1477.
1 parent 2869feb commit d071bb7

32 files changed

Lines changed: 44 additions & 30 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@e2b/cli": patch
3+
---
4+
5+
Fix `e2b template migrate` generating Python build scripts that fail to run as instructed. The generated `build_dev.py` / `build_prod.py` used a package-relative import (`from .template import template`) while the command instructs single-file execution (`python build_dev.py`), causing `ImportError: attempted relative import with no known parent package`. The scripts now use a runnable absolute import (`from template import template`).

packages/cli/src/templates/python-build-async.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from e2b import AsyncTemplate, default_build_logger
3-
from .template import template
3+
from template import template
44

55

66
async def main():

packages/cli/src/templates/python-build-sync.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from e2b import Template, default_build_logger
2-
from .template import template
2+
from template import template
33

44

55
if __name__ == "__main__":

packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from e2b import AsyncTemplate, default_build_logger
3-
from .template import template
3+
from template import template
44

55

66
async def main():

packages/cli/tests/commands/template/fixtures/complex-python/expected/python-async/build_prod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from e2b import AsyncTemplate, default_build_logger
3-
from .template import template
3+
from template import template
44

55

66
async def main():

packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from e2b import Template, default_build_logger
2-
from .template import template
2+
from template import template
33

44

55
if __name__ == "__main__":

packages/cli/tests/commands/template/fixtures/complex-python/expected/python-sync/build_prod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from e2b import Template, default_build_logger
2-
from .template import template
2+
from template import template
33

44

55
if __name__ == "__main__":

packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from e2b import AsyncTemplate, default_build_logger
3-
from .template import template
3+
from template import template
44

55

66
async def main():

packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-async/build_prod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from e2b import AsyncTemplate, default_build_logger
3-
from .template import template
3+
from template import template
44

55

66
async def main():

packages/cli/tests/commands/template/fixtures/copy-variations/expected/python-sync/build_dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from e2b import Template, default_build_logger
2-
from .template import template
2+
from template import template
33

44

55
if __name__ == "__main__":

0 commit comments

Comments
 (0)