Repository: conda/conda-build

Issue:
3.17: AttributeError: 'NoneType' object has no attribute 'replace'
Please see here for details: https://github.com/conda-forge/maven-feedstock/pull/7#issuecomment-445413296


Discussion:
Here is the error:

```
File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 1628, in build
    newly_built_packages = bundlers[pkg_type](output_d, m, env, stats)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 954, in bundle_conda
    files = post_process_files(metadata, initial_files)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 818, in post_process_files
    post_build(m, new_files, build_python=python)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/post.py", line 1010, in post_build
    check_overlinking(m, files)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/post.py", line 947, in check_overlinking
    m.config.channel_urls)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/post.py", line 875, in check_overlinking_impl
    build_prefix, build_prefix_substitution)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/post.py", line 597, in _collect_needed_dsos
    envroot=run_prefix)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/os_utils/liefldd.py", line 603, in __call__
    value = self.func(*args, **kw)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/os_utils/liefldd.py", line 632, in get_linkages_memoized
    recurse=recurse, sysroot=sysroot, envroot=envroot, arch=arch)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/os_utils/liefldd.py", line 414, in get_linkages
    sysroot=sysroot, envroot=envroot, arch=arch)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/os_utils/liefldd.py", line 373, in inspect_linkages_lief
    sysroot)
  File "/Users/travis/miniconda3/lib/python3.6/site-packages/conda_build/os_utils/liefldd.py", line 127, in get_rpaths
    rpaths.append(exe_dirname.replace('\\', '/'))
AttributeError: 'NoneType' object has no attribute 'replace'
```

and it happened, trying to build that recipe: https://github.com/conda-forge/maven-feedstock/blob/master/recipe/meta.yaml
This is the same issue reported in the `ptvsd` issue: https://github.com/conda/conda-build/issues/3287#issuecomment-443953991, which @dhirschfeld https://github.com/conda/conda-build/issues/3292#issuecomment-444633764 said he would help track down as well.

Please keep this issue open since PR #3294 did not fix the replace error.
@hadim, 

the current workaround for conda-forge feedstocks is to [pin the CI scripts to use conda-build 3.16](https://github.com/regro-cf-autotick-bot/kubernetes-feedstock/commit/c70ac1f36785002322483a3bf2a801f00bda525f)

Resolving patch:
diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py
--- a/conda_build/os_utils/liefldd.py
+++ b/conda_build/os_utils/liefldd.py
@@ -117,6 +117,11 @@ def get_rpaths(file, exe_dirname, envroot, windows_root=''):
     rpaths = []
     if binary:
         if binary.format == lief.EXE_FORMATS.PE:
+            if not exe_dirname:
+                # log = get_logger(__name__)
+                # log.warn("Windows library file at %s could not be inspected for rpath.  If it's a standalone "
+                #          "thing from a 3rd party, this is safe to ignore." % file)
+                return []
             # To allow the unix-y rpath code to work we consider
             # exes as having rpaths of env + CONDA_WINDOWS_PATHS
             # and consider DLLs as having no rpaths.


Test patch:
diff --git a/tests/test-recipes/dll-package/jansi.dll b/tests/test-recipes/dll-package/jansi.dll
new file mode 100755
Binary files /dev/null and b/tests/test-recipes/dll-package/jansi.dll differ
diff --git a/tests/test-recipes/dll-package/meta.yaml b/tests/test-recipes/dll-package/meta.yaml
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/dll-package/meta.yaml
@@ -0,0 +1,15 @@
+package:
+  name: dll-hello
+  version: 1.0.0
+
+build:
+  number: 0
+  script:
+    - pushd ${RECIPE_DIR}  # [not win]
+    - pushd %RECIPE_DIR%   # [win]
+
+    - cp jansi.dll ${PREFIX}         # [not win]
+    - cp jansi.dll %LIBRARY_PREFIX%  # [win]
+
+about:
+  summary: Tests that standalone dlls can be packaged
diff --git a/tests/test_api_build_dll_package.py b/tests/test_api_build_dll_package.py
new file mode 100644
--- /dev/null
+++ b/tests/test_api_build_dll_package.py
@@ -0,0 +1,20 @@
+import os
+import pytest
+
+from conda_build import api
+
+from .utils import thisdir
+
+@pytest.fixture()
+def recipe():
+    return os.path.join(thisdir, 'test-recipes', 'dll-package')
+
+def test_recipe_build(recipe, testing_config, testing_workdir, monkeypatch):
+    # These variables are defined solely for testing purposes,
+    # so they can be checked within build scripts
+    testing_config.activate = True
+    monkeypatch.setenv("CONDA_TEST_VAR", "conda_test")
+    monkeypatch.setenv("CONDA_TEST_VAR_2", "conda_test_2")
+    api.build(recipe, config=testing_config)
+
+