setup.py.in 4.0 KB
Newer Older
T
typhoonzero 已提交
1
from setuptools import setup, Distribution, Extension
Y
Yancey 已提交
2
import subprocess
3 4 5
class BinaryDistribution(Distribution):
    def has_ext_modules(foo):
        return True
Z
zhangjinchao01 已提交
6

Y
Yancey 已提交
7
MAJOR   = 0
T
typhoonzero 已提交
8
MINOR   = 11
Y
Yancey 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
PATCH   = 0
RC      = 0
ISTAGED = False



def git_commit():
    try:
        cmd = ['git', 'rev-parse', 'HEAD']
        git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip()
    except:
        git_commit = 'Unknown'
    return git_commit

def write_version_py(filename='paddle/version.py'):
    cnt = '''
# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
#
full_version    = '%(major)d.%(minor)d.%(patch)d'
major           = '%(major)d'
minor           = '%(minor)d'
patch           = '%(patch)d'
rc              = '%(rc)d'
istaged         = %(istaged)s
commit          = '%(commit)s'
L
Luo Tao 已提交
34
with_mkl        = '%(with_mkl)s'
Y
Yancey 已提交
35 36 37 38 39 40 41 42 43 44

def show():
    if istaged:
        print 'full_version:', full_version
        print 'major:', major
        print 'minor:', minor
        print 'patch:', patch
        print 'rc:', rc
    else:
        print 'commit:', commit
L
Luo Tao 已提交
45 46 47

def mkl():
    return with_mkl
Y
Yancey 已提交
48 49 50 51 52 53 54 55 56 57
'''
    commit = git_commit()
    with open(filename, 'w') as f:
        f.write(cnt % {
            'major': MAJOR,
            'minor': MINOR,
            'patch': PATCH,
            'rc': RC,
            'version': '${PADDLE_VERSION}',
            'commit': commit,
L
Luo Tao 已提交
58 59
            'istaged': ISTAGED,
            'with_mkl': '@WITH_MKL@'})
Y
Yancey 已提交
60

61
write_version_py(filename='@PADDLE_BINARY_DIR@/python/paddle/version.py')
Y
Yancey 已提交
62 63


Z
zhangjinchao01 已提交
64
packages=['paddle',
Q
qiaolongfei 已提交
65
          'paddle.utils',
66 67
          'paddle.dataset',
          'paddle.reader',
68 69
          'paddle.fluid',
          'paddle.fluid.proto',
X
Xin Pan 已提交
70
          'paddle.fluid.proto.profiler',
Y
Yancey 已提交
71
          'paddle.fluid.layers',
Q
qiaolongfei 已提交
72 73
          'paddle.fluid.transpiler',
          'paddle.fluid.transpiler.details']
L
Luo Tao 已提交
74

75
if '${WITH_FLUID_ONLY}'== 'OFF':
L
Luo Tao 已提交
76 77 78 79 80 81
    packages+=['paddle.proto',
               'paddle.trainer',
               'paddle.trainer_config_helpers',
               'paddle.v2',
               'paddle.v2.master',
               'paddle.v2.plot',
82 83
               'paddle.v2.reader',
               'paddle.v2.dataset',
L
Luo Tao 已提交
84
               'py_paddle']
Z
zhangjinchao01 已提交
85

86 87
with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f:
    setup_requires = f.read().splitlines()
88 89

if '${CMAKE_SYSTEM_PROCESSOR}' not in ['arm', 'armv7-a', 'aarch64']:
Y
Yancey 已提交
90
    setup_requires+=['opencv-python']
91

92
# the prefix is sys.prefix which should always be usr
L
Luo Tao 已提交
93
paddle_bins = ''
94
if '${WITH_FLUID_ONLY}'== 'OFF':
L
Luo Tao 已提交
95
    paddle_bin_dir = 'opt/paddle/bin'
X
Xin Pan 已提交
96 97
    paddle_bins = ['${PADDLE_BINARY_DIR}/paddle/legacy/trainer/paddle_trainer',
                   '${PADDLE_BINARY_DIR}/paddle/legacy/trainer/paddle_merge_model',
X
Xin Pan 已提交
98
                   '${PADDLE_BINARY_DIR}/paddle/legacy/pserver/paddle_pserver_main',
L
Luo Tao 已提交
99 100 101
                   '${PADDLE_BINARY_DIR}/paddle/scripts/paddle']

package_data={'paddle.fluid': ['core.so']}
102
if '${WITH_FLUID_ONLY}'== 'OFF':
L
Luo Tao 已提交
103 104 105 106
    package_data['paddle.v2.master']=['libpaddle_master.so']
    package_data['py_paddle']=['*.py','_swig_paddle.so']

package_dir={
107
    '': '${PADDLE_BINARY_DIR}/python',
L
Luo Tao 已提交
108 109 110 111
    # The paddle.fluid.proto will be generated while compiling.
    # So that package points to other directory.
    'paddle.fluid.proto.profiler': '${PADDLE_BINARY_DIR}/paddle/fluid/platform',
    'paddle.fluid.proto': '${PADDLE_BINARY_DIR}/paddle/fluid/framework',
Q
qiaolongfei 已提交
112
    'paddle.fluid': '${PADDLE_BINARY_DIR}/python/paddle/fluid',
L
Luo Tao 已提交
113
}
114
if '${WITH_FLUID_ONLY}'== 'OFF':
115
    package_dir['py_paddle']='${PADDLE_BINARY_DIR}/python/py_paddle'
L
Luo Tao 已提交
116
    
117

118
paddle_rt_lib_dir = 'lib'
L
Luo Tao 已提交
119 120 121
paddle_rt_libs = ['${WARPCTC_LIBRARIES}']
if '${MKL_SHARED_LIBS}'!= '':
  paddle_rt_libs += '${MKL_SHARED_LIBS}'.split(';')
T
tensor-tang 已提交
122

T
typhoonzero 已提交
123
setup(name='${PACKAGE_NAME}',
Z
zhangjinchao01 已提交
124 125
      version='${PADDLE_VERSION}',
      description='Parallel Distributed Deep Learning',
126
      install_requires=setup_requires,
L
Luo Tao 已提交
127
      packages=packages,
T
typhoonzero 已提交
128
      ext_modules=[Extension('_foo', ['stub.cc'])],
L
Luo Tao 已提交
129 130
      package_data=package_data,
      package_dir=package_dir,
131 132
      scripts=paddle_bins,
      data_files=[(paddle_rt_lib_dir, paddle_rt_libs)]
Z
zhangjinchao01 已提交
133
)