Skip to content

Commit

Permalink
tidy wheels, min py3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Aug 19, 2024
1 parent 4dc0830 commit 219ddef
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 26 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-12, macos-13, macos-13-xlarge, macos-14, ubuntu-latest, windows-latest ]
os: [ macos-12, macos-13-xlarge, macos-14, ubuntu-latest, windows-latest ]

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

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

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

- run: gfortran --version

Expand Down Expand Up @@ -48,6 +51,7 @@ jobs:
# all cp3xx, since old macs seem to only use osx 12+ builds if this is set not "none"
# see consistency with get_tag() in setup.py
MACOSX_DEPLOYMENT_TARGET: 12
CIBW_BUILD: cp311-*
CIBW_SKIP: pp*
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse
Expand Down Expand Up @@ -83,7 +87,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
cache: pip
cache-dependency-path: "setup.py"

Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ if: (type != pull_request) OR (type = pull_request AND TRAVIS_PULL_REQUEST_SLUG
jobs:
include:
- if: branch !~ ^test.*
name: "Focal + Python 3.7"
name: "Focal + Python 3.8"
dist: focal
addons:
apt:
packages:
- gfortran
python: "3.7"
python: "3.8"
env:
- PYPI_DIST="true"
- if: branch !~ ^test.*
Expand Down
2 changes: 1 addition & 1 deletion camb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__author__ = "Antony Lewis"
__contact__ = "antony at cosmologist dot info"
__url__ = "https://camb.readthedocs.io"
__version__ = "1.5.7"
__version__ = "1.5.8"

from . import baseconfig

Expand Down
6 changes: 2 additions & 4 deletions camb/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ def global_error_message(self):
return bytearray(self._global_error_message).decode('ascii').strip()

def check_global_error(self, reference=''):
code = self.global_error_flag
if code:
err = config.global_error_message()
if code := self.global_error_flag:
self.global_error_flag = 0
if reference:
reference = 'Error in Fortran called from %s:\n' % reference
else:
reference = ''
if err:
if err := config.global_error_message():
raise CAMBError(reference + '%s' % err)
else:
raise CAMBError(reference + 'Error code: %s' % code)
Expand Down
5 changes: 1 addition & 4 deletions camb/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,7 @@ def tensor_power(self, k):
return self.primordial_power(k, 2)

def primordial_power(self, k, ix):
if np.isscalar(k):
karr = np.array([k], dtype=np.float64)
else:
karr = np.array(k, dtype=np.float64)
karr = np.ascontiguousarray([k] if np.isscalar(k) else k, dtype=np.float64)
n = karr.shape[0]
powers = np.empty(n)
self.f_PrimordialPower(karr, powers, byref(c_int(n)), byref(c_int(ix)))
Expand Down
8 changes: 4 additions & 4 deletions camb/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def luminosity_distance(self, z):
"""

if not np.isscalar(z):
z = np.asarray(z)
z = np.ascontiguousarray(z, dtype=np.float64)
return self.angular_diameter_distance(z) * (1.0 + z) ** 2

def h_of_z(self, z):
Expand All @@ -1489,7 +1489,7 @@ def h_of_z(self, z):
:return: H(z)
"""
if not np.isscalar(z):
z = np.array(z, dtype=np.float64)
z = np.ascontiguousarray(z, dtype=np.float64)
arr = np.empty(z.shape)
self.f_HofzArr(arr, z, byref(c_int(z.shape[0])))
return arr
Expand Down Expand Up @@ -1535,7 +1535,7 @@ def physical_time(self, z):
:return: t(z)/Gigayear
"""
if not np.isscalar(z):
z = np.asarray(z, dtype=np.float64)
z = np.ascontiguousarray(z, dtype=np.float64)
return self.physical_time_a1_a2(0, 1.0 / (1 + z))

def conformal_time_a1_a2(self, a1, a2):
Expand Down Expand Up @@ -1567,7 +1567,7 @@ def conformal_time(self, z, presorted=None, tol=None):
if np.isscalar(z):
redshifts = np.array([z], dtype=np.float64)
else:
redshifts = np.array(z, dtype=np.float64)
redshifts = np.asarray(z, dtype=np.float64)
if presorted is True:
redshifts = redshifts[::-1].copy()
elif presorted is None:
Expand Down
10 changes: 9 additions & 1 deletion fortran/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,18 @@ FFLAGS = -O3 $(COMMON_FFLAGS)
DEBUGFLAGS = -g -fbacktrace -ffpe-trap=invalid,overflow,zero -fbounds-check $(COMMON_FFLAGS)
ifeq ($(shell uname -s),Darwin)
SFFLAGS = -dynamiclib #-fpic
ifneq ($(shell echo $(compiler_ver) | awk '{print ($$1 >= 14.0)}'),0)
SFFLAGS += -static-libgfortran -static-libgcc -static-libquadmath
endif
else
SFFLAGS = -shared -fpic
ifneq ($(CIBW_BUILD),)
SFFLAGS += -static-libgfortran -static-libgcc
endif
endif
#SFFLAGS = -shared -fPIC



MODOUT = -J$(OUTPUT_DIR)
SMODOUT = -J$(DLL_DIR)

Expand Down
2 changes: 1 addition & 1 deletion fortran/config.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module config
use constants, only: const_twopi
implicit none

character(LEN=*), parameter :: version = '1.5.7'
character(LEN=*), parameter :: version = '1.5.8'

integer :: FeedbackLevel = 0 !if >0 print out useful information about the model

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ keywords = ['cosmology', 'CAMB', 'CMB']
readme = "docs/README_pypi.rst"
license = { file = "LICENCE.txt" }
dynamic = ["version"]
requires-python = ">=3.7.0"
requires-python = ">=3.8.0"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Astronomy",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ def finalize_options(self):

def get_tag(self):
_, _, plat = super().get_tag()
if "osx_12" in plat:
return _, _, plat
return "py3", "none", plat


Expand Down

0 comments on commit 219ddef

Please sign in to comment.