Skip to content

Commit c57e3ad

Browse files
EmilyBourneyguclu
andauthored
Fix macOS gfortran installation (pyccel#1857)
Determine the location of the gfortran executable programatically. This fixes a CI failure on macOS caused by a change in HomeBrew's default installation directory. This solution should prevent a similar problem arising again in the future. Fixes pyccel#1856. **Additional changes** - Increase tolerance on symbolic tests to avoid failures. - Use isclose to compare floats instead of ==, which was causing failures in a single unit test. --------- Co-authored-by: Yaman Güçlü <[email protected]>
1 parent abcf694 commit c57e3ad

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.github/actions/macos_install/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ runs:
77
run: |
88
brew install open-mpi
99
brew install libomp
10-
if [[ ! -f "/usr/local/bin/gfortran" ]]; then
11-
gfort=$(ls /usr/local/bin/gfortran-* | tail -n 1)
12-
ln -s ${gfort} /usr/local/bin/gfortran
10+
GFORTRAN_HOME=$(which gfortran || true)
11+
echo "GFORTRAN_HOME : $GFORTRAN_HOME"
12+
if [[ ! -f "$GFORTRAN_HOME" ]]; then
13+
gfort=$(find ${PATH//:/\/ } -name 'gfortran-*' -exec basename {} \; | sort | tail -n 1 || true)
14+
echo "Found $gfort"
15+
gfort_path=$(which ${gfort})
16+
folder=$(dirname ${gfort_path})
17+
ln -s ${gfort_path} ${folder}/gfortran
1318
fi
1419
echo "MPI_OPTS=--oversubscribe" >> $GITHUB_ENV
1520
shell: bash

tests/epyccel/test_epyccel_generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def f(b : 'float[:]'):
120120

121121
f_epyc = epyccel(f, language = language)
122122

123-
assert f(x) == f_epyc(x)
123+
assert np.isclose(f(x), f_epyc(x), rtol=1e-14, atol=1e-14)
124124

125125
@pytest.mark.parametrize( 'language', (
126126
pytest.param("fortran", marks = pytest.mark.fortran),

tests/symbolic/test_symbolic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from pyccel.codegen.codegen import Codegen
1515
from pyccel.errors.errors import Errors
1616

17-
RTOL = 1e-12
18-
ATOL = 1e-16
17+
RTOL = 1e-13
18+
ATOL = 1e-14
1919

2020
base_dir = os.path.dirname(os.path.realpath(__file__))
2121
path_dir = os.path.join(base_dir, 'scripts')

0 commit comments

Comments
 (0)