setup.py 1.9 KB
Newer Older
1 2
import os
import sys
3
from setuptools import find_packages
4 5
from distutils.core import setup

6
def config_cython():
7 8 9
    # temporary disable cython for now
    # as NNVM uses local DLL build
    return []
10 11 12 13 14 15 16 17 18
    try:
        from Cython.Build import cythonize
        from distutils.extension import Extension
        if sys.version_info >= (3, 0):
            subdir = "_cy3"
        else:
            subdir = "_cy2"
        ret = []
        path = "nnvm/cython"
19

20 21 22 23 24 25 26 27 28 29 30 31
        for fn in os.listdir(path):
            if not fn.endswith(".pyx"):
                continue
            ret.append(Extension(
                "nnvm/%s/%s" % (subdir, fn[:-4]),
                ["nnvm/cython/%s" % fn],
                include_dirs=["../include/"],
                language="c++"))
        return cythonize(ret)
    except:
        print("Cython is not installed, will compile without cython module")
        return []
32

33 34 35 36 37 38 39 40
# We can not import `libinfo.py` in setup.py directly since __init__.py
# Will be invoked which introduces dependences
CURRENT_DIR = os.path.dirname(__file__)
libinfo_py = os.path.join(CURRENT_DIR, './nnvm/libinfo.py')
libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)

__version__ = libinfo['__version__']
41 42 43 44 45 46 47 48 49 50 51
if not os.getenv('CONDA_BUILD'):
    LIB_PATH = libinfo['find_lib_path']()
    _, LIB_NAME = os.path.split(LIB_PATH[0])
    curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
    rpath = os.path.relpath(LIB_PATH[0], curr_path)
    setup_kwargs = dict(
        include_package_data=True,
        data_files=[('nnvm', [rpath])]
    )
else:
    setup_kwargs = {}
52 53 54 55 56 57 58 59 60 61

setup(name='nnvm',
      version=__version__,      
      description="NNVM: Open Compiler for AI Frameworks",
      zip_safe=False,
      install_requires=[
        'numpy'
      ],
      packages=find_packages(),
      url='https://github.com/dmlc/nnvm',
62
      **setup_kwargs)