diff --git a/.gitignore b/.gitignore index 43dc5da..064655e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /cramjam-2.8.1.tar.gz /cramjam-2.8.2.tar.gz /cramjam-2.8.3.tar.gz +/cramjam-6068e8bbb8786c9173b2f0a229032b9ed7452b79-filtered.tar.gz +/cramjam-2.8.4.tar.gz +/cramjam-2.9.0rc1.tar.gz +/cramjam-2.9.0.tar.gz diff --git a/get_source b/get_source new file mode 100755 index 0000000..f2465bf --- /dev/null +++ b/get_source @@ -0,0 +1,49 @@ +#!/bin/sh +set -o errexit +set -o nounset + +if [ "$#" != '1' ] +then + cat 1>&2 < Downloading: ${URL}" 1>&2 +curl -L -O "${URL}" + +ARCHIVE="$(find . -mindepth 1 -maxdepth 1 -type f -name '*.tar.gz' -print -quit)" +echo "--> Extracting: $(basename "${ARCHIVE}")" 1>&2 +tar -xzf "${ARCHIVE}" +echo '--> Removing benchmarks/data/ due to licensing issues' 1>&2 +TARDIR="$(basename "${ARCHIVE}" '.tar.gz')" +MTIME="$(stat -c '%Y' "${TARDIR}")" +rm -rvf "${TARDIR}/benchmarks/data/" +# Make sure the original mtime is preserved even if we modified the base +# directory by removing something at the top level. (So far, we didn’t.) +touch -d @"${MTIME}" "${TARDIR}" +FILTERED="$(basename "${ARCHIVE}" .tar.gz)-filtered.tar.gz" +echo "--> Re-archiving: ${FILTERED}" 1>&2 +# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html +TZ=UTC LC_ALL=C tar \ + --create --verbose \ + --sort=name \ + --format=posix \ + --numeric-owner --owner=0 --group=0 \ + --mode=go+u,go-w \ + --pax-option='delete=atime,delete=ctime' \ + "${TARDIR}/" | + gzip -9 > "${FILTERED}" +mv -v "${FILTERED}" "${OUTDIR}" +echo 'Done.' 1>&2 diff --git a/python-cramjam.spec b/python-cramjam.spec index eca4d93..2cc1139 100644 --- a/python-cramjam.spec +++ b/python-cramjam.spec @@ -1,19 +1,34 @@ %bcond tests 1 Name: python-cramjam -Version: 2.8.3 +Version: 2.9.0 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 + +%if !%{defined commit} + +# This handles pre-release versioning: +%global srcversion %(echo '%{version}' | tr -d '~') +# Future PyPI sdists should not include benchmark data (some of which has +# complicated or unclear license status). See: “Consider excluding benchmarks +# from PyPI sdists” https://github.com/milesgranger/cramjam/issues/178 +Source: %{pypi_source cramjam %{srcversion}} + +%else + +%global srcversion %{commit} +# For snapshots, we must filter the source archive from GitHub using the script +# in Source1, since some of the benchmark data has complicated or unclear +# license status. +Source0: cramjam-%{commit}-filtered.tar.gz +# ./get_source ${COMMIT} (or ${TAG}) +Source1: get_source + +%endif # https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval ExcludeArch: %{ix86} @@ -22,6 +37,15 @@ BuildRequires: python3-devel BuildRequires: tomcli BuildRequires: cargo-rpm-macros >= 24 +%if %{with tests} +# These (along with some unwanted dependencies like linters) are listed in the +# dev extra in pyproject.toml. +BuildRequires: %{py3_dist numpy} +BuildRequires: %{py3_dist pytest} +BuildRequires: %{py3_dist pytest-xdist} +BuildRequires: %{py3_dist hypothesis} +%endif + %global common_description %{expand: %{summary}.} @@ -51,65 +75,89 @@ License: %{shrink: %prep -%autosetup -n cramjam-%{version} +%autosetup -n cramjam-%{srcversion} # Do not strip the compiled Python module; we need useful debuginfo. Upstream # set this intentionally, so this makes sense to keep downstream-only. -tomcli set cramjam-python/pyproject.toml false 'tool.maturin.strip' - -# 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 -tomcli set cramjam-python/pyproject.toml lists delitem --type regex \ - 'project.optional-dependencies.dev' '(black)\b.*' +tomcli set pyproject.toml false 'tool.maturin.strip' +tomcli set pyproject.toml false 'profile.release.strip' # Downstream-only: patch out the generate-import-lib feature, which is only # relevant on Windows, and which depends on the corresponding pyo3 feature – # which is not packaged for that reason. -tomcli set cramjam-python/Cargo.toml del 'features.generate-import-lib' +tomcli set Cargo.toml del 'features.generate-import-lib' -# 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 '{}' '+' +# Downstream-only: remove all the static-linking features, and make the +# dynamic-linking ones default, as we do in rust-libcramjam. +static_features="$( + tomcli get Cargo.toml features -F newline-keys | + grep -E '.-static$' | + tr '\n' ' ' +)" +for sf in ${static_features} +do + tomcli set Cargo.toml del "features.${sf}" + if ! echo "${sf}" | grep -E '^use-system-' >/dev/null + then + binding="$(echo "${sf}" | sed -r 's/-static//')" + tomcli set Cargo.toml lists replace --type regex \ + "features.${binding}" "${binding}-static" "${binding}-shared" + fi +done + +# Downstream-only: patch out the wasm-compat feature, which requires an +# unavailable blosc2 crate feature. +tomcli set Cargo.toml del 'features.wasm32-compat' -cd cramjam-python %cargo_prep %generate_buildrequires -cd cramjam-python -%pyproject_buildrequires %{?with_tests:-x dev} +%pyproject_buildrequires %cargo_generate_buildrequires %build export RUSTFLAGS='%{build_rustflags}' -cd cramjam-python %cargo_license_summary -%{cargo_license} > ../LICENSES.dependencies +%{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/*' +%ifarch s390x +# Even after serious effort by upstream (see +# https://github.com/milesgranger/blosc2-rs/issues/23), several blosc2-rs tests +# still fail on s390x, and therefore blosc2-related tests may also fail in this +# package. Making this package ExcludeArch would have a ripple effect on +# a whole tree of packages that depend on it, and which probably do not even +# use its blosc2 support. We consider that outcome even worse than shipping +# broken blosc2 support on s390x. Note that the endianness issues are probably +# in the C blosc2 library (and that the blosc2 package ignores any and all +# test failures on s390x), and see also: +# https://github.com/Blosc/c-blosc2/issues/467. +# +# […] +# E cramjam.DecompressionError: Blosc2(InvalidHeader) +# […] +# tests/test_variants.py:55: DecompressionError +k="${k-}${k+ and }not test_variants_different_dtypes[blosc2]" +%endif + +%pytest -k "${k-}" -v -n auto %endif %files -n python3-cramjam -f %{pyproject_files} %license LICENSE LICENSES.dependencies -%doc cramjam-python/README.md +%doc README.md %changelog diff --git a/sources b/sources index 4dbee90..ab931f6 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (cramjam-2.8.3.tar.gz) = 26e85bcc09eeef9623bf69f0659e33310c6a0152c3b89572db7e7584319790b682af65733bb863e69204ce1cea37b30de530bb7f1c686e98217f2bf52b81f9d4 +SHA512 (cramjam-2.9.0.tar.gz) = 51b52745ae427274341f364dfc864b9f059cb63704cda61b4f4632ae819f8ead382baf260ee7c55e4f04a0944be032e818be6a21324dff42d454aab06141dd7b