MCPcopy
hub / github.com/dagger/dagger / WithBase

Method WithBase

sdk/python/runtime/main.go:263–294  ·  view source on GitHub ↗

Initialize the base Python container Workdir is set to the module's source directory.

()

Source from the content-addressed store, hash-verified

261//
262// Workdir is set to the module's source directory.
263func (m *PythonSdk) WithBase() (*PythonSdk, error) {
264 baseAddr := m.getImage(BaseImageName).String()
265
266 // NB: Adding env vars with container images that were pulled allows
267 // modules to reuse them for performance benefits.
268 m.Container = dag.Container().
269 // Base Python
270 From(baseAddr).
271 // This var is informational only, in case it's useful in a module.
272 WithEnvVariable("DAGGER_BASE_IMAGE", baseAddr).
273 WithEnvVariable("PYTHONUNBUFFERED", "1").
274 WithEnvVariable("PIP_DISABLE_PIP_VERSION_CHECK", "1").
275 WithEnvVariable("PIP_ROOT_USER_ACTION", "ignore").
276 // Uv
277 With(m.uv()).
278 WithEnvVariable("UV_SYSTEM_PYTHON", "1").
279 WithEnvVariable("UV_LINK_MODE", "copy").
280 WithEnvVariable("UV_NATIVE_TLS", "1").
281 WithEnvVariable("UV_PROJECT_ENVIRONMENT", "/opt/venv")
282
283 if !m.UseUv() {
284 m.Container = m.Container.WithMountedCache("/root/.cache/pip", dag.CacheVolume("modpython-pip"))
285 }
286 if m.IndexURL() != "" {
287 m.Container = m.Container.WithEnvVariable("UV_INDEX_URL", m.IndexURL())
288 }
289 if m.ExtraIndexURL() != "" {
290 m.Container = m.Container.WithEnvVariable("UV_EXTRA_INDEX_URL", m.ExtraIndexURL())
291 }
292
293 return m, nil
294}
295
296func (m *PythonSdk) uv() dagger.WithContainerFunc {
297 uvImage := m.getImage(UvImageName)

Callers 2

CommonMethod · 0.95
invokeFunction · 0.80

Calls 12

getImageMethod · 0.95
uvMethod · 0.95
UseUvMethod · 0.95
IndexURLMethod · 0.95
ExtraIndexURLMethod · 0.95
StringMethod · 0.65
WithEnvVariableMethod · 0.45
WithMethod · 0.45
FromMethod · 0.45
ContainerMethod · 0.45
WithMountedCacheMethod · 0.45
CacheVolumeMethod · 0.45

Tested by

no test coverage detected