Skip to content

Commit 422ebaf

Browse files
author
Jonas Thiem
committed
Fix handling of file paths in module dependencies
1 parent 8e11634 commit 422ebaf

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pythonforandroid/build.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import re
1010
import sh
11+
import subprocess
1112

1213
from pythonforandroid.util import (ensure_dir, current_directory)
1314
from pythonforandroid.logger import (info, warning, error, info_notify,
@@ -559,6 +560,30 @@ def has_lib(self, arch, lib):
559560
return exists(join(self.get_libs_dir(arch), lib))
560561

561562
def has_package(self, name, arch=None):
563+
# If this is a file path, it'll need special handling:
564+
if (name.find("/") >= 0 or name.find("\\") >= 0) and \
565+
name.find("://") < 0: # (:// would indicate an url)
566+
if not os.path.exists(name):
567+
# Non-existing dir, cannot look this up.
568+
return False
569+
if os.path.exists(os.path.join(name, "setup.py")):
570+
# Get name from setup.py:
571+
name = subprocess.check_output([
572+
sys.executable, "setup.py", "--name"],
573+
cwd=name)
574+
try:
575+
name = name.decode('utf-8', 'replace')
576+
except AttributeError:
577+
pass
578+
name = name.strip()
579+
if len(name) == 0:
580+
# Failed to look up any meaningful name.
581+
return False
582+
else:
583+
# A folder with whatever, cannot look this up.
584+
return False
585+
586+
# Try to look up recipe by name:
562587
try:
563588
recipe = Recipe.get_recipe(name, self)
564589
except IOError:

0 commit comments

Comments
 (0)