|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import importlib.util |
| 4 | +import glob |
| 5 | +import os |
| 6 | +import sys |
| 7 | +import subprocess |
| 8 | + |
| 9 | +from setuptools import setup |
| 10 | +from setuptools.command.install import install |
| 11 | +from shutil import copyfile, copytree, rmtree |
| 12 | + |
| 13 | +# A temporary path so we can access above the Python project root and fetch scripts and jars we need |
| 14 | +TEMP_PATH = "deps" |
| 15 | +OAP_HOME = os.path.abspath("../") |
| 16 | + |
| 17 | +# Provide guidance about how to use setup.py |
| 18 | +incorrect_invocation_message = """ |
| 19 | +If you are installing oap_mllib from spark source, you must first build Spark and |
| 20 | +run sdist. |
| 21 | + To build Spark with maven you can run: |
| 22 | + ./build/mvn -DskipTests clean package |
| 23 | + Building the source dist is done in the Python directory: |
| 24 | + cd python |
| 25 | + python setup.py sdist |
| 26 | + pip install dist/*.tar.gz""" |
| 27 | + |
| 28 | +# Figure out is the jar compiled. |
| 29 | +JAR_PATH = os.path.join(OAP_HOME, "mllib-dal/target") |
| 30 | +EXAMPLES_PATH = os.path.join(OAP_HOME, "examples") |
| 31 | + |
| 32 | +JARS_TARGET = os.path.join(TEMP_PATH, "jars") |
| 33 | +EXAMPLES_TARGET = os.path.join(TEMP_PATH, "examples") |
| 34 | + |
| 35 | + |
| 36 | +try: |
| 37 | + copytree(JAR_PATH, JARS_TARGET) |
| 38 | + copytree(EXAMPLES_PATH, EXAMPLES_TARGET) |
| 39 | + |
| 40 | + with open('../README.md') as f: |
| 41 | + long_description = f.read() |
| 42 | + |
| 43 | + VERSION = "1.6.0" |
| 44 | + |
| 45 | + setup( |
| 46 | + name='oap_mllib', |
| 47 | + version=VERSION, |
| 48 | + description='OAP MLlib', |
| 49 | + long_description=long_description, |
| 50 | + long_description_content_type="text/markdown", |
| 51 | + packages=['oap_mllib', |
| 52 | + 'oap_mllib.jars', |
| 53 | + 'oap_mllib.examples'], |
| 54 | + install_requires=[], |
| 55 | + package_dir={ |
| 56 | + 'oap_mllib.jars': 'deps/jars', |
| 57 | + 'oap_mllib.examples': 'deps/examples' |
| 58 | + }, |
| 59 | + package_data={ |
| 60 | + 'oap_mllib.jars': ['*.jar'], |
| 61 | + 'oap_mllib.examples': ['*'], |
| 62 | + }, |
| 63 | + python_requires='>=3.6', |
| 64 | + ) |
| 65 | +finally: |
| 66 | + rmtree(os.path.join(TEMP_PATH, "jars")) |
| 67 | + rmtree(os.path.join(TEMP_PATH, "examples")) |
| 68 | + os.rmdir(TEMP_PATH) |
0 commit comments