Blob Blame History Raw
Name:           re2
%global tag 2024-07-02
%global so_version 11
Version:        %(echo '%{tag}' | tr -d -)
Epoch:          1
Release:        3%{?dist}
Summary:        C++ fast alternative to backtracking RE engines

# The entire source is BSD-3-Clause, except:
#   - lib/git/commit-msg.hook is Apache-2.0, but is not used in the build and
#     is removed in %%prep
License:        BSD-3-Clause
URL:            https://github.com/google/re2
Source:         %{url}/archive/%{tag}/re2-%{tag}.tar.gz

BuildRequires:  cmake
BuildRequires:  ninja-build
BuildRequires:  gcc-c++

BuildRequires:  cmake(absl)
BuildRequires:  pkgconfig(icu-uc)
BuildRequires:  cmake(GTest)
BuildRequires:  cmake(benchmark)

# Python extension
BuildRequires:  python3-devel
BuildRequires:  %{py3_dist pybind11}
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_packaging_header_only_libraries
BuildRequires:  pybind11-static

# Python extension tests
BuildRequires:  %{py3_dist pytest}
BuildRequires:  %{py3_dist absl-py}

%global common_description %{expand:
RE2 is a fast, safe, thread-friendly alternative to backtracking regular
expression engines like those used in PCRE, Perl, and Python. It is a C++
library.}

%description %{common_description}


%package        devel
Summary:        C++ header files and library symbolic links for re2

Requires:       re2%{?_isa} = %{epoch}:%{version}-%{release}

%description    devel %{common_description}

This package contains the C++ header files and symbolic links to the shared
libraries for re2. If you would like to develop programs using re2, you will
need to install re2-devel.


%package -n     python3-google-re2
Summary:        RE2 Python bindings

# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_requiring_base_package
Requires:       re2%{?_isa} = %{epoch}:%{version}-%{release}

Conflicts:      python3-fb-re2
Obsoletes:      python3-fb-re2 < 1.0.7-19

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_provides_for_importable_modules
%py_provides python3-re2

%description -n python3-google-re2
A drop-in replacement for the re module.

It uses RE2 under the hood, of course, so various PCRE features (e.g.
backreferences, look-around assertions) are not supported. See
https://github.com/google/re2/wiki/Syntax for the canonical reference, but
known syntactic ”gotchas” relative to Python are:

  • PCRE supports \Z and \z; RE2 supports \z; Python supports \z,
    but calls it \Z. You must rewrite \Z to \z in pattern strings.

Known differences between this module’s API and the re module’s API:

  • The error class does not provide any error information as attributes.
  • The Options class replaces the re module’s flags with RE2’s options as
    gettable/settable properties. Please see re2.h for their documentation.
  • The pattern string and the input string do not have to be the same type.
    Any str will be encoded to UTF-8.
  • The pattern string cannot be str if the options specify Latin-1 encoding.


%prep
%autosetup -n re2-%{tag}
# Show that a file licensed Apache-2.0 is not used in the build and does not
# contribute to the licenses of the binary RPMs:
rm lib/git/commit-msg.hook


%generate_buildrequires
cd python
%pyproject_buildrequires


%build
%cmake \
    -DRE2_BUILD_TESTING:BOOL=ON \
    -DRE2_USE_ICU:BOOL=ON \
    -GNinja
%cmake_build

cat >> python/setup.cfg <<EOF
[build_ext]
include_dirs=${PWD}
library_dirs=${PWD}/%{_vpath_builddir}
EOF
cd python
%pyproject_wheel


%install
%cmake_install

cd python
%pyproject_install
%pyproject_save_files -l re2


%check
%ctest

# Run the tests from the top-level directory to make sure we don’t accidentally
# import the “un-built” package instead of the one in the buildroot.
ln -s python/re2_test.py
LD_LIBRARY_PATH='%{buildroot}%{_libdir}' %pytest re2_test.py


%files
%license LICENSE
%doc README
%{_libdir}/libre2.so.%{so_version}{,.*}


