public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/units-llnl] f45: Simplify and modernize packaging
@ 2026-10-01 10:43 Benjamin A. Beasley
  0 siblings, 0 replies; only message in thread
From: Benjamin A. Beasley @ 2026-10-01 10:43 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/units-llnl
            Branch : f45
            Commit : 82af95747d3cc273c16132f549ae4884ac9a5179
            Author : Benjamin A. Beasley <code@musicinmybrain.net>
            Date   : 2026-09-14T17:18:07+01:00
            Stats  : +282/-91 in 7 file(s)
            URL    : https://src.fedoraproject.org/rpms/units-llnl/c/82af95747d3cc273c16132f549ae4884ac9a5179?branch=f45

            Log:
            Simplify and modernize packaging

- Build and run the tests
- Add a man page

---
diff --git a/.gitignore b/.gitignore
index 7f265fe..e2612c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/units-0.13.1.tar.gz
+/units-*.tar.gz

diff --git a/.packit.yaml b/.packit.yaml
deleted file mode 100644
index e5d67fd..0000000
--- a/.packit.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# See the documentation for more information:
-# https://packit.dev/docs/configuration/
-
-upstream_project_url: https://github.com/LLNL/units
-
-jobs:
-  - job: pull_from_upstream
-    trigger: release
-    dist_git_branches:
-      fedora-rawhide
-  - job: koji_build
-    trigger: commit
-    dist_git_branches:
-      - fedora-rawhide

