Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
c6ebb5a1
Commit
c6ebb5a1
authored
7 years ago
by
ziheng
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Python] Dist wheel tools (#348)
parent
fa232720
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/setup.py
+47
-21
47 additions, 21 deletions
python/setup.py
python/tvm/_ffi/libinfo.py
+2
-0
2 additions, 0 deletions
python/tvm/_ffi/libinfo.py
with
49 additions
and
21 deletions
python/setup.py
+
47
−
21
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
'
]()
prin
t
(
LIB_PATH
)
_
,
LIB_NAME
=
os
.
path
.
spli
t
(
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
)
This diff is collapsed.
Click to expand it.
python/tvm/_ffi/libinfo.py
+
2
−
0
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
"
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment