Skip to content

Commit

Permalink
Fix task inputs which are absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Sep 26, 2022
1 parent 73d79a3 commit 6f486ca
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,17 @@ class PythonPlugin implements Plugin<Project> {

File file
try {
file = new File(baseDir, req)
file = new File(req)
if (! file.isAbsolute()) {
// Passing two absolute paths to the File constructor will simply
// concatenate them rather than returning the second one.
file = new File(baseDir, req)
}
if (! file.exists()) {
file = null
}
} catch (Exception e) {
// In case File() or exists() throws on an invalid filename.
// In case any of the above code throws on an invalid filename.
file = null
}
// Do this outside of the try block to avoid hiding exceptions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'

android {
compileSdkVersion 23
defaultConfig {
applicationId "com.chaquo.python.test"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "0.0.1"
python {
pip {
install new File(projectDir,
"packages/apple-0.0.1-py2.py3-none-any.whl").toString()
}
}
ndk {
abiFilters "x86"
}
}
}
17 changes: 12 additions & 5 deletions product/gradle-plugin/src/test/integration/test_gradle_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def test_download_wheel(self):
["__init__.pxd", "__init__.py", "about.py", "mrmr.pxd", "mrmr.pyx",
"include/murmurhash/MurmurHash2.h", "include/murmurhash/MurmurHash3.h",
"tests/__init__.py", "tests/test_import.py"]] +
["chaquopy_libcxx-10000.dist-info/" + name for name in
["chaquopy_libcxx-11000.dist-info/" + name for name in
["INSTALLER", "LICENSE.TXT", "METADATA"]] +
["murmurhash-0.28.0.dist-info/" + name for name in
["INSTALLER", "LICENSE", "METADATA", "top_level.txt"]])
Expand Down Expand Up @@ -883,10 +883,17 @@ def test_reqs_file_content(self):
run.rerun("PythonReqs/reqs_file_content_3",
requirements=["apple2/__init__.py", "bravo1.py"])

def test_wheel_file(self):
run = self.RunGradle("base", "PythonReqs/wheel_file", requirements=["apple/__init__.py"])
run.apply_layers("PythonReqs/wheel_file_2")
run.rerun(requirements=["apple2/__init__.py"])
def test_wheel_file_relative(self):
run = self.RunGradle("base", "PythonReqs/wheel_file_relative",
"PythonReqs/wheel_file_1",
requirements=["apple/__init__.py"])
run.rerun("PythonReqs/wheel_file_2", requirements=["apple2/__init__.py"])

def test_wheel_file_absolute(self):
run = self.RunGradle("base", "PythonReqs/wheel_file_absolute",
"PythonReqs/wheel_file_1",
requirements=["apple/__init__.py"])
run.rerun("PythonReqs/wheel_file_2", requirements=["apple2/__init__.py"])

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

0 comments on commit 6f486ca

Please sign in to comment.