Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cmbant/CAMB
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiardie committed Jun 10, 2024
2 parents 0610008 + b59e6e0 commit aef4740
Show file tree
Hide file tree
Showing 45 changed files with 6,962 additions and 14,327 deletions.
155 changes: 155 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Wheels

on: [ push, pull_request ]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
if: ${{ startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[pypi]') }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-11, macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ]

steps:
- uses: awvwgk/setup-fortran@main
if: matrix.os == 'windows-latest'
id: setup-fortran
with:
compiler: gcc
version: 11

- run: ln -s $(which gfortran-11) /usr/local/bin/gfortran
if: matrix.os != 'windows-latest'

- run: gfortran --version

- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.18.1

- name: Build macos-13 wheels
if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' || matrix.os == 'flyci-macos-large-latest-m2'
env:
MACOSX_DEPLOYMENT_TARGET: 13
CIBW_BUILD: cp311-*
CIBW_SKIP: pp*
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse

- name: Build macos-12 wheels
if: matrix.os == 'macos-12'
env:
MACOSX_DEPLOYMENT_TARGET: 12
CIBW_BUILD: cp311-*
CIBW_SKIP: pp*
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse

- name: Build macos-11 wheels
if: matrix.os == 'macos-11'
env:
# all cp3xx, since old macs seem to only use osx 11+ builds if this is set not "none"
# see consistency with get_tag() in setup.py
MACOSX_DEPLOYMENT_TARGET: 11
CIBW_SKIP: pp*
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse

- name: Build wheels
if: matrix.os == 'macos-14' || matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest'
env:
MACOSX_DEPLOYMENT_TARGET: 14
CIBW_BUILD: cp311-*
CIBW_SKIP: pp* *-win32 *-manylinux_i686 *musllinux*
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: |
wheelhouse/*.whl
build-sdist-and-upload:
runs-on: ubuntu-latest
needs: [ 'build_wheels' ]
environment: wheels
if: github.repository_owner == 'cmbant'
permissions:
id-token: write

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
cache-dependency-path: "setup.py"

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U build twine
- name: Download wheels from build artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist-wheels/

- name: Build package
run: |
python -m build --sdist
twine check --strict dist/*
twine check --strict dist-wheels/*
- name: Publish wheels to PyPI Test
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist-wheels/

- name: Publish sdist to PyPI Test
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish wheels to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist-wheels/

- name: Publish sdist to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1

test_wheels:
name: Test wheels on ${{ matrix.os }}
if: contains(github.event.head_commit.message, '[testpypi]')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-11, macos-12, macos-13, flyci-macos-large-latest-m2, macos-14, ubuntu-latest, windows-latest ]

steps:
- uses: actions/setup-python@v5

- name: install
run: python -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ camb

- name: test
run: python -m unittest camb.tests.camb_test
16 changes: 9 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"
apt_packages:
- gfortran

python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs

sphinx:
configuration: docs/source/conf.py

formats: all

build:
apt_packages:
- gfortran


submodules:
include: all
34 changes: 11 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ language: python
git:
depth: false

dist: bionic
dist: jammy

branches:
except:
- CAMB_sources
- rayleigh

if: (type != pull_request) OR (type = pull_request AND TRAVIS_PULL_REQUEST_SLUG != 'cmbant/camb')

jobs:
include:
- name: "Ubuntu 20.04 + Python 3.7"
- if: branch !~ ^test.*
name: "Focal + Python 3.7"
dist: focal
addons:
apt:
Expand All @@ -22,7 +25,8 @@ jobs:
python: "3.7"
env:
- PYPI_DIST="true"
- name: "GCC10 + Python 3.10 anaconda"
- if: branch !~ ^test.*
name: "GCC10 + Python 3.10 anaconda"
dist: focal
addons:
apt:
Expand All @@ -34,16 +38,14 @@ jobs:
- PYDIST="ANACONDA"
- FORTRAN="test"
python: "3.10"
- name: "Ubuntu 22.04 + Python 3.11"
dist: jammy
- name: "Jammy + Python 3.12"
addons:
apt:
packages:
- gfortran
env:
- CHANNEL="defaults"
python: "3.11"
- name: "GCC trunk cosmobox"
python: "3.12"
- if: branch !~ ^test.*
name: "GCC trunk cosmobox"
language: shell
services:
- docker
Expand Down Expand Up @@ -89,17 +91,3 @@ script:
after_failure:
- test $TRAVIS_PULL_REQUEST == "false" && test $PYPI_DIST == "true" && test $TRAVIS_REPO_SLUG == "cmbant/CAMB" && [ -d fortran/testfiles ] && bash fortran/tests/upload_tests.sh

before_deploy:
- pushd fortran; make clean delete; popd

deploy:
- provider: pypi
distributions: sdist
username: "cmbant"
password:
secure: "UA+nTWbEND3R/KVodbAG/2xXcCibpotNO+PHBIokR8fm7KmYdjSnXF3OXBDNvFPYEQg2KY7L/JviCbUM9yfZmtekvMg7aKP/2fuHcayByNy5VJ4mUgcA48ft6LKp/sLS/8fn7nCzHbclT/Ye/Wo3PmGK1mQqbu9oxXGidY8C7pbXB9ZYnssdMH9DHXSqjIAL23yN95G8U1n9bVLI0dZB0ORFHro/f7XeIPrzJEdEgql33BSq5YArf7WK/2Vlo8Zk0vPNT1xRJvEdNaJ/VZ5Nk31yuym04ZekmWlBmi+kTsO0zwD4wQrkCFGm9qb31JRHjuRTpxrHUTkiXwTvYutmwNtHqJ3SYkQgoTmb6qi9f4Nha3mtAbRviTDxgVi8Dv4gWp59iXVcOQMhRM9hxiCK7QwMkHJsvss4XuL149eLFLP7TfNw6PwHo/tpMMyRyDBdwgT+Vz0wNUyncEKwsgunxgvct9sy4TKNs96NJ90cTee3ditq/ZmrLjzp0xjQkBW5nA1AiW/9g3KkozkWh0Q74qGR1qrSlKInM7na64zLnp8seRb71Ki+2Ad+gx+fREnTmmgBSTIav4AjQCc+hnEIYnZ57DyNqIaqON25jiL1i85oaAdWLDR5pctWlebmzRcS2PvuvgqB76bvgLnIoHPg8pRm4Li7wvYCQhi9fo9RvR4="
on:
branch: master
repo: cmbant/CAMB
tags: true
condition: $PYPI_DIST = true
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#Dockerfile for running pycamb notebooks with binder
#https://mybinder.org/v2/gh/cmbant/camb/master?filepath=docs%2FCAMBdemo.ipynb

FROM cmbant/cosmobox:gcc9
FROM cmbant/cosmobox:latest


RUN pip install --no-cache --upgrade pip && \
Expand All @@ -26,8 +26,8 @@ RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

WORKDIR ${HOME}
RUN pip install --no-cache-dir notebook==5.*
RUN python setup.py build

RUN pip install --no-cache-dir -e .

WORKDIR ${HOME}
USER ${USER}
USER ${USER}
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Then install using::

pip install -e ./CAMB [--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"
(and other standard setup commands) will build the Fortran library on all systems (including Windows without directly using a Makefile).
You will need gfortran 6 or higher installed to compile (usually included with gcc by default).
If you have gfortran installed, "python setup.py make" (and other standard setup commands) 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 <https://camb.readthedocs.io/en/latest/>`_.

Expand Down
10 changes: 0 additions & 10 deletions camb.py

This file was deleted.

4 changes: 2 additions & 2 deletions camb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Antony Lewis"
__contact__ = "antony at cosmologist dot info"
__url__ = "https://camb.readthedocs.io"
__version__ = "1.5.0"
__version__ = "1.5.5"

from . import baseconfig

Expand All @@ -23,7 +23,7 @@
from . import nonlinear
from .model import CAMBparams, TransferParams
from .results import CAMBdata, MatterTransferData, ClTransferData
from .reionization import TanhReionization
from .reionization import TanhReionization, ExpReionization
from .nonlinear import Halofit
from .dark_energy import DarkEnergyFluid, DarkEnergyPPF
from .initialpower import InitialPowerLaw, SplinedInitialPower
Expand Down
16 changes: 10 additions & 6 deletions camb/_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import struct
import platform
import re
from pkg_resources import parse_version

is_windows = platform.system() == "Windows"

Expand Down Expand Up @@ -38,6 +37,7 @@ def check_ifort():


def check_gfortran(version=gfortran_min, msg=False, retry=False):
from packaging.version import parse as parse_version
global compiler_environ
gfortran_version = get_gfortran_version()
version = str(version)
Expand All @@ -62,13 +62,17 @@ def check_gfortran(version=gfortran_min, msg=False, retry=False):
ver = x.split('-')[1]
if parse_version(best_version) <= parse_version(ver):
best_version = ver
newpath = os.path.join(mingw, x, 'mingw64', 'bin')
bin = os.path.join(mingw, 'bin')
if os.path.exists(bin):
ver = get_gfortran_version('"' + os.path.join(bin, 'gfortran') + '"')
newpath = os.path.join(mingw, x)
if os.path.exists(os.path.join(newpath, 'mingw64', 'bin')):
newpath = os.path.join(newpath, 'mingw64', 'bin')
elif os.path.exists(os.path.join(newpath, 'bin')):
newpath = os.path.join(newpath, 'bin')
bin_path = os.path.join(mingw, 'bin')
if os.path.exists(bin_path):
ver = get_gfortran_version('"' + os.path.join(bin_path, 'gfortran') + '"')
if ver and parse_version(best_version) <= parse_version(ver):
best_version = ver
newpath = bin
newpath = bin_path
if newpath:
if os.path.exists(os.path.join(newpath, 'gfortran.exe')):
if not compiler_environ["PATH"].startswith(newpath):
Expand Down
Loading

0 comments on commit aef4740

Please sign in to comment.