Name: cmdstan Version: 2.39.0 Release: 5%{?dist} Summary: A command-line interface to the STAN library # cmdstan, stan and stan_math are BSD-3-Clause; the rest is the bundled Eigen 3.4.0 License: BSD-3-Clause AND Apache-2.0 AND MPL-2.0 AND Minpack URL: https://mc-stan.org/users/interfaces/cmdstan Source0: https://github.com/stan-dev/cmdstan/releases/download/v%{version}/cmdstan-%{version}.tar.gz #https://github.com/stan-dev/cmdstan/releases/download/v2.20.0/cmdstan-2.20.0.tar.gz #https://github.com/stan-dev/cmdstan/archive/v2.20.0.tar.gz BuildRequires: gcc-c++ BuildRequires: boost-devel # eigen3-devel intentionally NOT used: Stan Math's eigen_plugins.h relies on # Eigen 3.4 macros (EIGEN_EMPTY_STRUCT_CTOR) and indexing semantics that # Fedora's eigen3 5.0.1 (F44+) breaks. Bundled Stan eigen_3.4.0 is kept. Provides: bundled(eigen3) = 3.4.0 # SUNDIALS stays bundled (6.1.1): Stan Math 5 uses the sundials::Context C++ # class from sundials_context.h, which SUNDIALS 7 (Fedora 44+: 7.6) moved to # sundials_context.hpp, and SUNDIALS 7 changed the C API and ABI. The -3 build # set SUNDIALS_INC=/usr/include, yet main.o still compiled against the bundled # 6.1 headers (src/cmdstan/main.d), and it linked Fedora's 7.6 libraries. Provides: bundled(sundials) = 6.1.1 # bin/stanc is not built here: `make build` copies the release tarball's # prebuilt bin/linux-stanc (stanc3, OCaml), which is an x86-64 static binary. # On aarch64 that put an x86-64 /usr/bin/stanc in the RPM (2.39.0-4); the Copr # builder ran it under emulation, so %%check passed, but a real aarch64 machine # cannot compile models. Building stanc3 needs OCaml 4.14 and Jane Street core # v0.16, which Fedora does not ship, so x86_64 only until stanc3 is packaged. ExclusiveArch: x86_64 BuildRequires: tbb-devel BuildRequires: chrpath BuildRequires: binutils BuildRequires: rapidjson-devel BuildRequires: cli11-devel BuildRequires: gtest-devel BuildRequires: google-benchmark-devel # Compiling a model is the point of the package: `make -C %%{_datadir}/cmdstan # /path/model` runs stanc, then g++ against Boost and TBB headers, and links # -ltbb. Requires: make Requires: gcc-c++ Requires: boost-devel Requires: tbb-devel %description Stan is a state-of-the-art platform for statistical modeling and\ high-performance statistical computation. %global debug_package %{nil} %prep %autosetup # Patch for oneTBB compatibility find . -type f \( -name "*.hpp" -o -name "*.cpp" -o -name "*.h" \) -exec sed -i 's|tbb/tbb_stddef.h|tbb/version.h|g' {} + # Patch for system RapidJSON and CLI11 find . -type f \( -name "*.hpp" -o -name "*.cpp" -o -name "*.h" \) -exec sed -i 's|rapidjson_1.1.0/|rapidjson/|g' {} + find . -type f \( -name "*.hpp" -o -name "*.cpp" -o -name "*.h" \) -exec sed -i 's|CLI11/CLI11.hpp|CLI/CLI.hpp|g' {} + # Fix CLI11 2.x API mismatch (remove 4th bool argument from add_option) sed -i 's|, *true)|)|g' src/cmdstan/stansummary.cpp sed -i 's|, *false)|)|g' src/cmdstan/stansummary.cpp # Sometimes it is on a new line sed -i 'N;s|, *\n *true)|)|;P;D' src/cmdstan/stansummary.cpp sed -i 'N;s|, *\n *false)|)|;P;D' src/cmdstan/stansummary.cpp %build # Use system libraries where possible. Keep Eigen bundled (3.4.0): system # eigen3 on F44+ is 5.0.1 and breaks Stan Math's eigen_plugins.h. cat < make/local BOOST = /usr/include RAPIDJSON = /usr/include CLI11 = /usr/include # Use system oneTBB TBB_INTERFACE_NEW = 1 TBB_INC = /usr/include TBB_LIB = %{_libdir} TBB_TARGETS = # The precompiled model header would be written under /usr/share at the # first model build, which users cannot do PRECOMPILED_HEADERS = false # Google Test and Benchmark GTEST = /usr/include BENCHMARK = /usr/include EOF make build %{?_smp_mflags} %check # Basic check. The stanc that ships must be a native binary: an emulated one # passes --version and still breaks every model build (see ExclusiveArch). readelf -h bin/stanc | grep -q 'Machine:.*X86-64' ./bin/stanc --version # Test building a model with our make/local # We need to set STAN_NUM_THREADS=1 or similar to avoid TBB issues in some envs make examples/bernoulli/bernoulli %{?_smp_mflags} %install # Install binaries install -m0755 -d $RPM_BUILD_ROOT%{_bindir} install -m0755 bin/stanc $RPM_BUILD_ROOT%{_bindir} install -m0755 bin/stansummary $RPM_BUILD_ROOT%{_bindir} install -m0755 bin/diagnose $RPM_BUILD_ROOT%{_bindir} # Install the "source" tree needed to build models # Users expect to run make inside this directory or point to it install -m0755 -d $RPM_BUILD_ROOT%{_datadir}/%{name} # cp -a keeps the built objects no older than their sources, so make does not # try to rebuild main.o or the SUNDIALS libraries in the read-only tree. The # top-level makefile is what `make -C` reads; -3 left it out, so no model # could be built. cp -a makefile make src stan $RPM_BUILD_ROOT%{_datadir}/%{name}/ # make expects the tools at bin/ inside the tree install -m0755 -d $RPM_BUILD_ROOT%{_datadir}/%{name}/bin for b in stanc stansummary diagnose; do ln -s ../../../bin/$b $RPM_BUILD_ROOT%{_datadir}/%{name}/bin/$b done # Remove bundled libs from the installed tree to ensure system ones are used, # EXCEPT eigen_* and sundials_* (see the Provides: bundled() above; models # link the SUNDIALS 6.1.1 static libraries built here). find $RPM_BUILD_ROOT%{_datadir}/%{name}/stan/lib/stan_math/lib -maxdepth 1 -type d \ -not -path '*/lib' -not -name 'eigen_*' -not -name 'sundials_*' -exec rm -rf {} + rm -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/stan/lib/rapidjson_1.1.0 # Drop upstream CI configuration from the installed tree. Jenkinsfile is groovy, # so RPM's script-interpreter detection turns it into # Requires: /usr/bin/groovy -- and groovy is not packaged in Fedora, which made # cmdstan UNINSTALLABLE. CI config has no business in a runtime package anyway. # (Two of them: stan/Jenkinsfile and stan/lib/stan_math/Jenkinsfile.) # Found by ci/check-installable.sh. find $RPM_BUILD_ROOT%{_datadir}/%{name} -type f \ \( -name 'Jenkinsfile' -o -name '*.groovy' -o -name '.travis.yml' \) -delete # Provide a default make/local in the installed tree install -m0644 make/local $RPM_BUILD_ROOT%{_datadir}/%{name}/make/local # Fix shebangs manually since macro expansion failed find $RPM_BUILD_ROOT%{_datadir}/%{name} -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/python$|#!/usr/bin/python3|' {} + find $RPM_BUILD_ROOT%{_datadir}/%{name} -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/env python$|#!/usr/bin/python3|' {} + find $RPM_BUILD_ROOT%{_datadir}/%{name} -type f -name "*.py" -exec sed -i 's|^#!/usr/bin/env python3$|#!/usr/bin/python3|' {} + # Remove RPATH if it persists find $RPM_BUILD_ROOT%{_bindir} -type f -exec chrpath --delete {} \; || : %files %license LICENSE %doc README.md %{_bindir}/* %{_datadir}/%{name} %changelog * Sat Nov 07 2026 Morgan Hough - 2.39.0-5 - ExclusiveArch: x86_64. bin/stanc is the tarball's prebuilt x86-64 stanc3, so the aarch64 RPM shipped an x86-64 /usr/bin/stanc and could not compile models on a real aarch64 machine (found on a Raspberry Pi 5; the Copr aarch64 builder ran it under emulation, so %%check passed) - %%check: fail unless bin/stanc is a native x86-64 binary * Sat Nov 07 2026 Morgan Hough - 2.39.0-4 - Make the installed tree build models. -3 could not: the top-level makefile was not shipped, bin/stanc was missing from the tree, and nothing pulled in make, gcc-c++, boost-devel or tbb-devel. Found by compiling a model as a normal user in a clean chroot. - Keep SUNDIALS 6.1.1 bundled: Stan Math 5 does not compile against Fedora's SUNDIALS 7, and main.o had been built on the bundled 6.1 headers while linking the system 7.6 libraries - PRECOMPILED_HEADERS = false, so the first model build does not write into %%{_datadir}/cmdstan * Sat Nov 07 2026 Morgan Hough - 2.39.0-3 - Rebuild in mhough/scientific: math and computational-physics packages move out of mhough/neurofedora - License: SPDX names (was Callaway "BSD"): BSD-3-Clause for cmdstan, stan and stan_math, plus Fedora's eigen3 licence for the bundled Eigen 3.4.0 * Mon Sep 28 2026 Morgan Hough - 2.39.0-2 - Stop shipping upstream CI config, which made cmdstan UNINSTALLABLE. Two Jenkinsfile files were packaged under %%{_datadir}/cmdstan/stan; they are groovy, so RPM's interpreter detection generated Requires: /usr/bin/groovy, and groovy is not packaged in Fedora at all. Nothing failed at build time. Found by ci/check-installable.sh. * Sun Jun 14 2026 Morgan Hough - 2.39.0-1 - Update to 2.39.0 (current upstream; freshness sweep 2026-06-14) * Sat May 23 2026 Morgan G Hough - 2.38.0-2 - Keep bundled Stan eigen_3.4.0 instead of forcing system eigen3: Fedora 44+ ships eigen3 5.0.1 which breaks Stan Math's eigen_plugins.h (EIGEN_EMPTY_STRUCT_CTOR macro + Eigen::all ambiguity, F44 FTBFS build 10504837) - Drop eigen3-devel BuildRequires (no longer needed) - Add Provides: bundled(eigen3) = 3.4.0 * Thu Feb 19 2026 Morgan G Hough - 2.38.0-1 - Update to 2.38.0 * Sat Sep 21 2019 Morgan G Hough - 2.24.0-1 - Initial package