2016-12-11 12:25:31 -08:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
2016-11-12 19:37:20 -08:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-05-27 21:35:48 -07:00
|
|
|
import os
|
2018-11-05 05:53:55 +08:00
|
|
|
import re
|
2017-05-27 21:35:48 -07:00
|
|
|
import shutil
|
2016-10-31 17:08:03 -07:00
|
|
|
import subprocess
|
2017-07-31 21:04:15 -07:00
|
|
|
import sys
|
2016-02-22 17:35:03 -08:00
|
|
|
|
2017-05-27 21:35:48 -07:00
|
|
|
from setuptools import setup, find_packages, Distribution
|
|
|
|
import setuptools.command.build_ext as _build_ext
|
2016-02-07 15:50:02 -08:00
|
|
|
|
2017-08-07 21:17:28 -07:00
|
|
|
# Ideally, we could include these files by putting them in a
|
|
|
|
# MANIFEST.in or using the package_data argument to setup, but the
|
|
|
|
# MANIFEST.in gets applied at the very beginning when setup.py runs
|
|
|
|
# before these files have been created, so we have to move the files
|
|
|
|
# manually.
|
2018-06-02 07:28:27 +08:00
|
|
|
|
2019-04-02 22:17:33 -07:00
|
|
|
# NOTE: The lists below must be kept in sync with ray/BUILD.bazel.
|
2018-06-02 07:28:27 +08:00
|
|
|
|
2017-08-07 21:17:28 -07:00
|
|
|
ray_files = [
|
2018-10-26 13:36:58 -07:00
|
|
|
"ray/core/src/ray/thirdparty/redis/src/redis-server",
|
|
|
|
"ray/core/src/ray/gcs/redis_module/libray_redis_module.so",
|
2019-01-25 01:17:14 +08:00
|
|
|
"ray/core/src/plasma/plasma_store_server", "ray/_raylet.so",
|
2018-04-11 10:11:35 -07:00
|
|
|
"ray/core/src/ray/raylet/raylet_monitor", "ray/core/src/ray/raylet/raylet",
|
2019-03-07 23:15:11 -08:00
|
|
|
"ray/dashboard/dashboard.py", "ray/dashboard/index.html",
|
|
|
|
"ray/dashboard/res/main.css", "ray/dashboard/res/main.js"
|
2017-08-07 21:17:28 -07:00
|
|
|
]
|
2017-07-31 21:04:15 -07:00
|
|
|
|
2019-07-08 22:41:37 +08:00
|
|
|
# These are the directories where automatically generated Python protobuf
|
2018-05-29 16:25:54 -07:00
|
|
|
# bindings are created.
|
|
|
|
generated_python_directories = [
|
2019-07-08 22:41:37 +08:00
|
|
|
"ray/core/generated",
|
2018-05-29 16:25:54 -07:00
|
|
|
]
|
|
|
|
|
2017-10-09 23:32:38 -07:00
|
|
|
optional_ray_files = []
|
|
|
|
|
2018-05-31 09:00:03 -07:00
|
|
|
ray_autoscaler_files = [
|
|
|
|
"ray/autoscaler/aws/example-full.yaml",
|
|
|
|
"ray/autoscaler/gcp/example-full.yaml",
|
2018-11-09 21:25:15 -08:00
|
|
|
"ray/autoscaler/local/example-full.yaml",
|
2018-05-31 09:00:03 -07:00
|
|
|
]
|
2018-03-04 23:35:58 -08:00
|
|
|
|
2018-03-07 10:18:58 -08:00
|
|
|
if "RAY_USE_NEW_GCS" in os.environ and os.environ["RAY_USE_NEW_GCS"] == "on":
|
2018-04-11 10:11:35 -07:00
|
|
|
ray_files += [
|
|
|
|
"ray/core/src/credis/build/src/libmember.so",
|
|
|
|
"ray/core/src/credis/build/src/libmaster.so",
|
|
|
|
"ray/core/src/credis/redis/src/redis-server"
|
|
|
|
]
|
2018-03-07 10:18:58 -08:00
|
|
|
|
2018-03-04 23:35:58 -08:00
|
|
|
optional_ray_files += ray_autoscaler_files
|
|
|
|
|
2018-11-27 09:50:59 -08:00
|
|
|
extras = {
|
2019-02-23 11:58:59 -08:00
|
|
|
"rllib": [
|
|
|
|
"pyyaml", "gym[atari]", "opencv-python-headless", "lz4", "scipy"
|
|
|
|
],
|
2018-11-27 09:50:59 -08:00
|
|
|
"debug": ["psutil", "setproctitle", "py-spy"],
|
2019-02-21 08:10:04 +00:00
|
|
|
"dashboard": ["psutil", "aiohttp"],
|
2018-11-27 09:50:59 -08:00
|
|
|
}
|
2017-12-12 13:58:28 -08:00
|
|
|
|
2017-07-31 21:04:15 -07:00
|
|
|
|
2017-05-27 21:35:48 -07:00
|
|
|
class build_ext(_build_ext.build_ext):
|
2017-07-13 14:53:57 -07:00
|
|
|
def run(self):
|
2017-08-07 21:17:28 -07:00
|
|
|
# Note: We are passing in sys.executable so that we use the same
|
|
|
|
# version of Python to build pyarrow inside the build.sh script. Note
|
|
|
|
# that certain flags will not be passed along such as --user or sudo.
|
|
|
|
# TODO(rkn): Fix this.
|
2019-03-07 09:59:13 +08:00
|
|
|
command = ["../build.sh", "-p", sys.executable]
|
|
|
|
if os.getenv("RAY_INSTALL_JAVA") == "1":
|
|
|
|
# Also build binaries for Java if the above env variable exists.
|
|
|
|
command += ["-l", "python,java"]
|
|
|
|
subprocess.check_call(command)
|
2017-08-07 21:17:28 -07:00
|
|
|
|
|
|
|
# We also need to install pyarrow along with Ray, so make sure that the
|
|
|
|
# relevant non-Python pyarrow files get copied.
|
2018-08-02 17:06:37 -07:00
|
|
|
pyarrow_files = []
|
|
|
|
for (root, dirs, filenames) in os.walk("./ray/pyarrow_files/pyarrow"):
|
|
|
|
for name in filenames:
|
|
|
|
pyarrow_files.append(os.path.join(root, name))
|
2017-08-07 21:17:28 -07:00
|
|
|
|
2019-02-18 12:17:36 -08:00
|
|
|
# Make sure the relevant files for modin get copied.
|
|
|
|
modin_files = []
|
|
|
|
for (root, dirs, filenames) in os.walk("./ray/modin"):
|
|
|
|
for name in filenames:
|
|
|
|
modin_files.append(os.path.join(root, name))
|
|
|
|
|
|
|
|
files_to_include = ray_files + pyarrow_files + modin_files
|
2017-07-31 21:04:15 -07:00
|
|
|
|
2019-07-08 22:41:37 +08:00
|
|
|
# Copy over the autogenerated protobuf Python bindings.
|
2018-05-29 16:25:54 -07:00
|
|
|
for directory in generated_python_directories:
|
|
|
|
for filename in os.listdir(directory):
|
|
|
|
if filename[-3:] == ".py":
|
|
|
|
files_to_include.append(os.path.join(directory, filename))
|
|
|
|
|
2017-07-13 14:53:57 -07:00
|
|
|
for filename in files_to_include:
|
|
|
|
self.move_file(filename)
|
2017-05-27 21:35:48 -07:00
|
|
|
|
2017-10-09 23:32:38 -07:00
|
|
|
# Try to copy over the optional files.
|
|
|
|
for filename in optional_ray_files:
|
|
|
|
try:
|
|
|
|
self.move_file(filename)
|
2018-10-24 16:30:00 -07:00
|
|
|
except Exception:
|
2017-10-09 23:32:38 -07:00
|
|
|
print("Failed to copy optional file {}. This is ok."
|
|
|
|
.format(filename))
|
|
|
|
|
2017-07-13 14:53:57 -07:00
|
|
|
def move_file(self, filename):
|
|
|
|
# TODO(rkn): This feels very brittle. It may not handle all cases. See
|
|
|
|
# https://github.com/apache/arrow/blob/master/python/setup.py for an
|
|
|
|
# example.
|
|
|
|
source = filename
|
|
|
|
destination = os.path.join(self.build_lib, filename)
|
|
|
|
# Create the target directory if it doesn't already exist.
|
|
|
|
parent_directory = os.path.dirname(destination)
|
|
|
|
if not os.path.exists(parent_directory):
|
|
|
|
os.makedirs(parent_directory)
|
2019-02-23 11:58:59 -08:00
|
|
|
if not os.path.exists(destination):
|
|
|
|
print("Copying {} to {}.".format(source, destination))
|
|
|
|
shutil.copy(source, destination)
|
2017-05-27 21:35:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
class BinaryDistribution(Distribution):
|
2017-07-13 14:53:57 -07:00
|
|
|
def has_ext_modules(self):
|
|
|
|
return True
|
2017-05-27 21:35:48 -07:00
|
|
|
|
2017-03-21 12:57:54 -07:00
|
|
|
|
2018-11-05 05:53:55 +08:00
|
|
|
def find_version(*filepath):
|
|
|
|
# Extract version information from filepath
|
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
with open(os.path.join(here, *filepath)) as fp:
|
|
|
|
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
|
|
|
|
fp.read(), re.M)
|
|
|
|
if version_match:
|
|
|
|
return version_match.group(1)
|
|
|
|
raise RuntimeError("Unable to find version string.")
|
|
|
|
|
|
|
|
|
2018-11-22 11:43:52 -08:00
|
|
|
requires = [
|
2019-03-15 10:37:57 -07:00
|
|
|
"numpy >= 1.14",
|
2018-12-09 13:52:40 -08:00
|
|
|
"filelock",
|
2018-11-22 11:43:52 -08:00
|
|
|
"funcsigs",
|
|
|
|
"click",
|
|
|
|
"colorama",
|
|
|
|
"pytest",
|
|
|
|
"pyyaml",
|
2018-11-24 16:36:38 -08:00
|
|
|
"redis",
|
2019-02-28 05:05:25 +08:00
|
|
|
# NOTE: Don't upgrade the version of six! Doing so causes installation
|
|
|
|
# problems. See https://github.com/ray-project/ray/issues/4169.
|
|
|
|
"six >= 1.0.0",
|
2019-01-13 23:55:59 -08:00
|
|
|
"faulthandler;python_version<'3.3'",
|
2019-07-06 15:59:55 -07:00
|
|
|
"protobuf >= 3.8.0",
|
2018-11-22 11:43:52 -08:00
|
|
|
]
|
|
|
|
|
2018-04-11 10:11:35 -07:00
|
|
|
setup(
|
|
|
|
name="ray",
|
2018-11-05 05:53:55 +08:00
|
|
|
version=find_version("ray", "__init__.py"),
|
2018-12-19 18:41:09 -08:00
|
|
|
author="Ray Team",
|
|
|
|
author_email="ray-dev@googlegroups.com",
|
2018-10-28 19:49:52 -07:00
|
|
|
description=("A system for parallel and distributed Python that unifies "
|
|
|
|
"the ML ecosystem."),
|
|
|
|
long_description=open("../README.rst").read(),
|
|
|
|
url="https://github.com/ray-project/ray",
|
|
|
|
keywords=("ray distributed parallel machine-learning "
|
|
|
|
"reinforcement-learning deep-learning python"),
|
2018-04-11 10:11:35 -07:00
|
|
|
packages=find_packages(),
|
|
|
|
cmdclass={"build_ext": build_ext},
|
|
|
|
# The BinaryDistribution argument triggers build_ext.
|
|
|
|
distclass=BinaryDistribution,
|
2018-11-22 11:43:52 -08:00
|
|
|
install_requires=requires,
|
2018-12-14 20:49:37 -08:00
|
|
|
setup_requires=["cython >= 0.29"],
|
2018-04-11 10:11:35 -07:00
|
|
|
extras_require=extras,
|
2018-07-12 19:12:04 +02:00
|
|
|
entry_points={
|
|
|
|
"console_scripts": [
|
|
|
|
"ray=ray.scripts.scripts:main",
|
2019-03-08 16:46:05 -08:00
|
|
|
"rllib=ray.rllib.scripts:cli [rllib]", "tune=ray.tune.scripts:cli"
|
2018-07-12 19:12:04 +02:00
|
|
|
]
|
|
|
|
},
|
2018-04-11 10:11:35 -07:00
|
|
|
include_package_data=True,
|
|
|
|
zip_safe=False,
|
|
|
|
license="Apache 2.0")
|