Initialize the base Python container Workdir is set to the module's source directory.
()
| 261 | // |
| 262 | // Workdir is set to the module's source directory. |
| 263 | func (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 | |
| 296 | func (m *PythonSdk) uv() dagger.WithContainerFunc { |
| 297 | uvImage := m.getImage(UvImageName) |
no test coverage detected