%global srcname myokit # Myokit's code-generation templates under myokit/formats/*/template/ are Python # files with placeholders, so they are not valid Python until rendered. # They must stay as .py files (myokit reads them as text), and rpm's bytecompile # step would otherwise abort the build on the first one. %global _python_bytecompile_errors_terminate_build 0 Name: python-%{srcname} Version: 1.39.2 Release: 1%{?dist} Summary: Modelling and simulation of cardiac cellular electrophysiology # LICENSE.txt is the three-clause BSD text. The bundled Windows sundials # directory carried its own LICENSE (sundials is BSD-3-Clause too); it is # removed in %%prep, see there. License: BSD-3-Clause URL: https://myokit.org # The GitHub tag, not the PyPI sdist: the sdist's MANIFEST.in globs # myokit/tests/*.py only, so it leaves out the two C files # (ansic_event_based_pacing.c, ansic_time_series_pacing.c) that eight pacing # tests read. Source: https://github.com/myokit/myokit/archive/v%{version}/%{srcname}-%{version}.tar.gz BuildArch: noarch BuildRequires: python3-devel # %%check compiles simulations with g++. BuildRequires: gcc-c++ BuildRequires: pyproject-rpm-macros # %%check compiles and runs the C simulations Myokit generates, as users do. BuildRequires: gcc BuildRequires: sundials-devel BuildRequires: python3-pytest BuildRequires: python3-scipy BuildRequires: python3-sympy %global _description %{expand: Myokit is a toolkit for modelling and simulating cardiac cellular electrophysiology. Models, pacing protocols and simulation scripts are written in a small declarative language (.mmt) with units, and Myokit checks them, runs them with CVODES (generating and compiling C on the fly), and exports them to many formats: CellML 1.0, 1.1 and 2.0, SBML, Matlab, Python, C, C++, CUDA, Stan, DiffSL and others. It reads patch-clamp data from Axon and HEKA files, and analyses action potentials and Markov models. Simulating needs a C compiler and the sundials development files at run time, as Brian2 does, so those are Requires. The graphical editor and data viewers need PyQt6 or PySide6.} %description %_description %package -n python3-%{srcname} Summary: %{summary} # Myokit writes C source and builds it with the system compiler against # CVODES when a simulation is first run. Requires: gcc Requires: sundials-devel Recommends: python3-scipy Recommends: python3-sympy Recommends: python3-pyqt6 %description -n python3-%{srcname} %_description %prep %autosetup -p1 -n %{srcname}-%{version} # Prebuilt Windows sundials (sundials_cvodes.dll, sundials_nvecserial.dll, their # import libraries and headers), used only when running on Windows, see # _dynamically_add_embedded_sundials_win() in myokit/_config.py. Binaries that # are not built here must not ship; Fedora uses the system sundials-devel. test -d myokit/_bin/sundials-win-vs rm -r myokit/_bin/sundials-win-vs # 'configparser' is the Python 2 backport name; the standard library has the # module, and Fedora does not provide the PyPI distribution. grep -q "^ 'configparser',$" setup.py || { echo "configparser requirement not found" >&2; exit 1; } sed -i "/^ 'configparser',$/d" setup.py # myokit/gui/__init__.py imports matplotlib.backends.back_qtagg, which does not # exist (the module is backend_qtagg), then falls back to backend_qt5agg, which # matplotlib 3.10 no longer has: the whole GUI raises ModuleNotFoundError on # import. One-word fix; still present on upstream main. grep -q 'matplotlib\.backends\.back_qtagg as' myokit/gui/__init__.py || { echo "back_qtagg not found" >&2; exit 1; } sed -i 's/matplotlib\.backends\.back_qtagg as/matplotlib.backends.backend_qtagg as/' myokit/gui/__init__.py %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install # Template scripts under myokit/formats/ start with "#!/usr/bin/env python", # which Fedora's brp-mangle-shebangs rejects as ambiguous. Point them at python3. find %{buildroot}%{python3_sitelib}/myokit -type f -name '*.py' \ -exec sed -i '1s|^#!/usr/bin/env python$|#!/usr/bin/python3|' {} + %pyproject_save_files -l %{srcname} # Only formats/python/template/sim.py is not valid Python (it starts with - 1.39.2-1 - Initial package: Myokit 1.39.2 (BSD-3-Clause, read from LICENSE.txt). Net-new to Fedora. Pure Python that compiles C at run time, so noarch with gcc and sundials-devel as Requires. - Source is the GitHub tag: the PyPI sdist omits two C files eight tests need. - Removed myokit/_bin/sundials-win-vs, prebuilt Windows DLLs and import libraries bundled for Windows users. - Three %%prep edits for upstream defects: drop the 'configparser' PyPI backport requirement; fix matplotlib.backends.back_qtagg -> backend_qtagg so myokit.gui imports (verified: PyQt6 offscreen imports the IDE and both data viewers; the suite has no GUI tests); the GUI is otherwise untested. - Offline on f44, sundials 7.6.0, gcc 16: 1328 passed, 67 skipped (OpenCL), 1 deselected, 0 failed. CellML 1.0/1.1/2.0 parser and writer tests included. - Not done: the desktop entries, MIME types and syntax file under myokit/_bin/install-lin are not installed, and the OpenCL simulations are untested. - Point the ambiguous '#!/usr/bin/env python' shebangs in the code-generation templates at python3; the first Copr build failed in brp-mangle-shebangs. - Do not let bytecompile errors abort the build: the templates under myokit/formats/*/template/ are not valid Python until rendered, and the second Copr build failed compiling sim.py. - BuildRequires gcc-c++: %%check compiles each simulation and failed on every chroot without g++. - Filter the formats/python/template/__pycache__ entries out of the generated file list: sim.py cannot be bytecompiled, so they are never created. A broader first filter left the other templates' .pyc files unpackaged.