Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"name": "python-sdk",
"engineVersion": "v1.0.0-0",
"engineVersion": "v1.0.0-beta.10",
"sdk": {
"source": "dang"
},
"dependencies": [
{
"name": "polyfill",
"source": "github.com/dagger/polyfill@main",
"pin": "16627066d1852106320bdc0cfa0e5f901efe5970"
}
]
}
}
1 change: 0 additions & 1 deletion dagger.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[["version","1"]]
["","git.head",["https://github.com/dagger/sdk-sdk"],"8c164424b7a8a37b33a77367ef7547490d5b87b5","float"]
["","git.ref",["https://github.com/dagger/polyfill","main"],"ec3ea84a2351b4beb06ecece951f2e5ef66509ff","float"]
2 changes: 1 addition & 1 deletion mod-config.dang
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type ModConfig {
}

let edited = withImage.file(toolPath).contents
polyfill.workspace(ws).fork.withNewFile(pyprojectPath, edited).changes
ws.fork.withNewFile("/" + pyprojectPath, edited).changes
}

"""
Expand Down
6 changes: 3 additions & 3 deletions mod.dang
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ type Mod {
"""
pub generate: Changeset! {
if (skipGenerate) {
polyfill.workspace(ws).fork.changes
ws.fork.changes
} else {
# Stage the local dependency closure so this module's codegen sees
# up-to-date dependency bindings before generating it.
let stagedWs = ws.withChanges(polyfill.workspace(ws).moduleSource("/" + rootPath).core.generateLocalDependencies(ws))
polyfill.workspace(stagedWs).moduleSource("/" + rootPath).generate.changes
let stagedWs = ws.withChanges(ws.moduleSource("/" + rootPath).generateLocalDependencies(ws))
stagedWs.moduleSource("/" + rootPath).generatedContextChangeset
}
}
}
33 changes: 16 additions & 17 deletions python-sdk.dang
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ type PythonSdk {
"""
Return every managed Python SDK module visible from the client's cwd: the
nearest enclosing module plus modules at or below the cwd. Discovery uses the
shared polyfill and intersects its results with the SDK list on the passed
engine's Workspace.findConfigDirs and intersects its results with the SDK list on the passed
workspace.
"""
pub modules(ws: Workspace!): [Mod!]! {
let managed = currentModule.asSDK(workspace: ws).modules.{{path}}
let cwd = normalizePath(ws.cwd)
polyfill.workspace(ws)
ws
.findConfigDirs(moduleConfigFilenames, exclude: ["**/.venv/**", "**/site-packages/**"])
.map { dir => workspacePath(cwd, dir) }
.uniq
Expand Down Expand Up @@ -161,8 +161,8 @@ type PythonSdk {
} else {
let templateSource = configuredTemplate(renderedTemplate(name, selectedTemplate), pythonVersion, useUv, baseImage)

polyfill.workspace(ws).fork
.withDirectory(modPath, templateSource)
ws.fork
.withNewDirectory("/" + modPath, templateSource)
.changes
}
}
Expand Down Expand Up @@ -218,18 +218,17 @@ type PythonSdk {
Modules with the generate skip marker are skipped.
"""
pub generateAll(ws: Workspace!): Changeset! @generate {
let pws = polyfill.workspace(ws)

modules(ws)
.filter { mod => mod.skipGenerate == false }
.reduce(pws.fork) { fork, mod =>
# Stage this module's local dependency closure first (leaf-first, possibly
# across SDKs) so its codegen sees up-to-date dependency bindings. The dep
# codegen is ephemeral: it appears in both the fork's before and after, so
# it cancels in the merge, leaving only each module's own changes.
let stagedWs = ws.withChanges(pws.moduleSource("/" + mod.rootPath).core.generateLocalDependencies(ws))
fork.merge(polyfill.workspace(stagedWs).moduleSource("/" + mod.rootPath).generate)
}
.changes
changeset.withChangesets(
modules(ws)
.filter { mod => mod.skipGenerate == false }
.map { mod =>
# Stage this module's local dependency closure first (leaf-first, possibly
# across SDKs) so its codegen sees up-to-date dependency bindings. The dep
# codegen is ephemeral: taking the changeset against the staged workspace
# cancels it out, leaving only each module's own changes.
let stagedWs = ws.withChanges(ws.moduleSource("/" + mod.rootPath).generateLocalDependencies(ws))
stagedWs.moduleSource("/" + mod.rootPath).generatedContextChangeset
},
)
}
}