diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3b8511 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/cramjam-2.8.1.tar.gz diff --git a/0001-Downstream-only-do-not-strip-the-compiled-Python-ext.patch b/0001-Downstream-only-do-not-strip-the-compiled-Python-ext.patch new file mode 100644 index 0000000..e34d4cd --- /dev/null +++ b/0001-Downstream-only-do-not-strip-the-compiled-Python-ext.patch @@ -0,0 +1,28 @@ +From d9bd99591c52a8114d38e2a799a2f6101410eb4b Mon Sep 17 00:00:00 2001 +From: "Benjamin A. Beasley" +Date: Fri, 2 Feb 2024 12:51:24 -0500 +Subject: [PATCH] Downstream-only: do not strip the compiled Python extension + module + +We need useful debuginfo. Upstream set this intentionally, so this makes +sense to keep downstream-only. +--- + cramjam-python/pyproject.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cramjam-python/pyproject.toml b/cramjam-python/pyproject.toml +index 2a4aa85..16ed5b8 100644 +--- a/cramjam-python/pyproject.toml ++++ b/cramjam-python/pyproject.toml +@@ -14,7 +14,7 @@ requires = ["maturin>=0.14"] + build-backend = "maturin" + + [tool.maturin] +-strip = true ++strip = false + + [project.optional-dependencies] + dev = [ +-- +2.43.0 + diff --git a/ccea06b962959b69596eada330c5acc055a5f195.patch b/ccea06b962959b69596eada330c5acc055a5f195.patch new file mode 100644 index 0000000..7b2d293 --- /dev/null +++ b/ccea06b962959b69596eada330c5acc055a5f195.patch @@ -0,0 +1,30 @@ +From ccea06b962959b69596eada330c5acc055a5f195 Mon Sep 17 00:00:00 2001 +From: Miles +Date: Sat, 3 Feb 2024 10:19:05 +0100 +Subject: [PATCH] Remove relative libcramjam dep for python builds (#131) + +--- + cramjam-cli/Cargo.toml | 2 +- + cramjam-python/Cargo.toml | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cramjam-cli/Cargo.toml b/cramjam-cli/Cargo.toml +index 73ccbbe..633f585 100644 +--- a/cramjam-cli/Cargo.toml ++++ b/cramjam-cli/Cargo.toml +@@ -8,4 +8,4 @@ edition = "2021" + [dependencies] + clap = { version = "^4.2", features = ["derive"] } + bytesize = "^1" +-libcramjam = { path = "../libcramjam" } ++libcramjam = "0.2.0" +diff --git a/cramjam-python/Cargo.toml b/cramjam-python/Cargo.toml +index 8092eb5..20a72b7 100644 +--- a/cramjam-python/Cargo.toml ++++ b/cramjam-python/Cargo.toml +@@ -19,4 +19,4 @@ extension-module = ["pyo3/extension-module"] + + [dependencies] + pyo3 = { version = "^0.20", default-features = false, features = ["macros"] } +-libcramjam = { path = "../libcramjam" } ++libcramjam = "0.2.0" diff --git a/python-cramjam.rpmlintrc b/python-cramjam.rpmlintrc new file mode 100644 index 0000000..204d347 --- /dev/null +++ b/python-cramjam.rpmlintrc @@ -0,0 +1,2 @@ +# “de/compression” +addFilter(r"spelling-error.*'de'") diff --git a/python-cramjam.spec b/python-cramjam.spec new file mode 100644 index 0000000..56f2130 --- /dev/null +++ b/python-cramjam.spec @@ -0,0 +1,109 @@ +%bcond tests 1 + +Name: python-cramjam +Version: 2.8.1 +Release: %autorelease +Summary: Thin Python bindings to de/compression algorithms in Rust + +# SPDX +License: MIT +URL: https://github.com/milesgranger/cramjam +# The PyPI sdist is structured like the git repository, but with pyproject.toml +# moved to the top level from cramjam-python/ and +# manifest-path = "cramjam-python/Cargo.toml" +# added to the [tool.maturin] section. We find it easiest to just build from +# the GitHub source archive. +Source: %{url}/archive/v%{version}/cramjam-%{version}.tar.gz + +# Remove relative libcramjam dep for python builds +# See: https://github.com/milesgranger/cramjam/pull/131 +Patch: %{url}/commit/ccea06b962959b69596eada330c5acc055a5f195.patch +# Do not strip the compiled Python module; we need useful debuginfo. Upstream +# set this intentionally, so this makes sense to keep downstream-only. +Patch: 0001-Downstream-only-do-not-strip-the-compiled-Python-ext.patch + +BuildRequires: python3-devel +BuildRequires: cargo-rpm-macros >= 24 + +%global common_description %{expand: +%{summary}.} + +%description %{common_description} + + +%package -n python3-cramjam +Summary: %{summary} +# 0BSD OR MIT OR Apache-2.0 +# Apache-2.0 +# BSD-3-Clause +# BSD-3-Clause AND MIT +# MIT +# MIT OR Apache-2.0 +# MIT OR Zlib OR Apache-2.0 +License: %{shrink: + (0BSD OR MIT OR Apache-2.0) AND + Apache-2.0 AND + BSD-3-Clause AND + MIT AND + (MIT OR Apache-2.0) AND + (MIT OR Zlib OR Apache-2.0) + } +# LICENSE.dependencies contains a full license breakdown + +%description -n python3-cramjam %{common_description} + + +%prep +%autosetup -n cramjam-%{version} -p1 + +# Downstream-only: patch out linters/formatters/etc. from the “dev” extra so we +# can use it to generate test dependencies. +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters +sed -r -i 's/^([[:blank:]]*)("(black)\b)/\1# \2/' cramjam-python/pyproject.toml + +# Remove bundled rust-libcramjam and the sources for cramjam-cli, which is +# versioned and released separately. Keep only the contents of cramjam-python/ +# and the LICENSE file. +find . -mindepth 1 -maxdepth 1 ! -type d ! -name LICENSE -print -delete +find . -mindepth 1 -maxdepth 1 -type d ! -name cramjam-python \ + -exec rm -rv '{}' '+' + +cd cramjam-python +%cargo_prep + + +%generate_buildrequires +cd cramjam-python +%pyproject_buildrequires %{?with_tests:-x dev} +%cargo_generate_buildrequires + + +%build +export RUSTFLAGS='%{build_rustflags}' +cd cramjam-python +%cargo_license_summary +%{cargo_license} > ../LICENSES.dependencies +%pyproject_wheel + + +%install +cd cramjam-python +%pyproject_install +%pyproject_save_files cramjam + + +%check +cd cramjam-python +%pyproject_check_import +%if %{with tests} +%pytest -v -n auto --ignore-glob='benchmarks/*' +%endif + + +%files -n python3-cramjam -f %{pyproject_files} +%license LICENSE LICENSES.dependencies +%doc cramjam-python/README.md + + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..fe4a995 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (cramjam-2.8.1.tar.gz) = d908a09f52cebe9a5f7638a91158262e4eea4f8faf57e65d7effab734d12442a65823fb04415d4bea9fd7e42c6569c67459605c655284d5189c59038ff9292e4