setup.py.in 3.3 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
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'

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
'''
    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,
            'istaged': ISTAGED})

write_version_py(filename='@PADDLE_SOURCE_DIR@/python/paddle/version.py')


Z
zhangjinchao01 已提交
59 60 61 62
packages=['paddle',
          'paddle.proto',
          'paddle.trainer',
          'paddle.trainer_config_helpers',
Q
qiaolongfei 已提交
63
          'paddle.utils',
Y
Yu Yang 已提交
64 65
          'paddle.v2',
          'paddle.v2.dataset',
Y
Yancey1989 已提交
66
          'paddle.v2.reader',
H
Helin Wang 已提交
67
          'paddle.v2.master',
68
          'paddle.v2.plot',
Q
Qiao Longfei 已提交
69 70
          'paddle.v2.fluid',
          'paddle.v2.fluid.proto',
71
          'py_paddle']
Z
zhangjinchao01 已提交
72

73 74
with open('@PADDLE_SOURCE_DIR@/python/requirements.txt') as f:
    setup_requires = f.read().splitlines()
75 76

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

79
# the prefix is sys.prefix which should always be usr
80
paddle_bin_dir = 'opt/paddle/bin'
81 82 83
paddle_bins = ['${PADDLE_BINARY_DIR}/paddle/scripts/paddle_usage',
               '${PADDLE_BINARY_DIR}/paddle/trainer/paddle_trainer',
               '${PADDLE_BINARY_DIR}/paddle/trainer/paddle_merge_model',
84 85
               '${PADDLE_BINARY_DIR}/paddle/pserver/paddle_pserver_main',
               '${PADDLE_BINARY_DIR}/paddle/scripts/paddle']
86

87
paddle_rt_lib_dir = 'lib'
L
Luo Tao 已提交
88 89 90
paddle_rt_libs = ['${WARPCTC_LIBRARIES}']
if '${MKL_SHARED_LIBS}'!= '':
  paddle_rt_libs += '${MKL_SHARED_LIBS}'.split(';')
T
tensor-tang 已提交
91

92
setup(name='paddlepaddle',
Z
zhangjinchao01 已提交
93 94
      version='${PADDLE_VERSION}',
      description='Parallel Distributed Deep Learning',
95
      install_requires=setup_requires,
L
Luo Tao 已提交
96
      packages=packages,
T
typhoonzero 已提交
97
      ext_modules=[Extension('_foo', ['stub.cc'])],
98 99
      package_data={
        'paddle.v2.master': ['libpaddle_master.so'],
Q
Qiao Longfei 已提交
100
        'paddle.v2.fluid': ['core.so'],
101
        'py_paddle':['*.py','_swig_paddle.so']
102
      },
Z
zhangjinchao01 已提交
103
      package_dir={
104
          '': '${CMAKE_CURRENT_SOURCE_DIR}',
Q
Qiao Longfei 已提交
105
          # The paddle.v2.fluid.proto will be generated while compiling.
106
          # So that package points to other directory.
Q
Qiao Longfei 已提交
107
          'paddle.v2.fluid.proto': '${PADDLE_BINARY_DIR}/paddle/framework',
108
          'py_paddle': '${PADDLE_SOURCE_DIR}/paddle/py_paddle'
109
      },
110 111
      scripts=paddle_bins,
      data_files=[(paddle_rt_lib_dir, paddle_rt_libs)]
Z
zhangjinchao01 已提交
112
)