diff --git a/0001-Downstream-only-Use-system-tinyxml2-for-unit-tests.patch b/0001-Downstream-only-Use-system-tinyxml2-for-unit-tests.patch
new file mode 100644
index 0000000..bb94498
--- /dev/null
+++ b/0001-Downstream-only-Use-system-tinyxml2-for-unit-tests.patch
@@ -0,0 +1,77 @@
+From ee990955ffb0931d48516d5b3b5f3db2c49d498d Mon Sep 17 00:00:00 2001
+From: "Benjamin A. Beasley" <code@musicinmybrain.net>
+Date: Mon, 14 Sep 2026 14:26:39 +0100
+Subject: [PATCH] Downstream-only: Use system tinyxml2 for unit tests
+
+Downstream-only because it is much easier to patch this unconditionally
+than to add an option similer to the existing UNITS_USE_EXTERNAL_GTEST
+and make it work properly.
+---
+ test/CMakeLists.txt   | 11 +++--------
+ test/test_ucum.cpp    |  2 +-
+ test/test_udunits.cpp |  2 +-
+ 3 files changed, 5 insertions(+), 10 deletions(-)
+
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index 7211a38..ba6d6d0 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -6,6 +6,7 @@
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 
+ include(AddGoogletest)
++find_package(tinyxml2 REQUIRED)
+ 
+ set(UNIT_TEST_HEADER_ONLY test_conversions1 test_equation_units test_measurement
+                           test_pu test_unit_ops test_uncertain_measurements
+@@ -110,19 +111,13 @@ else()
+         test_siunits PUBLIC -DTEST_FILE_FOLDER="${TEST_FILE_FOLDER}"
+     )
+ 
+-    target_sources(
+-        test_ucum PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty/xml/tinyxml2.cpp
+-                          ${PROJECT_SOURCE_DIR}/ThirdParty/xml/tinyxml2.h
+-    )
++    target_link_libraries(test_ucum tinyxml2)
+     target_include_directories(test_ucum PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty)
+     target_compile_definitions(
+         test_ucum PUBLIC -DTEST_FILE_FOLDER="${TEST_FILE_FOLDER}"
+     )
+ 
+-    target_sources(
+-        test_udunits PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty/xml/tinyxml2.cpp
+-                             ${PROJECT_SOURCE_DIR}/ThirdParty/xml/tinyxml2.h
+-    )
++    target_link_libraries(test_udunits tinyxml2)
+     target_include_directories(test_udunits PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty)
+     target_compile_definitions(
+         test_udunits PUBLIC -DTEST_FILE_FOLDER="${TEST_FILE_FOLDER}"
+diff --git a/test/test_ucum.cpp b/test/test_ucum.cpp
+index 1a0db0f..854e9e5 100644
+--- a/test/test_ucum.cpp
++++ b/test/test_ucum.cpp
+@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-3-Clause
+ 
+ #include "test.hpp"
+ #include "units/units.hpp"
+-#include "xml/tinyxml2.h"
++#include <tinyxml2.h>
+ 
+ #include <cmath>
+ #include <fstream>
+diff --git a/test/test_udunits.cpp b/test/test_udunits.cpp
+index 3261d65..91137a2 100644
+--- a/test/test_udunits.cpp
++++ b/test/test_udunits.cpp
+@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-3-Clause
+ 
+ #include "test.hpp"
+ #include "units/units.hpp"
+-#include "xml/tinyxml2.h"
++#include <tinyxml2.h>
+ 
+ #include <cmath>
+ #include <fstream>
+-- 
+2.55.0
+

diff --git a/packit.yaml b/packit.yaml
new file mode 100644
index 0000000..3ac71a7
--- /dev/null
+++ b/packit.yaml
@@ -0,0 +1,9 @@
+upstream_project_url: https://github.com/LLNL/units
+copy_upstream_release_description: false
+upstream_tag_template: v{version}
+
+jobs:
+  - job: pull_from_upstream
+    trigger: release
+    dist_git_branches:
+      - fedora-rawhide

diff --git a/units-llnl.rpmlintrc b/units-llnl.rpmlintrc
new file mode 100644
index 0000000..c70634c
--- /dev/null
+++ b/units-llnl.rpmlintrc
@@ -0,0 +1,2 @@
+# There really is no documentation specific to these subpackages.
+addFilter(r"units-llnl(-devel)?\..*: no-documentation$")

diff --git a/units-llnl.spec b/units-llnl.spec
index 33d5599..f88f21f 100644
--- a/units-llnl.spec
+++ b/units-llnl.spec
@@ -1,131 +1,198 @@
-%global pypi_name units-llnl
-%bcond python 1
-
 Name:           units-llnl
 Version:        0.13.1
-Release:        %{autorelease}
-Summary:        LLNL units library
-
-%global forgeurl https://github.com/LLNL/units
-%global tag v%{version}
-%forgemeta
-
+%global soname_version 0
+Release:        %autorelease
+Summary:        The Units library
+
+# The entire source is BSD-3-Clause, except:
+#
+# - The source includes a bundled copy of json (nlohmann-json, “JSON for Modern
+#   C++”) in ThirdParty/json.hpp. It is MIT and is removed in %%prep, replaced
+#   with a dependency on the system json package. Since it’s used only for the
+#   tests, its license does not contribute to the licenses of the binary RPMs
+#   even though it is header-only.
+# - The source includes a bundled copy of tinyxlml2 in ThirdParty/xml/. It is
+#   Zlib and is removed in %%prep, replaced with a dependency on the system
+#   tinyxml2 package.
+#
+# Additionally:
+#
+# - The source includes a bundled copy of CLI11 in ThirdParty/CLI11.hpp. It is
+#   is BSD-3-Clause and is removed in %%prep, replaced with a dependency on the
+#   system cli11 package. Since this is a header-only library, its license
+#   still contributes to the license of the binary RPM containing the
+#   command-line tool (that is, the base package). (CLI11 is not used in the
+#   shared library.) Since this is the same license as units-llnl itself, this
+#   doesn’t end up mattering in practice.
+# - Some of the build-system files in ThirdParty/cmake/ have their own license
+#   headers; currently, these are all also BSD-3-Clause, and in any case these
+#   do not contribute to the licenses of the binary RPMs.
 License:        BSD-3-Clause
-# The source tarball includes:
-# - header and source file of tinyxml2 (Zlib)
-# - header of CLI11 (BSD-3-Clause)
-# - header of Niels Lohmann JSON (MIT)
-# Of those only the CLI11 header is used in the code of the units_convert
-# app. All others are exclusively used for the test suite.
-# We remove the shipped CLI11 header and depend on cli11-devel instead.
-SourceLicense:  %license AND Zlib AND MIT
-URL:            %forgeurl
-Source:         %forgesource
+SourceLicense:  %{license} AND MIT AND Zlib
+# While the python3-nanobind package is not a header-only library, it functions
+# rather like one, in that it ships C++ sources that are compiled into
+# extensions that use it. Furthermore, it brings in an indirect dependency on
+# the header-only robin-map library.
+#   - python3-nanobind is BSD-3-Clause
+#   - robin-map-static is MIT
+# Therefore, these licenses also apply to the python3-unit-llnl subpackage.
+%global python_license %{license} AND MIT
+URL:            https://github.com/LLNL/units
+Source0:        %{url}/archive/v%{version}/units-%{version}.tar.gz
+# Man page hand-written for Fedora in groff_man(7) format based on --help
+Source1:        units_convert.1
+
+# Downstream-only: Use system tinyxml2 for unit tests
+#
+# Downstream-only because it is much easier to patch this unconditionally
+# than to add an option similer to the existing UNITS_USE_EXTERNAL_GTEST
+# and make it work properly.
+Patch:          0001-Downstream-only-Use-system-tinyxml2-for-unit-tests.patch
 
 BuildRequires:  cmake
-BuildRequires:  cmake(cli11)
+BuildRequires:  gcc-c++
+
+# Unbundled: for the command-line tool
+# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_packaging_header_only_libraries
+BuildRequires:  cli11-static
+
+# For tests
 BuildRequires:  cmake(gtest)
 BuildRequires:  pkgconfig(gmock)
-BuildRequires:  gcc-c++
+# Unbundled: for tests only
+BuildRequires:  json-static
+BuildRequires:  tinyxml2-devel
 
-%global _description %{expand:
-The Units library provides a means of working with units of measurement
-at runtime, including conversion to and from strings. It provides a
-small number of types for working with units and measurements and
-operations necessary for user input and output with units.}
+# A Python extension built with nanobind uses the C++ sources shipped inside
+# the package, and therefore also the header-only robin-map library. This
+# -static dependency is for tracking, required by guidelines.
+BuildRequires:  robin-map-static
 
-%description %_description
+Requires:       units-llnl-libs%{?_isa} = %{version}-%{release}
+
+%global common_description %{expand:
+The Units library provides a means of working with units of measurement at
+runtime, including conversion to and from strings. It provides a small number
+of types for working with units and measurements and operations necessary for
+user input and output with units.}
+
+%description %{common_description}
+
+
+%package libs
+Summary:        Shared libraries for units-llnl
+
+%description libs %{common_description}
 
 
 %package devel
-Summary:        Development files for %{name}
-Requires:       %{name}%{?_isa} = %{version}-%{release}
+Summary:        Development files for units-llnl
+Requires:       units-llnl-libs%{?_isa} = %{version}-%{release}
 
-%description devel %_description
+%description devel %{common_description}
 
 
-%if %{with python}
-%package -n python3-%{pypi_name}
+%package -n python3-units-llnl
 Summary:        %{summary}
-Requires:       %{name}%{?_isa} = %{version}-%{release}
+License:        %{python_license}
 
-BuildRequires:  python3-devel
-BuildRequires:  python3-nanobind-devel
+Requires:       units-llnl-libs%{?_isa} = %{version}-%{release}
 
-%description -n python3-%{pypi_name} %_description
-%endif
+%description -n python3-units-llnl %{common_description}
 
 
 %prep
-%forgeautosetup -p1
+%autosetup -C -p1
+
+# Unbundle cli11 by replacing the bundled single-header library with a trivial
+# header that re-includes the system copy.
+printf '#include <%s>\n' 'CLI/CLI.hpp' > ThirdParty/CLI11.hpp
 
-%if %{with python}
-# Drop lower bound from nanobind
-sed -r -i 's/(nanobind).*[0-9]\.[0-9]\.[0-9]/\1/' pyproject.toml
+# This should be empty (it’s a git submodule), but let’s make sure:
+rm --recursive --verbose ThirdParty/googletest
 
-# Clean up shipped CLI11 header. It is included in converter/converter.cpp
-# which is the source for the units_convert app.
-# We use the header files from cli11-devel instead.
-rm -vf ThirdParty/CLI11.hpp
-# Fix the include. CLI11.hpp is a standalone bundle of all header files
-# shipped seperately in cli11-devel. Use CLI/CLI.hpp as entry point.
-sed -r -i 's|CLI11\.hpp|CLI/CLI.hpp|' converter/converter.cpp
+# Unbundle tinyxml2
+rm --recursive --verbose ThirdParty/xml
+
+# Unbundle json (nlohmann-json, “JSON for Modern C++”) by replacing the bundled
+# single-header amalgamated copy of the library with a trivial header that
+# re-includes the system copy.
+printf '#include <%s>\n' 'nlohmann/json.hpp' > ThirdParty/json.hpp
+
+# Did we miss anything? All that remains in ThirdParty/ should be .cmake
+# build-system files and headers that we have replaced above.
+[ -z "$(
+  find ThirdParty/ -type f ! -name '*.cmake' ! -name CLI11.hpp ! -name json.hpp
+)" ]
 
 
 %generate_buildrequires
-%pyproject_buildrequires -x test
-%endif
+%pyproject_buildrequires --extras=test
 
 
-%build
-%cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-       -DUNITS_BUILD_SHARED_LIBRARY:BOOL=ON \
-       -DUNITS_ENABLE_TESTS:BOOL=OFF \
-       -DUNITS_BUILD_CONVERTER_APP:BOOL=ON \
-       -DUNITS_ENABLE_SUBMODULE_UPDATE:BOOL=OFF \
-       -DUNITS_USE_EXTERNAL_GTEST:BOOL=ON
+%conf
+%cmake \
+    -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
+    -DUNITS_BUILD_SHARED_LIBRARY:BOOL=ON \
+    -DUNITS_ENABLE_TESTS:BOOL=ON \
+    -DUNITS_BUILD_CONVERTER_APP:BOOL=ON \
+    -DUNITS_ENABLE_SUBMODULE_UPDATE:BOOL=OFF \
+    -DUNITS_USE_EXTERNAL_GTEST:BOOL=ON
+
 
+%build
 %cmake_build
 
-%if %{with python}
-%pyproject_wheel -C cmake.define.UNITS_BUILD_SHARED_LIBRARY:BOOL=ON
-%endif
+# https://scikit-build-core.readthedocs.io/en/latest/configuration/index.html
+%{pyproject_wheel %{shrink:
+    --config-settings=cmake.build-type=RelWithDebInfo
+    --config-settings=cmake.define.UNITS_BUILD_SHARED_LIBRARY:BOOL=ON
+    --config-settings=cmake.define.UNITS_ENABLE_SUBMODULE_UPDATE:BOOL=OFF
+    --config-settings=logging.level=INFO
+    --config-settings=build.verbose=true
+    }}
 
 
 %install
 %cmake_install
 
-%if %{with python}
 %pyproject_install
-%pyproject_save_files -l units_llnl
-%endif
+%pyproject_save_files --assert-license units_llnl
+
+install -D --preserve-timestamps --mode=0644 \
+    --target='%{buildroot}%{_mandir}/man1' '%{SOURCE1}'
 
 
 %check
 %ctest --verbose
 
-%if %{with python}
-# Set LD_LIBRARY_PATH since python module needs acces to libunits
-export LD_LIBRARY_PATH="%{buildroot}%{_libdir}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
-%pytest -r fEs test/python
-%endif
+export LD_LIBRARY_PATH='%{buildroot}%{_libdir}'
+%pyproject_check_import
+%pytest -rs --verbose test/python
 
 
 %files
-%license LICENSE
-%doc NOTICE CONTRIBUTORS.md CONTRIBUTING.md CHANGELOG.md
 %{_bindir}/units_convert
-%{_libdir}/libunits.so.0{,.*}
+%{_mandir}/man1/units_convert.1*
+
+
+%files libs
+%license LICENSE
+%license NOTICE
+%doc CONTRIBUTORS.md
+%doc CHANGELOG.md
+
+%{_libdir}/libunits.so.%{soname_version}{,.*}
+
 
 %files devel
 %{_includedir}/units/
 %{_libdir}/cmake/units/
 %{_libdir}/libunits.so
 
-%if %{with python}
-%files -n python3-%{pypi_name} -f %{pyproject_files}
-%doc CHANGELOG.md python/README.md
-%endif
+
+%files -n python3-units-llnl -f %{pyproject_files}
+%doc python/README.md
 
 
 %changelog

diff --git a/units_convert.1 b/units_convert.1
new file mode 100644
index 0000000..4c9535c
--- /dev/null
+++ b/units_convert.1
@@ -0,0 +1,50 @@
+.TH UNITS_CONVERT "1" "September 2026" "" "User Commands"
+.B units_convert
+\(en application to perform a conversion of a value from one unit to another
+.SH SYNOPSIS
+.B units_convert
+.RI [ OPTIONS ]
+.IR measure ...\:
+.I convert
+.SH OPTIONS
+.SS "POSITIONAL\ ARGUMENTS"
+.TP
+.I measure\fR\ [\fITEXT\fR\ ...]\ ...\ \fIREQUIRED
+Measurement to convert e.g.
+.RB \[oq] 57.4\ m \[cq],
+.RB \[oq] two\ thousand\ GB \[cq],
+.RB \[oq]  45.7*22.2\ feet^3/s^2 \[cq].
+.TP
+.I convert\fR\ \fITEXT\fR\ \fIREQUIRED
+The units to convert the measurement to,
+.RB \[oq] * \[cq]
+to convert to base units.
+.SS "OPTIONAL\ ARGUMENTS"
+.TP
+.B \-h\fR,\ \fB\-\-help
+Print a help message and exit.
+.TP
+.B \-f\fR,\ \fB\-\-full
+Specify that the output should include the measurement and units.
+.TP
+.B \-s\fR,\ \fB\-\-simplified
+Simplify the units using the units library
+.B to_string
+functions and print the conversion string like
+.BR \-\-full .
+This option will take precedence over
+.BR \-\-full .
+.TP
+.B \-\-measurement\fR\ [\fITEXT\fR\ ...]\ ...\ \fIREQUIRED
+Measurement to convert e.g.
+.RB \[oq] 57.4\ m \[cq],
+.RB \[oq] two\ thousand\ GB \[cq],
+.RB \[oq]  45.7*22.2\ feet^3/s^2 \[cq].
+.B \-\-measurement\ \fR[\fITEXT\fR\ ...]\ \...\ \fIREQUIRED
+.B \-\-convert\fR\ \fITEXT\fR\ \fIREQUIRED
+The units to convert the measurement to,
+.RB \[oq] * \[cq]
+to convert to base units.
+.TP
+.B \-v\fR,\ \fB\-\-version
+Display program version information and exit.

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-01 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 10:43 [rpms/units-llnl] f45: Simplify and modernize packaging Benjamin A. Beasley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox