Commit 2a1c2ba9 by abergeron Committed by Tianqi Chen

Fix conda package builds (#1445)

parent 1e4ac3cd
......@@ -201,17 +201,13 @@ endif()
# Custom targets
add_custom_target(runtime DEPENDS tvm_runtime)
# Installation rulse
# Installation rules
install(TARGETS tvm DESTINATION lib${LIB_SUFFIX})
install(TARGETS tvm_topi DESTINATION lib${LIB_SUFFIX})
install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX})
if(WIN32)
install(TARGETS nnvm_compiler RUNTIME DESTINATION bin)
install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib)
else()
install(TARGETS nnvm_compiler LIBRARY DESTINATION lib)
endif()
install(TARGETS nnvm_compiler DESTINATION lib${LIB_SUFFIX})
if (INSTALL_DEV)
install(TARGETS tvm DESTINATION lib${LIB_SUFFIX})
install(
DIRECTORY "include/." DESTINATION "include"
FILES_MATCHING
......
python:
- 3.5
- 3.6
- 3.7
\ No newline at end of file
#!/bin/bash
set -e
cd nnvm/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
{% set version = "0.1.dev" %}
{% set version = "0.4.dev" %}
package:
name: nnvm
......@@ -8,24 +8,31 @@ source:
path: ../..
build:
number: 1
number: 0
skip: True # [win]
requirements:
build:
- cmake
- python >=3
- {{ compiler('cxx') }}
host:
- python {{ python }}
- cython
- numpy
- setuptools
- nose
- decorator
- tvm-libs =={{ version }}
run:
- tvm
- topi
- python >=3
- numpy
- tvm =={{ version }}
- topi =={{ version }}
- tvm-libs =={{ version }}
- python
- {{ pin_compatible('numpy') }}
- decorator
test:
imports:
- nnvm
about:
home: https://github.com/dmlc/nnvm
license: Apache2
......
#!/bin/bash
set -e
cd topi/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
{% set version = "0.1.dev" %}
{% set version = "0.4.dev" %}
package:
name: topi
version: {{ version }}
source:
path: ..
path: ../..
build:
number: 0
script: $PYTHON setup.py install
requirements:
build:
- cmake
- python >=3
host:
- python {{ python }}
- numpy
- setuptools
- nose
- decorator
- tvm-libs =={{ version }}
run:
- python >=3
- numpy
- python
- {{ pin_compatible('numpy') }}
- decorator
- tvm-libs =={{ version }}
- tvm =={{ version }}
test:
imports:
- topi
about:
home: https://github.com/dmlc/tvm
......
......@@ -6,23 +6,10 @@ if [ -z "$PREFIX" ]; then
PREFIX="$CONDA_PREFIX"
fi
if [ "$(uname)" = 'Darwin' ]
then
# Without this, Apple's default shipped clang will refuse to see any
# headers like mutex.
export MACOSX_DEPLOYMENT_TARGET=10.9
fi
rm -rf build || true
mkdir -p build
cd build
# Enable static-libstdc++ to make it easier to link this library with
# other C++ compilers
CXXFLAGS=-static-libstdc++ cmake -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} ..
make -j4 VERBOSE=1
make install/fast
cd ..
cd python
$PYTHON setup.py install
cmake -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
make -j2 VERBOSE=1
make install
cd ..
{% set version = "0.4.dev" %}
package:
name: tvm-libs
version: {{ version }}
source:
path: ../..
build:
number: 0
requirements:
host:
# The OS X build will require some manual setup or it will break
# See https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html#macos-sdk
- {{ compiler('cxx') }}
build:
- llvmdev ==6.0.0
- cmake
about:
home: https://github.com/dmlc/tvm
license: Apache2
summary: a low level domain specific language for compiling tensor computation pipelines
\ No newline at end of file
#!/bin/bash
set -e
cd python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
{% set version = "0.1.dev" %}
{% set version = "0.4.dev" %}
package:
name: tvm
......@@ -8,24 +8,27 @@ source:
path: ../..
build:
number: 1
skip: True # [win]
script_env:
- CONDA_CUDA_HOME
number: 0
requirements:
build:
- llvmdev ==4.0.0
- cmake
- python >=3
- {{ compiler('cxx') }}
host:
- python {{ python }}
- cython
- numpy
- setuptools
- nose
- decorator
- tvm-libs =={{ version }}
run:
- python >=3
- numpy
- python
- {{ pin_compatible('numpy') }}
- decorator
- tvm-libs =={{ version }}
test:
imports:
- tvm
about:
home: https://github.com/dmlc/tvm
......
......@@ -28,10 +28,12 @@ def find_lib_path():
else:
lib_name = "nnvm_compiler" if sys.platform.startswith('win32') else "libnnvm_compiler"
api_path = os.path.join(base_path, '../../lib/')
cmake_build_path = os.path.join(base_path, '../../../build/Release/')
cmake_build_path = os.path.join(base_path, '../../../build/')
dll_path = [base_path, api_path, cmake_build_path]
api_path = os.path.join(base_path, '..', '..', 'lib')
cmake_build_path_win = os.path.join(base_path, '..', '..', '..', 'build', 'Release')
cmake_build_path = os.path.join(base_path, '..', '..', '..', 'build')
install_path = os.path.join(base_path, '..', '..', '..')
dll_path = [base_path, api_path, cmake_build_path_win, cmake_build_path,
install_path]
if sys.platform.startswith('linux') and os.environ.get('LD_LIBRARY_PATH', None):
dll_path.extend([p.strip() for p in os.environ['LD_LIBRARY_PATH'].split(":")])
......@@ -43,11 +45,12 @@ def find_lib_path():
if sys.platform.startswith('win32'):
vs_configuration = 'Release'
if platform.architecture()[0] == '64bit':
dll_path.append(os.path.join(base_path, '../../../build', vs_configuration))
dll_path.append(os.path.join(base_path, '../../../windows/x64', vs_configuration))
dll_path.append(os.path.join(base_path, '..', '..', '..', 'build', vs_configuration))
dll_path.append(os.path.join(base_path, '..', '..', '..', 'windows', 'x64',
vs_configuration))
else:
dll_path.append(os.path.join(base_path, '../../../build', vs_configuration))
dll_path.append(os.path.join(base_path, '../../../windows', vs_configuration))
dll_path.append(os.path.join(base_path, '..', '..', '..', 'build', vs_configuration))
dll_path.append(os.path.join(base_path, '..', '..', '..', 'windows', vs_configuration))
dll_path = [os.path.join(p, '%s.dll' % lib_name) for p in dll_path]
elif sys.platform.startswith('darwin'):
dll_path = [os.path.join(p, '%s.dylib' % lib_name) for p in dll_path]
......
......@@ -37,11 +37,18 @@ 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)
LIB_PATH = libinfo['find_lib_path']()
_, LIB_NAME = os.path.split(LIB_PATH[0])
__version__ = libinfo['__version__']
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
rpath = os.path.relpath(LIB_PATH[0], curr_path)
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 = {}
setup(name='nnvm',
version=__version__,
......@@ -52,6 +59,4 @@ setup(name='nnvm',
],
packages=find_packages(),
url='https://github.com/dmlc/nnvm',
include_package_data=True,
data_files=[('nnvm', [rpath])])
**setup_kwargs)
#!/bin/bash
set -e
# See Note [CUDA_TOOLKIT_ROOT_DIR versus CUDA_BIN_PATH]
if [ -z "$CONDA_CUDA_HOME" ]; then
CUDA_ARGS=""
else
# See Note [Bash argument quoting]
CUDA_ARGS="-DCUDA_TOOLKIT_ROOT_DIR=$(printf %q "$CONDA_CUDA_HOME")"
fi
if [ -z "$PREFIX" ]; then
PREFIX="$CONDA_PREFIX"
fi
if [ "$(uname)" = 'Darwin' ]
then
# Without this, Apple's default shipped clang will refuse to see any
# headers like mutex.
export MACOSX_DEPLOYMENT_TARGET=10.9
fi
rm -rf build || true
mkdir -p build
cd build
# Enable static-libstdc++ to make it easier to link this library with
# other C++ compilers
CXXFLAGS=-static-libstdc++ cmake -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DUSE_CUDA=1 -DUSE_LLVM=1 -DINSTALL_DEV=1 $CUDA_ARGS ..
make -j20 VERBOSE=1
make install/fast
cd ..
# Also install the headers for libraries that TVM vendored
mkdir -p "$PREFIX/include"
# TODO: arguably dlpack and dmlc-core should get its own packaging and
# install their headers themselves
cp -R dlpack/include/. "$PREFIX/include"
cp -R dmlc-core/include/. "$PREFIX/include"
# TODO: HalideIR's includes could conflict, but TVM currently assumes they
# are installed here, awfully enough
cp -R HalideIR/src/. "$PREFIX/include"
cd python
$PYTHON setup.py install
cd ..
......@@ -27,14 +27,17 @@ def get_lib_path():
libinfo_py = os.path.join(CURRENT_DIR, './tvm/_ffi/libinfo.py')
libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
lib_path = libinfo['find_lib_path']()
version = libinfo['__version__']
libs = [lib_path[0]]
if libs[0].find("runtime") == -1:
for name in lib_path[1:]:
if name.find("runtime") != -1:
libs.append(name)
break
if not os.getenv('CONDA_BUILD'):
lib_path = libinfo['find_lib_path']()
libs = [lib_path[0]]
if libs[0].find("runtime") == -1:
for name in lib_path[1:]:
if name.find("runtime") != -1:
libs.append(name)
break
else:
libs = None
return libs, version
LIB_LIST, __version__ = get_lib_path()
......@@ -89,23 +92,33 @@ class BinaryDistribution(Distribution):
def is_pure(self):
return False
include_libs = False
wheel_include_libs = False
if not os.getenv('CONDA_BUILD'):
if "bdist_wheel" in sys.argv:
wheel_include_libs = True
else:
include_libs = True
setup_kwargs = {}
# For bdist_wheel only
if "bdist_wheel" in sys.argv:
with open("MANIFEST.in", "w") as fo:
for path in LIB_LIST:
shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm'))
_, libname = os.path.split(path)
fo.write("include tvm/%s\n" % libname)
if wheel_include_libs:
for path in LIB_LIST:
shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm'))
_, libname = os.path.split(path)
fo.write("include tvm/%s\n" % libname)
setup_kwargs = {
"include_package_data": True
}
else:
if include_libs:
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
for i, path in enumerate(LIB_LIST):
LIB_LIST[i] = os.path.relpath(path, curr_path)
setup_kwargs = {
"include_package_data": True,
"data_files": [('tvm', LIB_LIST)]
"package_data": {'tvm': LIB_LIST}
}
setup(name='tvm',
......@@ -122,8 +135,9 @@ setup(name='tvm',
ext_modules=config_cython(),
**setup_kwargs)
# Wheel cleanup
if "bdist_wheel" in sys.argv:
if wheel_include_libs:
# Wheel cleanup
os.remove("MANIFEST.in")
for path in LIB_LIST:
_, libname = os.path.split(path)
......
......@@ -40,11 +40,11 @@ def find_lib_path(name=None, search_path=None, optional=False):
dll_path.extend([p.strip() for p in os.environ['DYLD_LIBRARY_PATH'].split(":")])
# Pip lib directory
dll_path.append(os.path.join(ffi_dir, "../"))
dll_path.append(os.path.join(ffi_dir, ".."))
# Default cmake build directory
dll_path.append(os.path.join(source_dir, "build"))
dll_path.append(os.path.join(source_dir, "build", "Release"))
# Default mkae build directory
# Default make build directory
dll_path.append(os.path.join(source_dir, "lib"))
dll_path.append(install_lib_dir)
......
......@@ -29,25 +29,31 @@ def get_lib_path():
libinfo_py = os.path.join(CURRENT_DIR, '../../python/tvm/_ffi/libinfo.py')
libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
lib_path = libinfo['find_lib_path'](get_lib_names())
version = libinfo['__version__']
libs = [lib_path[0]]
if libs[0].find("runtime") == -1:
for name in lib_path[1:]:
if name.find("runtime") != -1:
libs.append(name)
break
if not os.getenv('CONDA_BUILD'):
lib_path = libinfo['find_lib_path'](get_lib_names())
libs = [lib_path[0]]
if libs[0].find("runtime") == -1:
for name in lib_path[1:]:
if name.find("runtime") != -1:
libs.append(name)
break
else:
libs = None
return libs, version
LIB_LIST, __version__ = get_lib_path()
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
for i, path in enumerate(LIB_LIST):
LIB_LIST[i] = os.path.relpath(path, curr_path)
setup_kwargs = {
"include_package_data": True,
"data_files": [('topi', LIB_LIST)]
}
if not os.getenv('CONDA_BUILD'):
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
for i, path in enumerate(LIB_LIST):
LIB_LIST[i] = os.path.relpath(path, curr_path)
setup_kwargs = {
"include_package_data": True,
"data_files": [('topi', LIB_LIST)]
}
else:
setup_kwargs = {}
setup(name='topi',
version=__version__,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment