Commit 2a1c2ba9 by abergeron Committed by Tianqi Chen

Fix conda package builds (#1445)

parent 1e4ac3cd
...@@ -201,17 +201,13 @@ endif() ...@@ -201,17 +201,13 @@ endif()
# Custom targets # Custom targets
add_custom_target(runtime DEPENDS tvm_runtime) 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}) install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX})
if(WIN32) install(TARGETS nnvm_compiler DESTINATION lib${LIB_SUFFIX})
install(TARGETS nnvm_compiler RUNTIME DESTINATION bin)
install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib)
else()
install(TARGETS nnvm_compiler LIBRARY DESTINATION lib)
endif()
if (INSTALL_DEV) if (INSTALL_DEV)
install(TARGETS tvm DESTINATION lib${LIB_SUFFIX})
install( install(
DIRECTORY "include/." DESTINATION "include" DIRECTORY "include/." DESTINATION "include"
FILES_MATCHING 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: package:
name: nnvm name: nnvm
...@@ -8,24 +8,31 @@ source: ...@@ -8,24 +8,31 @@ source:
path: ../.. path: ../..
build: build:
number: 1 number: 0
skip: True # [win] skip: True # [win]
requirements: requirements:
build: build:
- cmake - {{ compiler('cxx') }}
- python >=3 host:
- python {{ python }}
- cython
- numpy - numpy
- setuptools - setuptools
- nose
- decorator - decorator
- tvm-libs =={{ version }}
run: run:
- tvm - tvm =={{ version }}
- topi - topi =={{ version }}
- python >=3 - tvm-libs =={{ version }}
- numpy - python
- {{ pin_compatible('numpy') }}
- decorator - decorator
test:
imports:
- nnvm
about: about:
home: https://github.com/dmlc/nnvm home: https://github.com/dmlc/nnvm
license: Apache2 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: package:
name: topi name: topi
version: {{ version }} version: {{ version }}
source: source:
path: .. path: ../..
build: build:
number: 0 number: 0
script: $PYTHON setup.py install
requirements: requirements:
build: host:
- cmake - python {{ python }}
- python >=3
- numpy - numpy
- setuptools - setuptools
- nose
- decorator - decorator
- tvm-libs =={{ version }}
run: run:
- python >=3 - python
- numpy - {{ pin_compatible('numpy') }}
- decorator - decorator
- tvm-libs =={{ version }}
- tvm =={{ version }}
test:
imports:
- topi
about: about:
home: https://github.com/dmlc/tvm home: https://github.com/dmlc/tvm
......
...@@ -6,23 +6,10 @@ if [ -z "$PREFIX" ]; then ...@@ -6,23 +6,10 @@ if [ -z "$PREFIX" ]; then
PREFIX="$CONDA_PREFIX" PREFIX="$CONDA_PREFIX"
fi 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 rm -rf build || true
mkdir -p build mkdir -p build
cd build cd build
# Enable static-libstdc++ to make it easier to link this library with cmake -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
# other C++ compilers make -j2 VERBOSE=1
CXXFLAGS=-static-libstdc++ cmake -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} .. make install
make -j4 VERBOSE=1
make install/fast
cd ..
cd python
$PYTHON setup.py install
cd .. 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: package:
name: tvm name: tvm
...@@ -8,24 +8,27 @@ source: ...@@ -8,24 +8,27 @@ source:
path: ../.. path: ../..
build: build:
number: 1 number: 0
skip: True # [win]
script_env:
- CONDA_CUDA_HOME
requirements: requirements:
build: build:
- llvmdev ==4.0.0 - {{ compiler('cxx') }}
- cmake host:
- python >=3 - python {{ python }}
- cython
- numpy - numpy
- setuptools - setuptools
- nose
- decorator - decorator
- tvm-libs =={{ version }}
run: run:
- python >=3 - python
- numpy - {{ pin_compatible('numpy') }}
- decorator - decorator
- tvm-libs =={{ version }}
test:
imports:
- tvm
about: about:
home: https://github.com/dmlc/tvm home: https://github.com/dmlc/tvm
......
...@@ -28,10 +28,12 @@ def find_lib_path(): ...@@ -28,10 +28,12 @@ def find_lib_path():
else: else:
lib_name = "nnvm_compiler" if sys.platform.startswith('win32') else "libnnvm_compiler" lib_name = "nnvm_compiler" if sys.platform.startswith('win32') else "libnnvm_compiler"
api_path = os.path.join(base_path, '../../lib/') api_path = os.path.join(base_path, '..', '..', 'lib')
cmake_build_path = os.path.join(base_path, '../../../build/Release/') cmake_build_path_win = os.path.join(base_path, '..', '..', '..', 'build', 'Release')
cmake_build_path = os.path.join(base_path, '../../../build/') cmake_build_path = os.path.join(base_path, '..', '..', '..', 'build')
dll_path = [base_path, api_path, cmake_build_path] 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): 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(":")]) dll_path.extend([p.strip() for p in os.environ['LD_LIBRARY_PATH'].split(":")])
...@@ -43,11 +45,12 @@ def find_lib_path(): ...@@ -43,11 +45,12 @@ def find_lib_path():
if sys.platform.startswith('win32'): if sys.platform.startswith('win32'):
vs_configuration = 'Release' vs_configuration = 'Release'
if platform.architecture()[0] == '64bit': if platform.architecture()[0] == '64bit':
dll_path.append(os.path.join(base_path, '../../../build', 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)) dll_path.append(os.path.join(base_path, '..', '..', '..', 'windows', 'x64',
vs_configuration))
else: else:
dll_path.append(os.path.join(base_path, '../../../build', 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.append(os.path.join(base_path, '..', '..', '..', 'windows', vs_configuration))
dll_path = [os.path.join(p, '%s.dll' % lib_name) for p in dll_path] dll_path = [os.path.join(p, '%s.dll' % lib_name) for p in dll_path]
elif sys.platform.startswith('darwin'): elif sys.platform.startswith('darwin'):
dll_path = [os.path.join(p, '%s.dylib' % lib_name) for p in dll_path] 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') ...@@ -37,11 +37,18 @@ libinfo_py = os.path.join(CURRENT_DIR, './nnvm/libinfo.py')
libinfo = {'__file__': libinfo_py} libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) 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__'] __version__ = libinfo['__version__']
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) if not os.getenv('CONDA_BUILD'):
rpath = os.path.relpath(LIB_PATH[0], curr_path) 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', setup(name='nnvm',
version=__version__, version=__version__,
...@@ -52,6 +59,4 @@ setup(name='nnvm', ...@@ -52,6 +59,4 @@ setup(name='nnvm',
], ],
packages=find_packages(), packages=find_packages(),
url='https://github.com/dmlc/nnvm', url='https://github.com/dmlc/nnvm',
include_package_data=True, **setup_kwargs)
data_files=[('nnvm', [rpath])])
#!/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(): ...@@ -27,14 +27,17 @@ def get_lib_path():
libinfo_py = os.path.join(CURRENT_DIR, './tvm/_ffi/libinfo.py') libinfo_py = os.path.join(CURRENT_DIR, './tvm/_ffi/libinfo.py')
libinfo = {'__file__': libinfo_py} libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
lib_path = libinfo['find_lib_path']()
version = libinfo['__version__'] version = libinfo['__version__']
if not os.getenv('CONDA_BUILD'):
lib_path = libinfo['find_lib_path']()
libs = [lib_path[0]] libs = [lib_path[0]]
if libs[0].find("runtime") == -1: if libs[0].find("runtime") == -1:
for name in lib_path[1:]: for name in lib_path[1:]:
if name.find("runtime") != -1: if name.find("runtime") != -1:
libs.append(name) libs.append(name)
break break
else:
libs = None
return libs, version return libs, version
LIB_LIST, __version__ = get_lib_path() LIB_LIST, __version__ = get_lib_path()
...@@ -89,9 +92,18 @@ class BinaryDistribution(Distribution): ...@@ -89,9 +92,18 @@ class BinaryDistribution(Distribution):
def is_pure(self): def is_pure(self):
return False 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 # For bdist_wheel only
if "bdist_wheel" in sys.argv: if wheel_include_libs:
with open("MANIFEST.in", "w") as fo:
for path in LIB_LIST: for path in LIB_LIST:
shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm')) shutil.copy(path, os.path.join(CURRENT_DIR, 'tvm'))
_, libname = os.path.split(path) _, libname = os.path.split(path)
...@@ -99,13 +111,14 @@ if "bdist_wheel" in sys.argv: ...@@ -99,13 +111,14 @@ if "bdist_wheel" in sys.argv:
setup_kwargs = { setup_kwargs = {
"include_package_data": True "include_package_data": True
} }
else:
if include_libs:
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
for i, path in enumerate(LIB_LIST): for i, path in enumerate(LIB_LIST):
LIB_LIST[i] = os.path.relpath(path, curr_path) LIB_LIST[i] = os.path.relpath(path, curr_path)
setup_kwargs = { setup_kwargs = {
"include_package_data": True, "include_package_data": True,
"data_files": [('tvm', LIB_LIST)] "package_data": {'tvm': LIB_LIST}
} }
setup(name='tvm', setup(name='tvm',
...@@ -122,8 +135,9 @@ setup(name='tvm', ...@@ -122,8 +135,9 @@ setup(name='tvm',
ext_modules=config_cython(), ext_modules=config_cython(),
**setup_kwargs) **setup_kwargs)
# Wheel cleanup
if "bdist_wheel" in sys.argv: if wheel_include_libs:
# Wheel cleanup
os.remove("MANIFEST.in") os.remove("MANIFEST.in")
for path in LIB_LIST: for path in LIB_LIST:
_, libname = os.path.split(path) _, libname = os.path.split(path)
......
...@@ -40,11 +40,11 @@ def find_lib_path(name=None, search_path=None, optional=False): ...@@ -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(":")]) dll_path.extend([p.strip() for p in os.environ['DYLD_LIBRARY_PATH'].split(":")])
# Pip lib directory # Pip lib directory
dll_path.append(os.path.join(ffi_dir, "../")) dll_path.append(os.path.join(ffi_dir, ".."))
# Default cmake build directory # Default cmake build directory
dll_path.append(os.path.join(source_dir, "build")) dll_path.append(os.path.join(source_dir, "build"))
dll_path.append(os.path.join(source_dir, "build", "Release")) 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(os.path.join(source_dir, "lib"))
dll_path.append(install_lib_dir) dll_path.append(install_lib_dir)
......
...@@ -29,25 +29,31 @@ def get_lib_path(): ...@@ -29,25 +29,31 @@ def get_lib_path():
libinfo_py = os.path.join(CURRENT_DIR, '../../python/tvm/_ffi/libinfo.py') libinfo_py = os.path.join(CURRENT_DIR, '../../python/tvm/_ffi/libinfo.py')
libinfo = {'__file__': libinfo_py} libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo) exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
lib_path = libinfo['find_lib_path'](get_lib_names())
version = libinfo['__version__'] version = libinfo['__version__']
if not os.getenv('CONDA_BUILD'):
lib_path = libinfo['find_lib_path'](get_lib_names())
libs = [lib_path[0]] libs = [lib_path[0]]
if libs[0].find("runtime") == -1: if libs[0].find("runtime") == -1:
for name in lib_path[1:]: for name in lib_path[1:]:
if name.find("runtime") != -1: if name.find("runtime") != -1:
libs.append(name) libs.append(name)
break break
else:
libs = None
return libs, version return libs, version
LIB_LIST, __version__ = get_lib_path() LIB_LIST, __version__ = get_lib_path()
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) if not os.getenv('CONDA_BUILD'):
for i, path in enumerate(LIB_LIST): 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) LIB_LIST[i] = os.path.relpath(path, curr_path)
setup_kwargs = { setup_kwargs = {
"include_package_data": True, "include_package_data": True,
"data_files": [('topi', LIB_LIST)] "data_files": [('topi', LIB_LIST)]
} }
else:
setup_kwargs = {}
setup(name='topi', setup(name='topi',
version=__version__, 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