Skip to content

Commit 6f486ca

Browse files
committed
Fix task inputs which are absolute paths
1 parent 73d79a3 commit 6f486ca

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

product/gradle-plugin/src/main/groovy/com/chaquo/python/PythonPlugin.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,17 @@ class PythonPlugin implements Plugin<Project> {
383383

384384
File file
385385
try {
386-
file = new File(baseDir, req)
386+
file = new File(req)
387+
if (! file.isAbsolute()) {
388+
// Passing two absolute paths to the File constructor will simply
389+
// concatenate them rather than returning the second one.
390+
file = new File(baseDir, req)
391+
}
387392
if (! file.exists()) {
388393
file = null
389394
}
390395
} catch (Exception e) {
391-
// In case File() or exists() throws on an invalid filename.
396+
// In case any of the above code throws on an invalid filename.
392397
file = null
393398
}
394399
// Do this outside of the try block to avoid hiding exceptions.
File renamed without changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'com.chaquo.python'
3+
4+
android {
5+
compileSdkVersion 23
6+
defaultConfig {
7+
applicationId "com.chaquo.python.test"
8+
minSdkVersion 21
9+
targetSdkVersion 23
10+
versionCode 1
11+
versionName "0.0.1"
12+
python {
13+
pip {
14+
install new File(projectDir,
15+
"packages/apple-0.0.1-py2.py3-none-any.whl").toString()
16+
}
17+
}
18+
ndk {
19+
abiFilters "x86"
20+
}
21+
}
22+
}
File renamed without changes.

product/gradle-plugin/src/test/integration/test_gradle_plugin.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def test_download_wheel(self):
753753
["__init__.pxd", "__init__.py", "about.py", "mrmr.pxd", "mrmr.pyx",
754754
"include/murmurhash/MurmurHash2.h", "include/murmurhash/MurmurHash3.h",
755755
"tests/__init__.py", "tests/test_import.py"]] +
756-
["chaquopy_libcxx-10000.dist-info/" + name for name in
756+
["chaquopy_libcxx-11000.dist-info/" + name for name in
757757
["INSTALLER", "LICENSE.TXT", "METADATA"]] +
758758
["murmurhash-0.28.0.dist-info/" + name for name in
759759
["INSTALLER", "LICENSE", "METADATA", "top_level.txt"]])
@@ -883,10 +883,17 @@ def test_reqs_file_content(self):
883883
run.rerun("PythonReqs/reqs_file_content_3",
884884
requirements=["apple2/__init__.py", "bravo1.py"])
885885

886-
def test_wheel_file(self):
887-
run = self.RunGradle("base", "PythonReqs/wheel_file", requirements=["apple/__init__.py"])
888-
run.apply_layers("PythonReqs/wheel_file_2")
889-
run.rerun(requirements=["apple2/__init__.py"])
886+
def test_wheel_file_relative(self):
887+
run = self.RunGradle("base", "PythonReqs/wheel_file_relative",
888+
"PythonReqs/wheel_file_1",
889+
requirements=["apple/__init__.py"])
890+
run.rerun("PythonReqs/wheel_file_2", requirements=["apple2/__init__.py"])
891+
892+
def test_wheel_file_absolute(self):
893+
run = self.RunGradle("base", "PythonReqs/wheel_file_absolute",
894+
"PythonReqs/wheel_file_1",
895+
requirements=["apple/__init__.py"])
896+
run.rerun("PythonReqs/wheel_file_2", requirements=["apple2/__init__.py"])
890897

891898
# This wheel has .data subdirectories for each of the possible distutils scheme keys. Only
892899
# purelib and platlib should be included in the APK.

0 commit comments

Comments
 (0)