%files          devel
%doc doc/syntax.{html,txt}
%{_includedir}/re2/
%{_libdir}/libre2.so
%{_libdir}/pkgconfig/re2.pc
%{_libdir}/cmake/re2/


%files -n       python3-google-re2 -f %{pyproject_files}


%changelog
* Sun Oct 13 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20240702-3
- Build the Python extension

* Sun Oct 13 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20240702-2
- Enable full Unicode properties support by linking ICU

* Sun Oct 13 2024 Denis Arnaud <denis.arnaud_fedora@m4x.org> - 1:20240702-1
- Upgrade to 2024-07-02
- Incorporate a few minor packaging enhancements from Rawhide

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-16
- Include HTML and text syntax references as devel package documentation

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-14
- Improve the source URL

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-13
- Switch the URL from HTTP to HTTPS

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-12
- Convert License to SPDX

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-11
- Use a simplified description from upstream.

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-10
- Build with ninja instead of make
- This is modestly faster and has no disadvantages

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-9
- Fix unowned directory %%{_libdir}/cmake/re2/

* Sat Oct 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1:20220601-6
- Use CMake to build and run tests; this results in more thorough testing

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1:20220601-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1:20220601-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1:20220601-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1:20220601-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1:20220601-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Nov 30 2022 Denis Arnaud <denis.arnaud_fedora@m4x.org>  - 1:20220601-1
- Upgrade to 2022-06-01

* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:20211101-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1:20211101-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Mon Jan 10 2022 Adam Williamson <awilliam@redhat.com> - 1:20211101-2
- Backport patch to fix thread dependency discovery
- Substitute the pkgconfig file before installing it (#2038572)
- Drop soname patches as upstream seems to be doing it properly now

* Fri Jan 07 2022 Denis Arnaud <denis.arnaud_fedora@m4x.org>  - 1:20211101-1
- Upgrade to 2021-11-01

* Tue Mar 30 2021 Jonathan Wakely <jwakely@redhat.com> - 1:20190801-8
- Rebuilt for removed libstdc++ symbol (#1937698)

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1:20190801-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Aug 26 2020 Jeff Law <law@redhat.com> - 1:20190801-6
- No longer force C++11

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1:20190801-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1:20190801-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Wed Aug 14 2019 Rex Dieter <rdieter@fedoraproject.org> - 1:20190801-3
- -devel: use epoch in versioned dep

* Wed Aug 14 2019 Rex Dieter <rdieter@fedoraproject.org> - 1:20190801-2
- bump soname
- tighten %%files, track soname explicitly
- use %%make_build %%make_install macros
- Epoch:1 for upgrade path (from f29)

* Sat Aug 03 2019 Lukas Vrabec <lvrabec@redhat.com> - 20190801-1
- update to 20190801

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 20160401-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Apr 29 2016 Tom Callaway <spot@fedoraproject.org> - 20160401-2
- hardcode -std=c++11 for older compilers

* Fri Apr 29 2016 Tom Callaway <spot@fedoraproject.org> - 20160401-1
- update to 20160401

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 20131024-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 20131024-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Wed Apr 15 2015 Petr Pisar <ppisar@redhat.com> - 20131024-4
- Rebuild owing to C++ ABI change in GCC-5 (bug #1195351)

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 20131024-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 20131024-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Mon Nov 11 2013 Tom Callaway <spot@fedoraproject.org> - 20131024-1
- update to 20131024
- fix symbols export to stop test from failing

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 20130115-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Sun Feb 17 2013 Denis Arnaud <denis.arnaud_fedora@m4x.org> 20130115-2
- Took into account the feedback from review request (#868578).

* Sun Feb 10 2013 Denis Arnaud <denis.arnaud_fedora@m4x.org> 20130115-1
- The download source comes now directly from the project.

* Thu Oct 25 2012 Denis Arnaud <denis.arnaud_fedora@m4x.org> 0.0.0-2
- Took into account review request (#868578) feedback.

* Sat Oct 20 2012 Denis Arnaud <denis.arnaud_fedora@m4x.org> 0.0.0-1
- RPM release for Fedora 18