Skip to content

Commit

Permalink
Merge pull request #219 from cphyc/support-rockstar-conda
Browse files Browse the repository at this point in the history
Support installation of rockstar through conda
  • Loading branch information
brittonsmith authored Sep 7, 2023
2 parents 0a4aff6 + ceea441 commit 498534a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
40 changes: 30 additions & 10 deletions doc/source/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://bitbucket.org/pbehroozi/rockstar-galaxies/>`__, by the
original author, Peter Behroozi, and
`this one <https://bitbucket.org/jwise77/rockstar-galaxies>`__, 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
<https://bitbucket.org/pbehroozi/rockstar-galaxies/>`__, the following
command must be issued after loading the resulting halo catalog in ``yt``:

Expand All @@ -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 <https://bitbucket.org/pbehroozi/rockstar-galaxies/>`__, by the
original author, Peter Behroozi, and
`this one <https://bitbucket.org/jwise77/rockstar-galaxies>`__, maintained by
John Wise.

To install ``rockstar-galaxies``, do the following:

.. code-block:: bash
Expand All @@ -82,8 +102,8 @@ Then, install ``yt_astro_analysis``.
$ echo <path_to_rockstar> > 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
Expand Down
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand All @@ -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},
Expand Down

0 comments on commit 498534a

Please sign in to comment.