For a majority of Ray users, installing Ray via the latest wheels or pip package is usually enough. However, you may want to build the latest master branch.
Then you can enter into the Ray git repository directory:
..code-block:: shell
cd ray
Next make sure you connect your repository to the upstream (main project) Ray repository. This will allow you to push your code to your repository when proposing changes (in pull requests) while also pulling updates from the main project.
..tabbed:: Git SSH
To connect your repository using SSH (the default) run the command:
Every time you want to update your local version you can pull the changes from the main repository:
..code-block:: shell
# Checkout the local master branch
git checkout master
# Pull the latest changes from the main repository
git pull upstream master
Prepare the Python environment
------------------------------
..tip::
To setup an isolated Anaconda environment, see :ref:`ray_anaconda`.
You will probably want to have some type of Python virtual environment. For example you could use Python's integrated ``venv`` module to create one:
..code-block:: shell
python -m venv env
That will create a virtual environment called ``env`` in the current directory, it will contain a directory with all the packages used by the local Python of your project. You only need to do this step once.
Next, you need to activate the environment to tell your shell/terminal to use this particular Python. This will also depend on the system you use to set up your virtual environment (conda, venv, or other methods).
If you are using the example from above using ``venv``, you would activate your virtual environment with:
..code-block:: shell
source env/bin/activate
You will need to activate the virtual environment every time you start a new shell/terminal to work on Ray.
After that, it's always good to make sure you have the latest version of ``pip`` and ``wheel``. When you create a new virtual environment it can come with an older version, and many strange-looking problems while installing packages are simply solved by upgrading pip to the latest version:
..code-block:: shell
python -m pip install --upgrade pip wheel
That command tells Python to use the module ``pip`` to install the latest version of ``pip`` (itself) and ``wheel``.
RLlib, Tune, Autoscaler, and most Python files do not require you to build and compile Ray. Follow these instructions to develop Ray's Python files locally without building Ray.
4. 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 directory at the ``site-packages/ray`` location), then do a pip reinstall (see the command above), and finally run the above ``setup-dev.py`` script again.
..tip:: Assuming you already have Brew and Bazel installed on your mac and you also have grpc and protobuf installed on your mac consider removing those (grpc and protobuf) for smooth build through the commands ``brew uninstall grpc``, ``brew uninstall protobuf``. If you have built the source code earlier and it still fails with errors like ``No such file or directory:``, try cleaning previous builds on your host by running the commands ``brew uninstall binutils`` and ``bazel clean --expunge``.
..warning:: if you run ``python setup.py install``, files will be copied from the Ray directory to a directory of Python packages (``/lib/python3.6/site-packages/ray``). This means that changes you make to files in the Ray directory will not have any effect.
If your machine is running out of memory during the build or the build is causing other programs to crash, try adding the following line to ``~/.bazelrc``:
1. Enable Developer mode on Windows 10 systems. This is necessary so git can create symlinks.
1. Open Settings app;
2. Go to "Update & Security";
3. Go to "For Developers" on the left pane;
4. Turn on "Developer mode".
2. Add the following Miniconda subdirectories to PATH. If Miniconda was installed for all users, the following paths are correct. If Miniconda is installed for a single user, adjust the paths accordingly.
3. Define an environment variable ``BAZEL_SH`` to point to ``bash.exe``. If git for Windows was installed for all users, bash's path should be ``C:\Program Files\Git\bin\bash.exe``. If git was installed for a single user, adjust the path accordingly.