setup.py 3.4 KB
Newer Older
T
tangwei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#   Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
T
for whl  
tangwei 已提交
14
"""
15
setup for paddle-rec.
T
for whl  
tangwei 已提交
16
"""
T
tangwei 已提交
17

T
tangwei 已提交
18
import os
T
tangwei 已提交
19

T
tangwei 已提交
20
from setuptools import setup, find_packages
T
tangwei 已提交
21
import shutil
T
tangwei 已提交
22 23
import tempfile

T
tangwei 已提交
24
requires = ["paddlepaddle == 1.7.2", "pyyaml >= 5.1.1"]
T
for whl  
tangwei 已提交
25 26

about = {}
27
about["__title__"] = "paddle-rec"
T
for whl  
tangwei 已提交
28
about["__version__"] = "0.0.2"
29 30 31 32
about["__description__"] = "paddle-rec"
about["__author__"] = "paddle-dev"
about["__author_email__"] = "paddle-dev@baidu.com"
about["__url__"] = "https://github.com/PaddlePaddle/PaddleRec"
T
tangwei12 已提交
33

T
for mat  
tangwei 已提交
34
readme = ""
T
for whl  
tangwei 已提交
35

T
tangwei 已提交
36 37 38 39 40 41 42 43 44

def run_cmd(command):
    assert command is not None and isinstance(command, str)
    return os.popen(command).read().strip()


def build(dirname):
    package_dir = os.path.dirname(os.path.abspath(__file__))
    run_cmd("cp -r {}/* {}".format(package_dir, dirname))
45
    run_cmd("mkdir {}".format(os.path.join(dirname, "paddlerec")))
T
tangwei 已提交
46 47 48 49 50 51 52 53 54 55 56 57
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "core"), os.path.join(dirname, "paddlerec")))
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "doc"), os.path.join(dirname, "paddlerec")))
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "models"), os.path.join(dirname, "paddlerec")))
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "tests"), os.path.join(dirname, "paddlerec")))
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "tools"), os.path.join(dirname, "paddlerec")))
    run_cmd("mv {} {}".format(
        os.path.join(dirname, "*.py"), os.path.join(dirname, "paddlerec")))
T
tangwei 已提交
58

59
    packages = find_packages(dirname, include=('paddlerec.*'))
T
tangwei 已提交
60
    package_dir = {'': dirname}
61
    package_data = {}
T
tangwei 已提交
62

T
tangwei 已提交
63 64
    models_copy = [
        'data/*.txt', 'data/*/*.txt', '*.yaml', '*.sh', 'tree/*.npy',
65 66
        'tree/*.txt', 'data/sample_data/*', 'data/sample_data/train/*',
        'data/sample_data/infer/*'
T
tangwei 已提交
67
    ]
X
xujiaqi01 已提交
68

T
tangwei 已提交
69
    engine_copy = ['*/*.sh']
70
    for package in packages:
71
        if package.startswith("paddlerec.models."):
T
tangwei 已提交
72
            package_data[package] = models_copy
73
        if package.startswith("paddlerec.core.engine"):
T
tangwei 已提交
74
            package_data[package] = engine_copy
T
tangwei 已提交
75

T
tangwei 已提交
76 77 78 79 80 81 82 83 84 85
    setup(
        name=about["__title__"],
        version=about["__version__"],
        description=about["__description__"],
        long_description=readme,
        author=about["__author__"],
        author_email=about["__author_email__"],
        url=about["__url__"],
        packages=packages,
        package_dir=package_dir,
T
tangwei 已提交
86
        package_data=package_data,
T
tangwei 已提交
87 88
        python_requires=">=2.7",
        install_requires=requires,
T
tangwei 已提交
89
        zip_safe=False)
T
tangwei 已提交
90 91 92 93 94


dirname = tempfile.mkdtemp()
build(dirname)
shutil.rmtree(dirname)
T
for whl  
tangwei 已提交
95 96 97

print('''
\033[32m
T
tangwei 已提交
98 99
  _   _   _   _   _   _   _   _   _
 / \ / \ / \ / \ / \ / \ / \ / \ / \
100
( P | A | D | D | L | E | - | R | E | C )
T
tangwei 已提交
101
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
T
for whl  
tangwei 已提交
102 103 104
\033[0m
\033[34m
Installation Complete. Congratulations!
105
How to use it ? Please visit our webside: https://github.com/PaddlePaddle/PaddleRec
T
for whl  
tangwei 已提交
106 107
\033[0m
''')