Skip to content

Commit

Permalink
Merge pull request #1489 from JonasT/fixfilepaths
Browse files Browse the repository at this point in the history
Fix handling of file paths in module dependencies
  • Loading branch information
AndreMiras authored Nov 26, 2018
2 parents 1a222e0 + 422ebaf commit a5c9078
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import re
import sh
import subprocess

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

def has_package(self, name, arch=None):
# If this is a file path, it'll need special handling:
if (name.find("/") >= 0 or name.find("\\") >= 0) and \
name.find("://") < 0: # (:// would indicate an url)
if not os.path.exists(name):
# Non-existing dir, cannot look this up.
return False
if os.path.exists(os.path.join(name, "setup.py")):
# Get name from setup.py:
name = subprocess.check_output([
sys.executable, "setup.py", "--name"],
cwd=name)
try:
name = name.decode('utf-8', 'replace')
except AttributeError:
pass
name = name.strip()
if len(name) == 0:
# Failed to look up any meaningful name.
return False
else:
# A folder with whatever, cannot look this up.
return False

# Try to look up recipe by name:
try:
recipe = Recipe.get_recipe(name, self)
except IOError:
Expand Down

0 comments on commit a5c9078

Please sign in to comment.