Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
c6ebb5a1
Commit
c6ebb5a1
authored
Aug 19, 2017
by
ziheng
Committed by
Tianqi Chen
Aug 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Python] Dist wheel tools (#348)
parent
fa232720
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
21 deletions
+49
-21
python/setup.py
+47
-21
python/tvm/_ffi/libinfo.py
+2
-0
No files found.
python/setup.py
View file @
c6ebb5a1
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""Setup tvm package."""
# pylint: disable=invalid-name, exec-used
"""Setup TVM package."""
from
__future__
import
absolute_import
import
os
import
shutil
import
sys
import
setuptools
import
sysconfig
import
platform
from
setuptools
import
find_packages
from
setuptools.dist
import
Distribution
# need to use distutils.core for correct placement of cython dll
if
"--inplace"
in
sys
.
argv
:
...
...
@@ -14,13 +18,15 @@ else:
from
setuptools
import
setup
from
setuptools.extension
import
Extension
# We can not import `mxnet.info.py` in setup.py directly since mxnet/__init__.py
# Will be invoked which introduces dependences
CURRENT_DIR
=
os
.
path
.
dirname
(
__file__
)
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
}
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'
]()
print
(
LIB_PATH
)
_
,
LIB_NAME
=
os
.
path
.
split
(
LIB_PATH
[
0
]
)
__version__
=
libinfo
[
'__version__'
]
def
config_cython
():
...
...
@@ -28,6 +34,11 @@ def config_cython():
if
os
.
name
==
'nt'
:
print
(
"WARNING: Cython is not supported on Windows, will compile without cython module"
)
return
[]
sys_cflags
=
sysconfig
.
get_config_var
(
"CFLAGS"
)
if
"i386"
in
sys_cflags
and
"x86_64"
in
sys_cflags
:
print
(
"WARNING: Cython library may not be compiled correctly with both i386 and x64"
)
return
[]
try
:
from
Cython.Build
import
cythonize
# from setuptools.extension import Extension
...
...
@@ -61,20 +72,35 @@ def config_cython():
print
(
"WARNING: Cython is not installed, will compile without cython module"
)
return
[]
setuptools
.
setup
(
name
=
'tvm'
,
version
=
__version__
,
description
=
'A domain specific language(DSL) for tensor computations.'
,
install_requires
=
[
class
BinaryDistribution
(
Distribution
):
def
has_ext_modules
(
self
):
return
True
def
is_pure
(
self
):
return
False
# For bdist_wheel only
if
"bdist_wheel"
in
sys
.
argv
:
shutil
.
copy
(
LIB_PATH
[
0
],
os
.
path
.
join
(
CURRENT_DIR
,
'tvm'
))
fo
=
open
(
"MANIFEST.in"
,
"w"
)
fo
.
write
(
"include tvm/
%
s
\n
"
%
LIB_NAME
)
fo
.
close
()
setup
(
name
=
'tvm'
,
version
=
__version__
,
description
=
'A domain specific language(DSL) for tensor computations.'
,
zip_safe
=
False
,
install_requires
=
[
'numpy'
,
'decorator'
,
],
zip_safe
=
False
,
packages
=
[
'tvm'
,
'tvm.contrib'
,
'tvm._ffi'
,
'tvm._ffi._ctypes'
,
'tvm._ffi._cy2'
,
'tvm._ffi._cy3'
],
data_files
=
[(
'tvm'
,
[
LIB_PATH
[
0
]])],
url
=
'https://github.com/dmlc/tvm'
,
ext_modules
=
config_cython
())
packages
=
find_packages
(),
include_package_data
=
True
,
distclass
=
BinaryDistribution
,
url
=
'https://github.com/dmlc/tvm'
,
ext_modules
=
config_cython
())
# clean up
if
"bdist_wheel"
in
sys
.
argv
:
os
.
remove
(
"MANIFEST.in"
)
os
.
remove
(
"tvm/
%
s"
%
LIB_NAME
)
python/tvm/_ffi/libinfo.py
View file @
c6ebb5a1
...
...
@@ -39,6 +39,8 @@ def find_lib_path(name=None, search_path=None):
elif
sys
.
platform
.
startswith
(
'darwin'
)
and
os
.
environ
.
get
(
'DYLD_LIBRARY_PATH'
,
None
):
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
,
"../"
))
# Default cmake build directory
dll_path
.
append
(
os
.
path
.
join
(
source_dir
,
"build"
))
dll_path
.
append
(
os
.
path
.
join
(
source_dir
,
"build"
,
"Release"
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment