Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Make no install recommends optional (#983)
Mish Ushakovde2a922aa5f3
diff --git a/.changeset/calm-lions-push.md b/.changeset/calm-lions-push.mdnew file mode 100644index 000000000..d7c235987--- /dev/null+++ b/.changeset/calm-lions-push.md@@ -0,0 +1,6 @@+---+'@e2b/python-sdk': patch+'e2b': patch+---++make --no-install-recommends optional in apt_installdiff --git a/packages/js-sdk/src/template/index.ts b/packages/js-sdk/src/template/index.tsindex 9fdee6150..2f9137787 100644--- a/packages/js-sdk/src/template/index.ts+++ b/packages/js-sdk/src/template/index.ts@@ -466,13 +466,16 @@ export class TemplateBase)}- aptInstall(packages: string | string[]): TemplateBuilder {+ aptInstall(+ packages: string | string[],+ options?: { noInstallRecommends?: boolean }+ ): TemplateBuilder {const packageList = Array.isArray(packages) ? packages : [packages]return this.runInNewStackTraceContext(() =>this.runCmd(['apt-get update',- `DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y --no-install-recommends ${packageList.join(+ `DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y ${options?.noInstallRecommends ? '--no-install-recommends ' : ''}${packageList.join(' ')}`,],diff --git a/packages/js-sdk/src/template/types.ts b/packages/js-sdk/src/template/types.tsindex 3ce05faac..f8bd70b01 100644--- a/packages/js-sdk/src/template/types.ts+++ b/packages/js-sdk/src/template/types.ts@@ -470,9 +470,13 @@ export interface TemplateBuilder {* ```ts* template.aptInstall('vim')* template.aptInstall(['git', 'curl', 'wget'])+ * template.aptInstall(['vim'], { noInstallRecommends: true })* ```*/- aptInstall(packages: string | string[]): TemplateBuilder+ aptInstall(+ packages: string | string[],+ options?: { noInstallRecommends?: boolean }+ ): TemplateBuilder/*** Install MCP servers using mcp-gateway.diff --git a/packages/js-sdk/tests/template/methods/aptInstall.test.ts b/packages/js-sdk/tests/template/methods/aptInstall.test.tsnew file mode 100644index 000000000..76b7a9d3c--- /dev/null+++ b/packages/js-sdk/tests/template/methods/aptInstall.test.ts@@ -0,0 +1,19 @@+import { Template } from '../../../src'+import { buildTemplateTest } from '../../setup'++buildTemplateTest('apt install', async ({ buildTemplate }) => {+ const template = Template().fromImage('ubuntu:24.04').aptInstall(['vim'])++ await buildTemplate(template)+})++buildTemplateTest(+ 'apt install with no install recommends',+ async ({ buildTemplate }) => {+ const template = Template()+ .fromImage('ubuntu:24.04')+ .aptInstall(['vim'], { noInstallRecommends: true })++ await buildTemplate(template)+ }+)diff --git a/packages/js-sdk/tests/template/methods/npmInstall.test.ts b/packages/js-sdk/tests/template/methods/npmInstall.test.tsindex cbebffc0b..c633e818e 100644--- a/packages/js-sdk/tests/template/methods/npmInstall.test.ts+++ b/packages/js-sdk/tests/template/methods/npmInstall.test.ts@@ -1,21 +1,16 @@-import { randomUUID } from 'node:crypto'-import { test } from 'vitest'import { Template } from '../../../src'+import { buildTemplateTest } from '../../setup'-test('npm install', async () => {+buildTemplateTest('npm install', async ({ buildTemplate }) => {const template = Template().fromNodeImage('24').npmInstall(['lodash', 'ms'])- await Template.build(template, {- alias: randomUUID(),- })+ await buildTemplate(template)})-test('npm install global', async () => {+buildTemplateTest('npm install global', async ({ buildTemplate }) => {const template = Template().fromNodeImage('24').npmInstall(['lodash', 'ms'], { g: true })- await Template.build(template, {- alias: randomUUID(),- })+ await buildTemplate(template)})diff --git a/packages/python-sdk/e2b/template/main.py b/packages/python-sdk/e2b/template/main.pyindex 06a478489..1a831ba6f 100644--- a/packages/python-sdk/e2b/template/main.py+++ b/packages/python-sdk/e2b/template/main.py@@ -389,11 +389,14 @@ class TemplateBuilder:lambda: self.run_cmd(" ".join(args), user="root" if g else None))- def apt_install(self, packages: Union[str, List[str]]) -> "TemplateBuilder":+ def apt_install(+ self, packages: Union[str, List[str]], no_install_recommends: bool = False+ ) -> "TemplateBuilder":"""Install system packages using apt-get.:param packages: Package name(s) to install+ :param no_install_recommends: Whether to install recommended packages:return: `TemplateBuilder` class@@ -410,7 +413,7 @@ class TemplateBuilder:lambda: self.run_cmd(["apt-get update",- f"DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y --no-install-recommends {' '.join(packages)}",+ f"DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y {'--no-install-recommends ' if no_install_recommends else ''}{' '.join(packages)}",],user="root",)diff --git a/packages/python-sdk/tests/async/template_async/methods/test_apt_install.py b/packages/python-sdk/tests/async/template_async/methods/test_apt_install.pynew file mode 100644index 000000000..e2d649c4c--- /dev/null+++ b/packages/python-sdk/tests/async/template_async/methods/test_apt_install.py@@ -0,0 +1,20 @@+import pytest++from e2b import AsyncTemplate++[email protected]_debug()+async def test_apt_install(async_build):+ template = AsyncTemplate().from_image("ubuntu:24.04").apt_install(["vim"])++ await async_build(template)++[email protected]_debug()+async def test_apt_install_no_install_recommends(async_build):+ template = (+ AsyncTemplate()+ .from_image("ubuntu:24.04")+ .apt_install(["vim"], no_install_recommends=True)+ )+ await async_build(template)diff --git a/packages/python-sdk/tests/sync/template_sync/methods/test_apt_install.py b/packages/python-sdk/tests/sync/template_sync/methods/test_apt_install.pynew file mode 100644index 000000000..5db4e7cbf--- /dev/null+++ b/packages/python-sdk/tests/sync/template_sync/methods/test_apt_install.py@@ -0,0 +1,21 @@+import pytest++from e2b import Template++[email protected]_debug()+def test_apt_install(build):+ template = Template().from_image("ubuntu:24.04").apt_install(["vim"])++ build(template)++[email protected]_debug()+def test_apt_install_no_install_recommends(build):+ template = (+ Template()+ .from_image("ubuntu:24.04")+ .apt_install(["vim"], no_install_recommends=True)+ )++ build(template)