From 22c019b5dcaf10e59516dd682af376c0b01c820a Mon Sep 17 00:00:00 2001 From: Antony Lewis Date: Fri, 18 Jan 2019 21:41:20 +0000 Subject: [PATCH] Changes for Planck 2018 defaults and accuracy tweaks - default halofit version now mead (HMCode), as Planck 2018 - update BBN default model to 2018 Parthenope table - Calculate all L<=15 (small change in EE polarization at 10 1900661 bytes camb/model.py | 19 +- camb/nonlinear.py | 2 +- camb/results.py | 26 +- camb_tests/camb_test.py | 14 +- docs/CAMBdemo.html | 50 +- docs/README_pypi.rst | 32 + docs/source/index.rst | 30 +- .../HighLExtrapTemplate_lenspotentialCls.dat | 15999 ++++++++-------- fortran/VisualStudio/CAMB.sln | 2 +- .../{CAMB_devel.vfproj => CAMB.vfproj} | 0 fortran/camb_python.f90 | 2 + fortran/config.f90 | 27 +- fortran/halofit.f90 | 4 +- fortran/readme.html | 6 +- fortran/results.f90 | 44 +- inifiles/params.ini | 2 +- requirements.txt | 3 +- setup.py | 203 +- 26 files changed, 8333 insertions(+), 8245 deletions(-) create mode 100644 docs/README_pypi.rst rename fortran/VisualStudio/{CAMB_devel.vfproj => CAMB.vfproj} (100%) diff --git a/.travis.yml b/.travis.yml index b7ab6975..c9131830 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,13 +35,6 @@ matrix: - CHANNEL="conda-forge" python: "3.6" - -#before_install: -# - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test -# - sudo apt-get update -qq -# - sudo apt-get install -qq gfortran-6 -# - sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-6 90 - install: - mkdir -p gfortran-symlinks - ln -s /usr/bin/gfortran-$GCC_VERSION gfortran-symlinks/gfortran @@ -67,7 +60,7 @@ install: script: fortran/tests/run_tests.sh after_failure: - - test $TRAVIS_PULL_REQUEST == "false" && test $CHANNEL == "defaults" && test $TRAVIS_REPO_SLUG == "cmbant/CAMB" && [ -d testfiles ] && bash fortran/tests/upload_tests.sh + - test $TRAVIS_PULL_REQUEST == "false" && test $CHANNEL == "defaults" && test $TRAVIS_REPO_SLUG == "cmbant/CAMB" && [ -d fortran/testfiles ] && bash fortran/tests/upload_tests.sh before_deploy: - pushd fortran; make clean delete; popd diff --git a/MANIFEST.in b/MANIFEST.in index 8f966056..8193ade6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,15 @@ include *.rst *.txt recursive-include camb *.py recursive-include camb_tests *.py +recursive-include fortran Makefile* *.dat *.?90 +recursive-include forutils Makefile* *.?90 include camb/cambdll.dll +exclude camb/camblib.so include camb/PArthENoPE_880.2_marcucci.dat include camb/PArthENoPE_880.2_standard.dat +include camb/PRIMAT_Yp_DH_Error.dat +exclude camb/HighLExtrapTemplate_lenspotentialCls.dat +exclude fortran/sigma8.f90 +exclude fortran/writefits.f90 +include docs/README_pypi.rst + diff --git a/README.rst b/README.rst index ca8b0c05..4cb4df4f 100644 --- a/README.rst +++ b/README.rst @@ -16,29 +16,40 @@ Description and installation CAMB is a cosmology code for calculating cosmlogical observables, including CMB, lensing, source count and 21cm angular power spectra, matter power spectra, transfer functions -and background evolution. The code is in Python and modern Fortran. +and background evolution. The code is in Python, with numerical code implemented in fast modern Fortran. -To install the CAMB python package on your computer run:: +See the `CAMB python example notebook `_ for a +quick introduction to how to use the CAMB Python package. - pip install camb +For a standard non-editable installation use:: -or from the source + pip install camb [--user] - python setup.py install +The --user is optional and only required if you don't have write permission to your main python installation. +To install from source, clone from github using:: -You will need gfortran 6 or higher installed to compile. Binary library builds for python on -Windows are also provided, so these are used instead if no gfortran installation -is found on Windows machines. + git clone --recursive https://github.com/cmbant/CAMB -See the `CAMB python example notebook `_ for a -quick introduction to how to use the CAMB Python package. +Then in the project source root directory use:: + + python setup.py install [--user] + +If you want to work on the code, you can also just install in place without copying anything using:: + + python setup.py make + pip install -e . [--user] + +You will need gfortran 6 or higher installed to compile. Binary files for Windows are also provided, so these are used instead if no +gfortran installation is found on Windows machines. If you have gfortran installed, "python setup.py make" will build +the Fortran library on all systems (including Windows without directly using a Makefile). The python wrapper provides a module called "camb" documented in the `Python CAMB documentation `_. -.. image:: https://readthedocs.org/projects/camb/badge/?version=latest - :target: https://camb.readthedocs.org/en/latest +After installation you can also run CAMB from the command line reading parameters from a .ini file, e.g.:: + + camb inifiles/planck_2018.ini -To compile the Fortran command-line code run "Make" in the fortran directory. For full details +To compile the Fortran command-line code run "make camb" in the fortran directory. For full details see the `ReadMe `_. Branches @@ -57,8 +68,9 @@ Reference results and test outputs are stored in the `test outputs repository `_ code. -CAMB_v1 is the old Fortran-oriented (gfortran 4.8-compatible) version as used by the Planck 2018 analysis. + - *CAMB_sources* is the old public `CAMB Sources `_ code. + - *CAMB_v1* is the old Fortran-oriented (gfortran 4.8-compatible) version as used by the Planck 2018 analysis. + - *rayleigh* includes frequency-dependent Rayleigh scattering ============= diff --git a/camb.py b/camb.py index f5cb67b1..5bd8b2f5 100644 --- a/camb.py +++ b/camb.py @@ -3,7 +3,8 @@ # Python command line CAMB reading parameters from a .ini file # an alternative to fortran binary compiled into fortran/camb using "make camb". # To use .ini files from a python script use camb.run_ini or camb.read_ini +# If you have installed the camb package, you can just use "camb params.ini" without using this script. -from camb._command_line import _run_command_line +from camb._command_line import run_command_line -_run_command_line() +run_command_line() diff --git a/camb/_command_line.py b/camb/_command_line.py index 601502f9..69119a62 100644 --- a/camb/_command_line.py +++ b/camb/_command_line.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import os import sys @@ -9,10 +10,11 @@ import ctypes import six -def _run_command_line(): + +def run_command_line(): parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description='Python command line CAMB reading parameters from a .ini file.' + - '\n\n Example usage:\n\n python camb.py inifiles/planck_2018.ini') + '\n\nSample .ini files are provided in the source distribution, e.g. see inifiles/planck_2018.ini') parser.add_argument('ini_file', help='text .ini file with parameter settings') parser.add_argument('--validate', action='store_true', help='Just validate the .ini file, don''t actually run anything') @@ -33,4 +35,4 @@ def _run_command_line(): if __name__ == "__main__": - _run_command_line() + run_command_line() diff --git a/camb/baseconfig.py b/camb/baseconfig.py index 14108832..ad129063 100644 --- a/camb/baseconfig.py +++ b/camb/baseconfig.py @@ -44,9 +44,9 @@ def __getitem__(self, name_or_ordinal): else: if not osp.isfile(CAMBL): - sys.exit( - 'Library file %s does not exist.\nMake sure you have installed or built the camb package (or remove any old installation and install again).' % ( - CAMBL)) + sys.exit('Library file %s does not exist.\nMake sure you have installed or built the camb package ' + '(e.g. using "python setup.py make"); or remove any old conflicting installation and install again.' % ( + CAMBL)) camblib = ctypes.LibraryLoader(ifort_gfortran_loader).LoadLibrary(CAMBL) @@ -86,11 +86,14 @@ def lib_import(module_name, class_name, func_name, restype=None): return func -def set_filelocs(): - HighLExtrapTemplate = osp.join(BASEDIR, "HighLExtrapTemplate_lenspotentialCls.dat") +def set_cl_template_file(cl_template_file=None): + if cl_template_file and not osp.exists(cl_template_file): + raise ValueError('File not found : %s' % cl_template_file) + + HighLExtrapTemplate = cl_template_file or osp.join(BASEDIR, "HighLExtrapTemplate_lenspotentialCls.dat") if not osp.exists(HighLExtrapTemplate): HighLExtrapTemplate = osp.abspath( - osp.join(BASEDIR, "../../fortran", "HighLExtrapTemplate_lenspotentialCls.dat")) + osp.join(BASEDIR, "..", "..", "fortran", "HighLExtrapTemplate_lenspotentialCls.dat")) HighLExtrapTemplate = six.b(HighLExtrapTemplate) func = camblib.__handles_MOD_set_cls_template func.argtypes = [ctypes.c_char_p, ctypes.c_long] @@ -98,7 +101,7 @@ def set_filelocs(): func(s, ctypes.c_long(len(HighLExtrapTemplate))) -set_filelocs() +set_cl_template_file() def _get_fortran_sizes(): diff --git a/camb/bbn.py b/camb/bbn.py index 10b10100..e6bda03d 100644 --- a/camb/bbn.py +++ b/camb/bbn.py @@ -65,17 +65,18 @@ def Y_He(self, ombh2, delta_neff=0.): class BBN_table_interpolator(BBNPredictor): """ - BBN predictor based on interpolation on a table calculated from BBN code + BBN predictor based on interpolation from a numerical table calculated by a BBN code. + + Tables are supplied for `Parthenope `_ 2017 (PArthENoPE_880.2_standard.dat, default), + similar but with Marucci rates (PArthENoPE_880.2_marcucci.dat), and `PRIMAT `_ (PRIMAT_Yp_DH_Error.dat). + + :param interpolation_table: filename of interpolation table to use. + :param function_of: two variables that determine the interpolation grid (x,y) in the table, matching top column label comment. + By default ombh2, DeltaN, and function argument names reflect that, but can also be used more generally. + """ def __init__(self, interpolation_table='PArthENoPE_880.2_standard.dat', function_of=['ombh2', 'DeltaN']): - """ - Load table file and initialize interpolation - - :param interpolation_table: filename of interpolation table to use. - :param function_of: two variables that determine the interpolation grid (x,y) in the table, matching top column label comment. - By default ombh2, DeltaN, and function argument names reflect that, but can also be used more generally. - """ if os.sep not in interpolation_table and '/' not in interpolation_table: interpolation_table = os.path.normpath(os.path.join(os.path.dirname(__file__), interpolation_table)) @@ -149,7 +150,7 @@ def get(self, name, ombh2, delta_neff=0., grid=False): class BBN_fitting_parthenope(BBNPredictor): """ - BBN predictions for Helium abundance using fitting formulae based on Parthenope (pre 2015) + Old BBN predictions for Helium abundance using fitting formulae based on Parthenope (pre 2015). """ def __init__(self, tau_neutron=None): @@ -191,11 +192,11 @@ def DH(self, ombh2, delta_neff, tau_neutron=None): def get_default_predictor(): """ - Get instance of default BBNPredictor class. Currently fitting formula to match Planck 2015 analysis. + Get instance of default BBNPredictor class. Currently numerical table interpolation as Planck 2018 analysis. """ global _default_predictor if _default_predictor is None: - _default_predictor = BBN_fitting_parthenope() + _default_predictor = BBN_table_interpolator() return _default_predictor diff --git a/camb/cambdll.dll b/camb/cambdll.dll index e1f95cbea81b56af088a2805905ccc7f460e6bf9..3b2f8e52bbadb063738d7e29c180654e1d7cf30a 100644 GIT binary patch delta 313688 zcmaGo2V7H0^Vx|YA`p;H=mY@;1Z-eI>4^qK>>cIoUBQZq2dELF;_9tk&+gfeJ7X6c z_U@-*7u$>2uy_Bn?*+?!_x<_(^krveXJ=<-XJ^ZMZ?ZF9XJ^csD(}@ewje(l!jcQF zMv%GGn&d!O8#PJ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f$uPbNVLFIBd`dQ`lW4PAsnd78np!j zD(6*OcuRcP<95&s?$&0l+e2;mQkzX}j~-D}n-#Z*Fql!BS*L+JbLapbKCNq`3XbGV z diff --git a/fortran/results.f90 b/fortran/results.f90 index f60b9c15..84a50b90 100644 --- a/fortran/results.f90 +++ b/fortran/results.f90 @@ -516,10 +516,10 @@ subroutine CAMBdata_SetParams(this, P, error, DoReion, call_again) write (*,*) 'source max_eta_k: ', this%CP%Max_eta_k,'kmax = ', this%CP%Max_eta_k/this%tau0 end if - if (this%CP%NonLinear==NonLinear_Lens .or. this%CP%NonLinear==NonLinear_both ) then - this%CP%Transfer%kmax = max(this%CP%Transfer%kmax, this%CP%Max_eta_k/this%tau0) - if (FeedbackLevel > 0 .and. this%CP%Transfer%kmax== this%CP%Max_eta_k/this%tau0) & - write (*,*) 'max_eta_k changed to ', this%CP%Max_eta_k + if ((this%CP%NonLinear==NonLinear_Lens .or. this%CP%NonLinear==NonLinear_both) .and. & + this%CP%Max_eta_k/this%tau0 > this%CP%Transfer%kmax) then + this%CP%Transfer%kmax =this%CP%Max_eta_k/this%tau0 + if (FeedbackLevel > 0) write (*,*) 'kmax changed to ', this%CP%Transfer%kmax end if if (global_error_flag/=0) then @@ -1242,13 +1242,17 @@ subroutine lSamples_init(this, State, lmin, max_l) end do if (Accuracy%AccurateReionization) then + do lvar=11, 14 + lind=lind+1 + ls(lind)=lvar + end do if (Accuracy%lSampleBoost > 1) then - do lvar=11, 37,1 + do lvar=15, 37, 1 lind=lind+1 ls(lind)=lvar end do else - do lvar=11, 37,2 + do lvar=15, 37, 2 lind=lind+1 ls(lind)=lvar end do @@ -1420,7 +1424,7 @@ subroutine InterpolateClArrTemplated(lSet,iCl, all_Cl, max_ind, template_index) if (max_ind > lSet%nl) call MpiStop('Wrong max_ind in InterpolateClArrTemplated') if (lSet%use_spline_template .and. present(template_index)) then if (template_index<=3) then - !interpolate only the difference between the C_l and an accurately interpolated template. Temp only for the mo. + !interpolate only the difference between the C_l and an accurately interpolated template. !Using unlensed for template, seems to be good enough maxdelta=max_ind do while (lSet%l(maxdelta) > lmax_extrap_highl) @@ -2651,32 +2655,6 @@ function Win_Limber_ell(W,CP,lmax) result(ell_limb) end function Win_Limber_ell - subroutine CheckLoadedHighLTemplate - use FileUtils - integer :: L - real(dl) :: array(7) - type(TTextFile) :: infile - - if (.not. allocated(highL_CL_template)) then - allocate(highL_CL_template(1:lmax_extrap_highl, C_Temp:C_Phi)) - call infile%Open(highL_unlensed_cl_template) - highL_CL_template(1,:)=0 - do - read(infile%unit, *, end=500) L, array - if (L>lmax_extrap_highl) exit - ! array = array * (2*l+1)/(4*pi) * 2*pi/(l*(l+1)) - highL_CL_template(L, C_Temp:C_E) =array(1:2) - highL_CL_template(L, C_Cross) =array(4) - highL_CL_template(L, C_Phi) =array(5) - end do -500 if (L< lmax_extrap_highl) & - call MpiStop('CheckLoadedHighLTemplate: template file does not go up to lmax_extrap_highl') - call infile%Close() - end if - - end subroutine CheckLoadedHighLTemplate - - subroutine TCLdata_InitCls(this, State) class(TCLData) :: this class(CAMBdata) :: State diff --git a/inifiles/params.ini b/inifiles/params.ini index 8f9b6305..a9fd3ffc 100644 --- a/inifiles/params.ini +++ b/inifiles/params.ini @@ -254,7 +254,7 @@ do_late_rad_truncation = T #6. A standard (inaccurate) halo model power spectrum calcultion #7. PKequal (Casarini et al. arXiv:0810.0190, arXiv:1601.07230) #8. HMcode (Mead et al. 2015; arXiv 1505.07833) -halofit_version= +halofit_version= 4 #Computation parameters #if number_of_threads=0 assigned automatically diff --git a/requirements.txt b/requirements.txt index 3b1c16d8..c3fa3735 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ numpy -matplotlib six sympy>=1.0 -scipy +scipy>=1.0 diff --git a/setup.py b/setup.py index 700bd4ba..fb36fe05 100644 --- a/setup.py +++ b/setup.py @@ -6,14 +6,15 @@ import io import re import os +import shutil from distutils.command.build import build from distutils.command.install import install -from distutils.command.sdist import sdist import struct try: from setuptools import setup except ImportError: + print('Using distutils.core') from distutils.core import setup is_windows = platform.system() == "Windows" @@ -31,7 +32,7 @@ def get_long_description(): - with open('README.rst') as f: + with open(os.path.join('docs', 'README_pypi.rst')) as f: return f.read() @@ -147,10 +148,10 @@ def makefile_dict(filename): append = len(parts) > 1 def repl(groups): - if groups[1] in vals: - return vals[groups[1]] + if groups.group(1) in vals: + return vals[groups.group(1)] else: - return groups[0] + return groups.group(0) for key, value in vals.items(): if '$' in value: @@ -158,88 +159,111 @@ def repl(groups): return vals +def make_library(cluster=False): + CAMBDIR = os.path.join(file_dir, 'fortran') + pycamb_path = '..' + os.chdir(CAMBDIR) + lib_file = os.path.join(pycamb_path, 'camb', DLLNAME) + if is_windows or not check_ifort(): + ok, gfortran_version = check_gfortran(msg=not is_windows) + if is_windows: + COMPILER = "gfortran" + # note that TDM-GCC MingW 5.1 does not work due go general fortran bug. + # This works: http://sourceforge.net/projects/mingw-w64/?source=typ_redirect + # but need to use 32bit compiler to build 32 bit dll (contrary to what is implied) + FFLAGS = "-shared -static -cpp -fopenmp -O3 -fmax-errors=4" + if is32Bit: FFLAGS = "-m32 " + FFLAGS + if not ok: + print( + 'WARNING: gfortran %s or higher not in path (if you just installed you may need to log off and on again).' % + gfortran_min) + print(' You can get a Windows gfortran build from http://sourceforge.net/projects/mingw-w64/') + print(' (get the %s version to match this python installation)' % (('x86_64', 'i686')[is32Bit])) + if is32Bit: + raise IOError('No 32bit Windows DLL provided, you need to build or use 64 bit python') + else: + print('Using pre-compiled binary instead - any local changes will be ignored...') + else: + fpath = get_forutils() + makefile = makefile_dict('Makefile_main') + SOURCES = makefile['SOURCEFILES'].split() + [makefile['CAMBSO'].replace('.f90', '')] + FORUTILS = [os.path.join(fpath, f.replace('.f90', '')) for f in + makefile_dict(os.path.join(fpath, 'Makefile'))['SRCS'].replace('MatrixUtils.f90', + '').split()] + tmpdir = 'WinDLL' + ('', '32')[is32Bit] + if not os.path.isdir(tmpdir): os.mkdir(tmpdir) + modified = False + ofiles = [] + for source in FORUTILS + SOURCES: + # simplest possible Makefile-free make without making full dependencies + fout = os.path.join(tmpdir, os.path.split(source)[1] + '.o') + ofiles += [fout] + if modified or not os.path.exists(fout) or os.path.getmtime(fout) < os.path.getmtime( + source + '.f90'): + modified = True + cmd = COMPILER + ' ' + FFLAGS + ' ' + source + '.f90 -c -o %s -J%s' % (fout, tmpdir) + print(cmd) + if subprocess.call(cmd, shell=True) != 0: + raise IOError('Compilation failed') + if os.path.exists(lib_file): + # raise an exception if the file in use and cannot be deleted + try: + os.remove(lib_file) + except OSError: + raise IOError('dll file in use. Stop python codes and notebook kernels that are using camb.') + print('Compiling sources...') + cmd = COMPILER + ' ' + FFLAGS + ' ' + " ".join(ofiles) + ' -o %s -J%s' % (lib_file, tmpdir) + print(cmd) + if subprocess.call(cmd, shell=True) != 0: + raise IOError('Compilation failed') + else: + get_forutils() + print("Compiling source...") + subprocess.call("make camblib.so PYCAMB_OUTPUT_DIR=%s/camb/ CLUSTER_SAFE=%d" % + (pycamb_path, int(cluster)), shell=True) + subprocess.call("chmod 755 %s" % lib_file, shell=True) + + if not os.path.isfile(os.path.join(pycamb_path, 'camb', DLLNAME)): + sys.exit('Compilation failed') + tem_file = 'HighLExtrapTemplate_lenspotentialCls.dat' + tem = os.path.join(pycamb_path, 'camb', tem_file) + if not os.path.exists(tem) or os.path.getmtime(tem) < os.path.getmtime(tem_file): + shutil.copy(tem_file, tem) + + os.chdir(file_dir) + + +class MakeLibrary(build.__bases__[0], object): + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + make_library(False) + + +class MakeLibraryCluster(MakeLibrary): + + def run(self): + make_library(True) + + class SharedLibrary(build, object): - cluster = False def run(self): - CAMBDIR = os.path.join(file_dir, 'fortran') - pycamb_path = '..' - os.chdir(CAMBDIR) - if is_windows or not check_ifort(): - ok, gfortran_version = check_gfortran(msg=not is_windows) - if is_windows: - COMPILER = "gfortran" - # note that TDM-GCC MingW 5.1 does not work due go general fortran bug. - # This works: http://sourceforge.net/projects/mingw-w64/?source=typ_redirect - # but need to use 32bit compiler to build 32 bit dll (contrary to what is implied) - FFLAGS = "-shared -static -cpp -fopenmp -O3 -fmax-errors=4" - if is32Bit: FFLAGS = "-m32 " + FFLAGS - if not ok: - print( - 'WARNING: gfortran %s or higher not in path (if you just installed you may need to log off and on again).' % - gfortran_min) - print(' You can get a Windows gfortran build from http://sourceforge.net/projects/mingw-w64/') - print(' (get the %s version to match this python installation)' % (('x86_64', 'i686')[is32Bit])) - if is32Bit: - raise IOError('No 32bit Windows DLL provided, you need to build or use 64 bit python') - else: - print('Using pre-compiled binaries instead - any local changes will be ignored...') - else: - fpath = get_forutils() - makefile = makefile_dict('Makefile_main') - SOURCES = makefile['SOURCEFILES'].split() + [makefile['CAMBSO'].replace('.f90', '')] - FORUTILS = [os.path.join(fpath, f.replace('.f90', '')) for f in - makefile_dict(os.path.join(fpath, 'Makefile'))['SRCS'].replace('MatrixUtils.f90', - '').split()] - tmpdir = 'WinDLL' + ('', '32')[is32Bit] - if not os.path.isdir(tmpdir): os.mkdir(tmpdir) - modified = False - ofiles = [] - for source in FORUTILS + SOURCES: - # simplest possible Makefile-free make without making full dependencies - fout = os.path.join(tmpdir, os.path.split(source)[1] + '.o') - ofiles += [fout] - if modified or not os.path.exists(fout) or os.path.getmtime(fout) < os.path.getmtime( - source + '.f90'): - modified = True - cmd = COMPILER + ' ' + FFLAGS + ' ' + source + '.f90 -c -o %s -J%s' % (fout, tmpdir) - print(cmd) - if subprocess.call(cmd, shell=True) != 0: - raise IOError('Compilation failed') - OUTPUT = r"%s\camb\%s" % (pycamb_path, DLLNAME) - if os.path.exists(OUTPUT): - # raise an exception if the file in use and cannot be deleted - try: - os.remove(OUTPUT) - except OSError: - raise IOError('dll file in use. Stop python codes and notebook kernels that are using camb.') - print('Compiling sources...') - cmd = COMPILER + ' ' + FFLAGS + ' ' + " ".join(ofiles) + ' -o %s -J%s' % (OUTPUT, tmpdir) - print(cmd) - if subprocess.call(cmd, shell=True) != 0: - raise IOError('Compilation failed') - subprocess.call(r"copy /Y HighLExtrapTemplate_lenspotentialCls.dat %s\camb" % pycamb_path, shell=True) - if not os.path.isfile(os.path.join(pycamb_path, 'camb', DLLNAME)): - sys.exit('Compilation failed') - else: - get_forutils() - print("Compiling source...") - subprocess.call("make camblib.so PYCAMB_OUTPUT_DIR=%s/camb/ CLUSTER_SAFE=%d" % - (pycamb_path, int(self.cluster)), shell=True) - so_file = os.path.join(pycamb_path, 'camb', 'camblib.so') - if not os.path.isfile(so_file): sys.exit('Compilation failed') - subprocess.call("chmod 755 %s" % so_file, shell=True) - subprocess.call("cp HighLExtrapTemplate_lenspotentialCls.dat %s/camb" % pycamb_path, shell=True) - - os.chdir(file_dir) + make_library(False) build.run(self) class SharedLibraryCluster(SharedLibrary): - cluster = True def run(self): - super(SharedLibraryCluster, self).run() + make_library(True) + build.run(self) class CustomInstall(install): @@ -248,15 +272,6 @@ def run(self): install.run(self) -class CustomSdist(sdist): - def read_template(self): - sdist.read_template(self) - self.filelist.process_template_line('recursive-include fortran Makefile* *.dat *.?90') - - def run(self): - sdist.run(self) - - if __name__ == "__main__": setup(name=os.getenv('CAMB_PACKAGE_NAME', 'camb'), version=find_version(), @@ -264,19 +279,25 @@ def run(self): long_description=get_long_description(), author='Antony Lewis', url="https://camb.info/", - cmdclass={'build': SharedLibrary, 'build_cluster': SharedLibraryCluster, - 'install': CustomInstall, 'sdist': CustomSdist}, + cmdclass={'build': SharedLibrary, 'build_cluster': SharedLibraryCluster, 'install': CustomInstall, + 'make': MakeLibrary, 'make_cluster': MakeLibraryCluster}, packages=['camb', 'camb_tests'], - scripts=['camb.py'], package_data={'camb': [DLLNAME, 'HighLExtrapTemplate_lenspotentialCls.dat', 'PArthENoPE_880.2_marcucci.dat', 'PArthENoPE_880.2_standard.dat', 'PRIMAT_Yp_DH_Error.dat']}, test_suite='camb_tests', + entry_points={ + 'console_scripts': [ + 'camb=camb._command_line:run_command_line', + ]}, classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Operating System :: OS Independent', + 'Intended Audience :: Science/Research', + 'Topic :: Scientific/Engineering :: Astronomy', "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7'