|
8 | 8 | import sys
|
9 | 9 | import re
|
10 | 10 | import sh
|
| 11 | +import subprocess |
11 | 12 |
|
12 | 13 | from pythonforandroid.util import (ensure_dir, current_directory)
|
13 | 14 | from pythonforandroid.logger import (info, warning, error, info_notify,
|
@@ -559,6 +560,30 @@ def has_lib(self, arch, lib):
|
559 | 560 | return exists(join(self.get_libs_dir(arch), lib))
|
560 | 561 |
|
561 | 562 | 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: |
562 | 587 | try:
|
563 | 588 | recipe = Recipe.get_recipe(name, self)
|
564 | 589 | except IOError:
|
|
0 commit comments