Repository: conda/conda-build

Issue:
api inspect_hash_inputs doesn't seem to work with absolute paths
---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-41-4ad67f775ddf> in <module>()
      1 # API could do the same thing:
----> 2 api.inspect_hash_inputs(pkg_file)

/Users/msarahan/code/conda-build/conda_build/api.py in inspect_hash_inputs(packages)
    359     """
    360     from .inspect import get_hash_input
--> 361     return get_hash_input(packages)
    362 
    363 

/Users/msarahan/code/conda-build/conda_build/inspect.py in get_hash_input(packages)
    319         pkgname = os.path.basename(pkg)[:-8]
    320         hash_inputs[pkgname] = {}
--> 321         hash_input = package_has_file(pkg, 'info/hash_input.json')
    322         if hash_input:
    323             hash_inputs[pkgname]['recipe'] = json.loads(hash_input.decode())

/Users/msarahan/code/conda-build/conda_build/utils.py in package_has_file(package_path, file_path)
    667         locks = get_conda_operation_locks()
    668         with try_acquire_locks(locks, timeout=90):
--> 669             with tarfile.open(package_path) as t:
    670                 try:
    671                     # internal paths are always forward slashed on all platforms

/Users/msarahan/miniconda3/lib/python3.6/tarfile.py in open(cls, name, mode, fileobj, bufsize, **kwargs)
   1562                     saved_pos = fileobj.tell()
   1563                 try:
-> 1564                     return func(name, "r", fileobj, **kwargs)
   1565                 except (ReadError, CompressionError):
   1566                     if fileobj is not None:

/Users/msarahan/miniconda3/lib/python3.6/tarfile.py in gzopen(cls, name, mode, fileobj, compresslevel, **kwargs)
   1627 
   1628         try:
-> 1629             fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
   1630         except OSError:
   1631             if fileobj is not None and mode == 'r':

/Users/msarahan/miniconda3/lib/python3.6/gzip.py in __init__(self, filename, mode, compresslevel, fileobj, mtime)
    161             mode += 'b'
    162         if fileobj is None:
--> 163             fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
    164         if filename is None:
    165             filename = getattr(fileobj, 'name', '')

IsADirectoryError: [Errno 21] Is a directory: '/'


Discussion:

Resolving patch:
diff --git a/conda_build/inspect.py b/conda_build/inspect.py
--- a/conda_build/inspect.py
+++ b/conda_build/inspect.py
@@ -22,7 +22,8 @@
 
 from conda_build.os_utils.ldd import get_linkages, get_package_obj_files, get_untracked_obj_files
 from conda_build.os_utils.macho import get_rpaths, human_filetype
-from conda_build.utils import groupby, getter, comma_join, rm_rf, package_has_file, get_logger
+from conda_build.utils import (groupby, getter, comma_join, rm_rf, package_has_file, get_logger,
+                               ensure_list)
 
 
 def which_package(path):
@@ -203,7 +204,7 @@ def inspect_linkages(packages, prefix=sys.prefix, untracked=False,
     if untracked:
         packages.append(untracked_package)
 
-    for pkg in packages:
+    for pkg in ensure_list(packages):
         if pkg == untracked_package:
             dist = untracked_package
         elif pkg not in installed:
@@ -279,7 +280,7 @@ def inspect_objects(packages, prefix=sys.prefix, groupby='package'):
     installed = _installed(prefix)
 
     output_string = ""
-    for pkg in packages:
+    for pkg in ensure_list(packages):
         if pkg == untracked_package:
             dist = untracked_package
         elif pkg not in installed:
@@ -315,7 +316,7 @@ def inspect_objects(packages, prefix=sys.prefix, groupby='package'):
 def get_hash_input(packages):
     log = get_logger(__name__)
     hash_inputs = {}
-    for pkg in packages:
+    for pkg in ensure_list(packages):
         pkgname = os.path.basename(pkg)[:-8]
         hash_inputs[pkgname] = {}
         hash_input = package_has_file(pkg, 'info/hash_input.json')


Test patch: