Skip to content

Commit d20f97b

Browse files
FFroehlichdweindl
andauthored
Add conda installation workflow (#2839)
Add GitHub Actions workflow to verify conda installations on Linux and macOS. Fixes crashes on macos under conda related to linking libpython. Adds some CMake debug output. --------- Co-authored-by: Daniel Weindl <[email protected]> Co-authored-by: Daniel Weindl <[email protected]>
1 parent 319efac commit d20f97b

File tree

5 files changed

+79
-23
lines changed

5 files changed

+79
-23
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Conda installation
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '48 4 * * *'
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
conda:
12+
name: Conda installation
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-24.04, macos-latest]
17+
python-version: ['3.11', '3.12', '3.13']
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Miniconda
22+
uses: conda-incubator/setup-miniconda@v3
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
auto-update-conda: true
26+
activate-environment: amici
27+
- name: Install requirements
28+
shell: bash -l {0}
29+
run: |
30+
conda install -c conda-forge compilers cmake
31+
- name: Install AMICI
32+
shell: bash -l {0}
33+
run: |
34+
pip3 install -v ./python/sdist
35+
- name: Show environment
36+
shell: bash -l {0}
37+
run: |
38+
python -c "import os; import pprint; pprint.pprint(dict(os.environ))"
39+
which cmake
40+
which ninja
41+
ls -l /Users/runner/miniconda3/envs/amici/bin || true
42+
- name: Install test dependencies
43+
shell: bash -l {0}
44+
run: |
45+
# Install test extras (pytest, scipy, etc.)
46+
pip3 install pytest pytest-cov scipy h5py antimony
47+
- name: Test import
48+
shell: bash -l {0}
49+
run: |
50+
python -c "from amici import _amici; print(_amici)"
51+
python -m amici
52+
- name: Run SBML import test
53+
shell: bash -l {0}
54+
# FIXME
55+
continue-on-error: true
56+
run: |
57+
cd python/tests
58+
pytest test_sbml_import.py::test_steadystate_simulation -sv

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ cmake_minimum_required(VERSION 3.22)
66
# src/CMakeLists.template.cmake
77
cmake_policy(VERSION 3.22...3.31)
88

9+
# We aren't using C++20 modules, so disable scanning for them to avoid
10+
# clang-scan-deps-notfound errors.
11+
# See also https://discourse.cmake.org/t/cmake-3-28-cmake-cxx-compiler-clang-scan-deps-notfound-not-found/9244/3
12+
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
13+
914
project(amici)
1015

1116
# misc options
@@ -27,6 +32,7 @@ message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
2732
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
2833
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
2934
message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
35+
message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
3036

3137
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3238

doc/python_installation.rst

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,6 @@ Installation under conda
249249
There is no amici conda recipe available yet. However, you can install AMICI
250250
using pip in a conda environment.
251251

252-
.. note::
253-
254-
It is possible, but we currently don't recommend using conda for installing
255-
AMICI, as it commonly leads to conflicts with system installations of
256-
libraries and compilers.
257-
258252
Create a minimal conda environment via:
259253

260254
.. code-block:: bash
@@ -286,25 +280,13 @@ Now, you are ready to use AMICI in the virtual environment.
286280

287281
**conda on Mac**
288282

289-
If the above installation does not work for you, try installing AMICI via:
283+
If the above installation does not work for you, try installing AMICI
284+
using clang compilers provided by conda:
290285

291286
.. code-block:: bash
292287
293-
CFLAGS="-stdlib=libc++" CC=clang CXX=clang pip3 install --verbose amici
294-
295-
This will use the ``clang`` compiler.
296-
297-
You will have to pass the same options when compiling any model later
298-
on. This can be done by inserting the following code before model import:
299-
300-
.. code-block:: python
301-
302-
import os
303-
os.environ['CC'] = 'clang'
304-
os.environ['CXX'] = 'clang'
305-
os.environ['CFLAGS'] = '-stdlib=libc++'
306-
307-
(For further discussion see https://github.com/AMICI-dev/AMICI/issues/357)
288+
conda install -c conda-forge compilers
289+
pip install amici --no-cache
308290
309291
Known issues:
310292

python/sdist/amici/exporters/sundials/templates/CMakeLists.template.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ cmake_policy(VERSION 3.22...3.31)
44

55
project(TPL_MODELNAME)
66

7+
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
8+
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
9+
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
10+
message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
11+
message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
12+
713
set(CMAKE_CXX_STANDARD 20)
814
set(CMAKE_CXX_STANDARD_REQUIRED ON)
915
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

swig/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ find_package(
2020
Python3
2121
COMPONENTS Interpreter Development NumPy
2222
REQUIRED)
23+
message(
24+
STATUS
25+
"Python3_INCLUDE_DIRS: ${Python3_INCLUDE_DIRS}; Python3_LIBRARIES: ${Python3_LIBRARIES}"
26+
)
2327
message(
2428
STATUS
2529
"Found numpy ${Python3_NumPy_VERSION} include dir ${Python3_NumPy_INCLUDE_DIRS}"
@@ -112,7 +116,7 @@ set_target_properties(
112116
# NOTE: No public definitions of any dependency are forwarded to swig, they are
113117
# only used for compiling the swig-generated source file. Any definition that
114118
# are relevant for swig-code generation, need to be forwarded manually.
115-
target_link_libraries(_amici amici Python3::Python)
119+
target_link_libraries(_amici amici Python3::Module)
116120
if(WIN32)
117121
add_custom_command(
118122
TARGET _amici

0 commit comments

Comments
 (0)