lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

a minor issue in python/setup.py when OMPFLAG is not set #383

Open komatsu5147 opened 3 years ago

komatsu5147 commented 3 years ago

It would be better to change the last line in the following part python/setup.py:

# Define cython extension and fix Python version
classy_ext = Extension("classy", [os.path.join(classy_folder, "classy.pyx")],
                           include_dirs=[nm.get_include(), include_folder],
                           libraries=liblist,
                           library_dirs=[root_folder, GCCPATH],
                           extra_link_args=['-lgomp'])

to

# Define cython extension and fix Python version
classy_ext = Extension("classy", [os.path.join(classy_folder, "classy.pyx")],
                           include_dirs=[nm.get_include(), include_folder],
                           libraries=liblist,
                           library_dirs=[root_folder, GCCPATH],
                           extra_link_args=['-lgomp'],
)

The reason: When OMPFLAG is not set, Makefile removes the line containing "lgomp". This means that the above line before modification becomes an incomplete line, yielding a syntax error:

grep -v "lgomp" python/setup.py > python/autosetup.py
cd python; export CC=gcc; python autosetup.py install || python autosetup.py install --user
  File "autosetup.py", line 41
    import six
    ^
SyntaxError: invalid syntax
  File "autosetup.py", line 41
    import six
    ^
SyntaxError: invalid syntax
make: *** [classy] Error 1

The above simple fix eliminates this error. Hope this is helpful!

komatsu5147 commented 3 years ago

Just realised that this fix was already reported in the pull request https://github.com/lesgourg/class_public/pull/343. So, perhaps you could merge it to reflect this easy fix.