Skip to content

Fix handling of file paths in module dependencies #1489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Nov 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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