diff --git a/doc/source/development.rst b/doc/source/development.rst index 6ea581aec..82c931aa5 100644 --- a/doc/source/development.rst +++ b/doc/source/development.rst @@ -34,7 +34,10 @@ RLlib, Tune, Autoscaler, and most Python files do not require you to build and c git remote add upstream https://github.com/ray-project/ray.git # Make sure you are up-to-date on master. -4. Replace Python files in the installed package with your local editable copy. We provide a simple script to help you do this: ``ray/python/ray/setup-dev.py``. Running the script will remove the ``ray/tune``, ``ray/rllib``, ``ray/autoscaler`` dir (among other directories) bundled with the ``ray`` pip package, and replace them with links to your local code. +3. Replace Python files in the installed package with your local editable copy. We provide a simple script to help you do this: ``python python/ray/setup-dev.py``. +Running the script will remove the ``ray/tune``, ``ray/rllib``, ``ray/autoscaler`` dir (among other directories) bundled with the ``ray`` pip package, and replace them with links to your local code. This way, changing files in your git clone will directly affect the behavior of your installed ray. + +.. warning:: Do not run ``pip uninstall ray`` or ``pip install -U`` (for Ray or Ray wheels) if setting up your environment this way. To uninstall or upgrade, you must first ``rm -rf`` the pip-installation site (usually a ``site-packages/ray`` location), then do a pip reinstall (see 1. above), and finally run the above `setup-dev.py` script again. .. code-block:: shell @@ -43,8 +46,6 @@ RLlib, Tune, Autoscaler, and most Python files do not require you to build and c # This replaces miniconda3/lib/python3.7/site-packages/ray/tune # with your local `ray/python/ray/tune`. -.. warning:: Do not run ``pip uninstall ray`` or ``pip install -U`` (for Ray or Ray wheels) if setting up your environment this way. To uninstall or upgrade, you must ``rm -rf`` the installation site (usually a ``site-packages/ray`` location). - Building Ray (full) ------------------- diff --git a/python/ray/setup-dev.py b/python/ray/setup-dev.py index 793457943..a33fe129d 100755 --- a/python/ray/setup-dev.py +++ b/python/ray/setup-dev.py @@ -4,6 +4,7 @@ import argparse import click import os +import shutil import subprocess import ray @@ -22,14 +23,25 @@ def do_link(package, force=False, local_path=""): package_home, local_home), default=True): return - if os.access(os.path.dirname(package_home), os.W_OK): - subprocess.check_call(["rm", "-rf", package_home]) - subprocess.check_call(["ln", "-s", local_home, package_home]) + # Windows: Create directory junction. + if os.name == "nt": + try: + shutil.rmtree(package_home) + except FileNotFoundError: + pass + except OSError: + os.remove(package_home) + subprocess.check_call( + ["mklink", "/J", package_home, local_home], shell=True) + # Posix: Use `ln -s` to create softlink. else: - print("You don't have write permission to {}, using sudo:".format( - package_home)) - subprocess.check_call(["sudo", "rm", "-rf", package_home]) - subprocess.check_call(["sudo", "ln", "-s", local_home, package_home]) + sudo = [] + if not os.access(os.path.dirname(package_home), os.W_OK): + print("You don't have write permission to {}, using sudo:".format( + package_home)) + sudo = ["sudo"] + subprocess.check_call(sudo + ["rm", "-rf", package_home]) + subprocess.check_call(sudo + ["ln", "-s", local_home, package_home]) if __name__ == "__main__":