Skip to content

Commit 339c7e9

Browse files
committed
classy: updated installation method
1 parent 9d7031e commit 339c7e9

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

cobaya/theories/classy/classy.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,13 @@
187187
$ cd /path/to/cosmo/
188188
$ git clone https://github.com/lesgourg/class_public.git CLASS --depth=1
189189
$ cd CLASS
190-
$ make
190+
$ python setup.py build
191191
192192
If the **second** line produces an error (because you don't have ``git`` installed),
193193
download the latest snapshot from `here
194194
<https://github.com/lesgourg/class_public/archive/master.zip>`_, decompress it, rename the
195-
resulting ``class_public-master`` folder to ``CLASS`` (optional) and run the ``make``
196-
command from there.
197-
198-
.. note::
199-
200-
If CLASS seems to compile and install correctly, but you cannot import it from Python
201-
manually, or Cobaya fails to import it, it may be that the CLASS installation script is
202-
not using the right Python version. To fix that, if your preferred Python command is
203-
e.g. ``python3``, re-do the ``make`` step as
204-
205-
.. code:: bash
206-
207-
$ PYTHON=python3 make
195+
resulting ``class_public-master`` folder to ``CLASS`` (optional) and run the
196+
``python setup.py build`` command from there.
208197
209198
If the instructions above failed, follow those in the
210199
`official CLASS web page <https://class-code.net/>`_.
@@ -329,9 +318,11 @@ def initialize(self):
329318
# Add general CLASS stuff
330319
self.extra_args["output"] = self.extra_args.get("output", "")
331320
if "sBBN file" in self.extra_args:
332-
self.extra_args["sBBN file"] = self.extra_args["sBBN file"].format(
333-
classy=self.path
334-
)
321+
sbbn_dir, sbbn_file = os.path.split(self.extra_args["sBBN file"])
322+
if not os.path.isabs(sbbn_dir):
323+
# Discard dir, since it's standardized in the C code anyway.
324+
self.extra_args["sBBN file"] = os.path.join("/external/bbn", sbbn_file)
325+
# The "else" case (abs path) will fail in CLASS, and should be fixed.
335326
# Normalize `non_linear` vs `non linear`: prefer underscore
336327
# Keep this convention throughout the rest of this module!
337328
if "non linear" in self.extra_args:
@@ -1008,7 +999,13 @@ def install(cls, path=None, code=True, no_progress_bars=False, **_kwargs):
1008999

10091000
env = deepcopy(os.environ)
10101001
env.update({"PYTHON": sys.executable})
1011-
process_make = Popen(["make"], cwd=classy_path, stdout=PIPE, stderr=PIPE, env=env)
1002+
process_make = Popen(
1003+
[sys.executable, "setup.py", "build"],
1004+
cwd=classy_path,
1005+
stdout=PIPE,
1006+
stderr=PIPE,
1007+
env=env,
1008+
)
10121009
out, err = process_make.communicate()
10131010
if process_make.returncode:
10141011
log.info(out.decode("utf-8"))

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def install_test_wrapper(skip_not_installed, func, *args, **kwargs):
8383
raise
8484

8585

86-
# Skip not installed #####################################################################
86+
# Plots from tests #######################################################################
8787

8888

8989
@pytest.fixture

0 commit comments

Comments
 (0)