Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support installation of rockstar through conda #219

Merged
merged 4 commits into from Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 30 additions & 10 deletions doc/source/Installation.rst
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
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