diff --git a/doc/source/Installation.rst b/doc/source/Installation.rst index dbfd2098..77fe35fe 100644 --- a/doc/source/Installation.rst +++ b/doc/source/Installation.rst @@ -47,15 +47,9 @@ Installing with Rockstar support versions of ``rockstar`` will not work. Rockstar support requires ``yt_astro_analysis`` to be installed from source. -Before that, the ``rockstar-galaxies`` code must also be installed from source -and the installation path then provided to ``yt_astro_analysis``. Two -recommended repositories exist for installing ``rockstar-galaxies``, -`this one `__, by the -original author, Peter Behroozi, and -`this one `__, maintained by -John Wise. +Before that, the ``rockstar-galaxies`` code must also be installed. -.. warning:: If using `Peter Behroozi's repository +.. warning:: If using the conda version or building from source with `Peter Behroozi's repository `__, the following command must be issued after loading the resulting halo catalog in ``yt``: @@ -64,6 +58,32 @@ John Wise. ds = yt.load(...) ds.parameters["format_revision"] = 2 +Installing ``rockstar-galaxies`` through ``conda`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you are using ``conda`` to manage packages, you can install ``rockstar-galaxies`` as follows + +.. code-block:: bash + + $ conda install -c conda-forge rockstar-galaxies + +Then, go into the ``yt_astro_analysis`` source directory and install it. + +.. code-block:: bash + + $ cd yt_astro_analysis + $ pip install -e . + +Installing ``rockstar-galaxies`` from source +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Alternatively, you can install ``rockstar-galaxies`` from source. Two +recommended repositories exist for installing ``rockstar-galaxies``, +`this one `__, by the +original author, Peter Behroozi, and +`this one `__, maintained by +John Wise. + To install ``rockstar-galaxies``, do the following: .. code-block:: bash @@ -82,8 +102,8 @@ Then, install ``yt_astro_analysis``. $ echo > rockstar.cfg $ pip install -e . -Finally, you'll need to make sure that the location of ``librockstar-galaxies.so`` -is in your LD_LIBRARY_PATH. +Finally, if you installed rockstar-galaxies from source, you'll need to make sure that +the location of ``librockstar-galaxies.so`` is in your LD_LIBRARY_PATH. .. code-block:: bash diff --git a/setup.py b/setup.py index 2821528b..4b508fa0 100644 --- a/setup.py +++ b/setup.py @@ -78,6 +78,7 @@ def get_version(filename): ] # ROCKSTAR +_paths_to_try = [] if os.path.exists("rockstar.cfg"): try: rd = open("rockstar.cfg").read().strip() @@ -87,7 +88,17 @@ def get_version(filename): print("rockstar-galaxies install in rockstar.cfg and restart.") print("(ex: \"echo '/path/to/rockstar-galaxies' > rockstar.cfg\" )") sys.exit(1) + _paths_to_try.append(rd) +if "CONDA_PREFIX" in os.environ: + _paths_to_try.append( + os.path.join(os.environ["CONDA_PREFIX"], "include", "rockstar-galaxies") + ) + +for rd in _paths_to_try: + if not os.path.exists(rd): + continue + print(f"BUILDING with ROCKSTAR in {rd}") rockstar_extdir = "yt_astro_analysis/halo_analysis/halo_finding/rockstar" rockstar_extensions = [ Extension( @@ -108,6 +119,8 @@ def get_version(filename): ext.include_dirs += [rd, os.path.join(rd, "io"), os.path.join(rd, "util")] extensions += rockstar_extensions + break + CYTHONIZE_KWARGS = { "compiler_directives": {"language_level": 3},