Skip to content

Commit 9b34561

Browse files
authored
Update CI and fix Python builds (#59)
* ci test python: bump python version and actions * maybe fix compile error on MacOS silicon disable error for now (int vs. long in pointer function signature). * typo * try setting flags instead * set C flag (not Fortran flag) * set flag on macos arm64 only * win python build: use flang 5 Like for the conda-forge feedstock: issue with fortran-compiler metapakage? * python win: try fix flang not found * try fix flag path * apply patch from fastscapelib-f2py feedstock
1 parent b4d13f4 commit 9b34561

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

.github/workflows/test-python.yml

+17-12
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ on:
1010

1111
jobs:
1212
unix:
13-
name: 3.8 (${{ matrix.os }})
13+
name: 3.12 (${{ matrix.os }})
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, macos-latest]
1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222

2323
- name: Setup Python
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v5
2525
with:
26-
python-version: '3.8'
26+
python-version: '3.12'
2727

2828
- name: Install Python dependencies
2929
run: |
@@ -50,30 +50,35 @@ jobs:
5050
run: python -c "import sys; sys.path.pop(0); import fastscapelib_fortran"
5151

5252
windows:
53-
name: 3.8 (windows-latest)
53+
name: 3.12 (windows-latest)
5454
runs-on: windows-latest
5555
steps:
5656
- name: Checkout
57-
uses: actions/checkout@v2
57+
uses: actions/checkout@v4
5858

5959
- name: Setup Conda
60-
uses: conda-incubator/setup-miniconda@v2
60+
uses: conda-incubator/setup-miniconda@v3
6161
with:
62-
python-version: 3.8
62+
python-version: 3.12
6363
miniforge-version: latest
6464

6565
- name: Install dependencies
6666
shell: cmd
6767
run: |
68-
conda create -n test python=3.8 cmake c-compiler fortran-compiler scikit-build pip wheel setuptools numpy
68+
conda create -n test python=3.12 cmake c-compiler flang=5.0 scikit-build pip wheel setuptools numpy
69+
70+
- name: Conda env info
71+
shell: cmd
72+
run: >-
73+
conda activate test &&
74+
echo %CONDA% &&
75+
ls %CONDA%\envs\test\Library\bin
6976
7077
- name: Build and install project
7178
shell: cmd
7279
run: >-
7380
conda activate test &&
74-
ls %CONDA%\envs\test &&
75-
ls %CONDA%\envs\test\Library\bin &&
76-
set FC="C:/Miniconda3/envs/test/Library/bin/flang.exe" &&
81+
set FC=%CONDA%\envs\test\Library\bin\flang.exe &&
7782
python setup.py bdist_wheel --dist-dir="dist" -G "NMake Makefiles" -- -DCMAKE_Fortran_COMPILER:FILEPATH="%FC%" &&
7883
python -m pip install --no-index --find-links="dist" fastscapelib_fortran -vvv
7984

CMakeLists.txt

+18-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ set(CMAKE_Fortran_FLAGS_DEBUG
7272
# let F2PY (scikit-build) configure flags for F77 and F90 source
7373
if(NOT SKBUILD)
7474
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect} ${ioflags}")
75+
else()
76+
if(APPLE AND MAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
77+
# https://github.com/numpy/numpy/issues/25869 ?
78+
# (seems problematic only on MacOS Mx)
79+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=incompatible-function-pointer-types")
80+
endif()
7581
endif()
7682

7783
# override flags for old-school F77 files
@@ -147,9 +153,10 @@ if(SKBUILD)
147153
# TODO: remove when https://github.com/scikit-build/scikit-build/pull/495 is merged
148154
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
149155

156+
find_package(PythonLibs REQUIRED)
157+
find_package(PythonExtensions REQUIRED)
150158
find_package(NumPy REQUIRED)
151159
find_package(F2PY REQUIRED)
152-
find_package(PythonExtensions REQUIRED)
153160

154161
set(F2PY_MODULE_NAME "_fastscapelib_fortran")
155162

@@ -158,6 +165,16 @@ if(SKBUILD)
158165
INCLUDE_DIRECTORIES ${FASTSCAPELIB_SRC_DIR}
159166
)
160167

168+
if (UNIX)
169+
if (APPLE)
170+
set_target_properties(${F2PY_MODULE_NAME} PROPERTIES
171+
LINK_FLAGS '-Wl,-dylib,-undefined,dynamic_lookup')
172+
else()
173+
set_target_properties(${F2PY_MODULE_NAME} PROPERTIES
174+
LINK_FLAGS '-Wl,--allow-shlib-undefined')
175+
endif()
176+
endif()
177+
161178
python_extension_module(${F2PY_MODULE_NAME})
162179

163180
install(

cmake/FindF2PY.cmake

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
# case, CMake is not used to find the compiler and configure the associated build system.
6767
#
6868

69-
find_program(F2PY_EXECUTABLE NAMES f2py${PYTHON_VERSION_MAJOR} f2py)
69+
# temporarily disable and force searching the program path through the python numpy module (below)
70+
# (see patch added in https://github.com/conda-forge/fastscapelib-f2py-feedstock/pull/17)
71+
# (see https://github.com/conda-forge/numpy-feedstock/issues/276)
72+
# find_program(F2PY_EXECUTABLE NAMES f2py${PYTHON_VERSION_MAJOR} f2py)
7073

7174
# XXX This is required to support NumPy < v0.15.0. See note in module documentation above.
7275
if(NOT F2PY_EXECUTABLE)

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[build-system]
22
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja", "numpy"]
3+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)