Skip to content

Commit 4c37aa3

Browse files
committed
fix custom workdir support regression
1 parent 433c551 commit 4c37aa3

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/main/groovy/ru/vyarus/gradle/plugin/python/cmd/Python.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class Python {
305305
// on win non global python could be called only through cmd
306306
String exec = withCmd ? 'cmd'
307307
// use absolute python path if work dir set (relative will simply not work)
308-
: (wrkDirUsed && customBinaryPath ? CliUtils.canonicalPath(executable) : executable)
308+
: (wrkDirUsed && customBinaryPath ? project.file(executable).canonicalPath : executable)
309309
String[] cmd = withCmd ?
310310
CliUtils.wincmdArgs(executable, project.projectDir, prepareArgs(args), wrkDirUsed)
311311
: prepareArgs(args)

src/main/groovy/ru/vyarus/gradle/plugin/python/util/CliUtils.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ final class CliUtils {
204204
/**
205205
* Format canonical path WITHOUT following symlinks (which {@link File#getCanonicalPath()} do). Used to
206206
* remove redundant ".." parts in path.
207+
* <p>
208+
* Relative path will remain relative!
207209
*
208210
* @param file file or directory path
209211
* @return canonical path

src/test/groovy/ru/vyarus/gradle/plugin/python/multimodule/PythonUsedInSubmoduleKitTest.groovy

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,39 @@ class PythonUsedInSubmoduleKitTest extends AbstractKitTest {
176176
!result.output.contains("${projectName()}${File.separator}.gradle${File.separator}python")
177177
result.output.contains("${projectName()}${File.separator}sub${File.separator}python")
178178
}
179+
180+
def "Check submodule python call with custom work dir"() {
181+
182+
setup:
183+
file('settings.gradle') << ' include "sub"'
184+
file('sub').mkdir()
185+
build """
186+
plugins {
187+
id 'ru.vyarus.use-python' apply false
188+
}
189+
190+
allprojects {
191+
apply plugin: 'ru.vyarus.use-python'
192+
}
193+
194+
subprojects {
195+
python {
196+
pip 'click:6.7'
197+
}
198+
199+
task sample(type: PythonTask) {
200+
command = '-c print(\\'samplee\\')'
201+
workDir = 'src'
202+
}
203+
}
204+
"""
205+
206+
when: "run sub task"
207+
debug()
208+
BuildResult result = run(':sub:sample')
209+
210+
then: "task successful"
211+
result.task(':sub:sample').outcome == TaskOutcome.SUCCESS
212+
result.output.contains('samplee')
213+
}
179214
}

0 commit comments

Comments
 (0)