From f9251475eff56a44388ddc2d492fa3e759c605b1 Mon Sep 17 00:00:00 2001
From: Nehal J Wani <nehaljw.kkd1@gmail.com>
Date: Wed, 4 Apr 2018 12:57:03 +0000
Subject: [PATCH 2/2] conda: unbundle libmxnet DSO

---
 python/mxnet/libinfo.py | 2 ++
 python/setup.py         | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/python/mxnet/libinfo.py b/python/mxnet/libinfo.py
index ff795f9..27779e6 100644
--- a/python/mxnet/libinfo.py
+++ b/python/mxnet/libinfo.py
@@ -19,6 +19,7 @@
 """Information about mxnet."""
 from __future__ import absolute_import
 import os
+import sys
 import platform
 import logging
 
@@ -50,6 +51,7 @@ def find_lib_path():
     dll_path = [curr_path, api_path, cmake_build_path]
     if os.name == 'nt':
         dll_path.append(os.path.join(curr_path, '../../build'))
+        dll_path.append(os.path.join(sys.prefix, 'Library', 'bin'))
         vs_configuration = 'Release'
         if platform.architecture()[0] == '64bit':
             dll_path.append(os.path.join(curr_path, '../../build', vs_configuration))
diff --git a/python/setup.py b/python/setup.py
index 3f365dd..c93416c 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -48,6 +48,13 @@ exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinf
 LIB_PATH = libinfo['find_lib_path']()
 __version__ = libinfo['__version__']
 
+if os.getenv('CONDA_BUILD'):
+   print("Conda-build detected, not installing libmxnet DSO")
+   data_files=('mxnet', [])
+else:
+   print("Install libmxnet from: %s" % LIB_PATH)
+   data_files=('mxnet', LIB_PATH)
+
 sys.path.insert(0, CURRENT_DIR)
 
 # Try to generate auto-complete code
@@ -111,7 +118,7 @@ setup(name='mxnet',
       version=__version__,
       description=open(os.path.join(CURRENT_DIR, 'README.md')).read(),
       packages=find_packages(),
-      data_files=[('mxnet', [LIB_PATH[0]])],
+      data_files=[data_files],
       url='https://github.com/apache/incubator-mxnet',
       ext_modules=config_cython(),
       classifiers=[
-- 
2.7.4

