Skip to content

Commit e91a501

Browse files
edmundmillerclaude
andcommitted
feat: Update bash wrapper for unified package activation
Enhances the bash wrapper system to support the new package directive: - BashWrapperBuilder: Adds getPackageActivateSnippet() method that creates package environments using the PackageManager - command-run.txt: Adds {{package_activate}} template variable for package environment activation The new system works alongside existing conda/pixi activation, enabling gradual migration while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Edmund Miller <[email protected]>
1 parent 3fc4c39 commit e91a501

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

modules/nextflow/src/main/groovy/nextflow/executor/BashWrapperBuilder.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class BashWrapperBuilder {
342342
binding.conda_activate = getCondaActivateSnippet()
343343
binding.spack_activate = getSpackActivateSnippet()
344344
binding.pixi_activate = getPixiActivateSnippet()
345+
binding.package_activate = getPackageActivateSnippet()
345346

346347
/*
347348
* add the task environment
@@ -584,6 +585,29 @@ class BashWrapperBuilder {
584585
return result
585586
}
586587

588+
private String getPackageActivateSnippet() {
589+
import nextflow.packages.PackageManager
590+
import nextflow.Global
591+
592+
if (!packageSpec || !PackageManager.isEnabled(Global.session))
593+
return null
594+
595+
try {
596+
def packageManager = new PackageManager(Global.session)
597+
def envPath = packageManager.createEnvironment(packageSpec)
598+
def activationScript = packageManager.getActivationScript(packageSpec, envPath)
599+
600+
return """\
601+
# ${packageSpec.provider} environment
602+
${activationScript}
603+
""".stripIndent()
604+
}
605+
catch (Exception e) {
606+
log.warn "Failed to create package environment: ${e.message}"
607+
return null
608+
}
609+
}
610+
587611
protected String getTraceCommand(String interpreter) {
588612
String result = "${interpreter} ${fileStr(scriptFile)}"
589613
if( input != null )

modules/nextflow/src/main/resources/nextflow/executor/command-run.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ nxf_main() {
163163
{{conda_activate}}
164164
{{spack_activate}}
165165
{{pixi_activate}}
166+
{{package_activate}}
166167
set -u
167168
{{task_env}}
168169
{{secrets_env}}

0 commit comments

Comments
 (0)