diff --git a/finddata.spec b/finddata.spec index f2c94e7..138b07b 100644 --- a/finddata.spec +++ b/finddata.spec @@ -1,6 +1,8 @@ %global srcname finddata %global summary Find data files using ONCat %define release 1 +# default python3=python3.9 on rhel9 which is too old +%define python3_pkgversion 3.11 Summary: %{summary} Name: python-%{srcname} @@ -11,9 +13,12 @@ License: MIT Group: Development/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot Prefix: %{_prefix} -BuildArch: noarch / BuildRequires: gcc +BuildArch: noarch Vendor: Pete Peterson Url: https://github.com/neutrons/finddata +Obsoletes: python3-finddata + +Patch1: finddata-pyproject.patch %description Finddata uses ONCat to locate the full path of files on the NScD clusters. @@ -24,41 +29,40 @@ Requires: python%{python3_pkgversion} Requires: python%{python3_pkgversion}-urllib3 Requires: bash Requires: bash-completion -Requires: python%{python3_pkgversion}-argcomplete +#Requires: python%{python3_pkgversion}-argcomplete %{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}} -BuildRequires: python3-devel -BuildRequires: python3-tomli -BuildRequires: python3-wheel +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-wheel +BuildRequires: python%{python3_pkgversion}-pip %description -n python%{python3_pkgversion}-%{srcname} Finddata uses ONCat to locate the full path of files on the NScD clusters. +# unpack tarball and apply patchfile - add -v to see individual commands %prep -%autosetup -p1 -n %{srcname}-%{version} - -%generate_buildrequires -%pyproject_buildrequires +%autosetup -p1 %build %pyproject_wheel %install %pyproject_install -%{__mkdir} -p %{buildroot}/etc/bash_completion.d/ -%{__install} -m 644 finddata.bashcomplete %{buildroot}/etc/bash_completion.d/ -%{__mkdir} -p %{buildroot}%{_bindir}/ +# automatically scan files to install +%pyproject_save_files finddata +# install bash completions +%{__mkdir} -p %{buildroot}%{_sysconfdir}/bash_completion.d/ +%{__install} -m 644 finddata.bashcomplete %{buildroot}%{_sysconfdir}/bash_completion.d/ -# there are no tests -#check -#tox +# there are no tests - check that top level module can be imported +%check +%pyproject_check_import -t %clean rm -rf $RPM_BUILD_ROOT -%files -n python%{python3_pkgversion}-%{srcname} +%files -n python%{python3_pkgversion}-%{srcname} -f %{pyproject_files} %doc README.md %license LICENSE -%{python3_sitelib}/* %{_bindir}/finddata -/etc/bash_completion.d/finddata.bashcomplete +%{_sysconfdir}/bash_completion.d/finddata.bashcomplete diff --git a/pyproject.patch b/pyproject.patch new file mode 100644 index 0000000..f3e503b --- /dev/null +++ b/pyproject.patch @@ -0,0 +1,41 @@ +diff --git a/pyproject.toml b/pyproject.toml +index ac7ebfb..adf8c09 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -1,8 +1,7 @@ + [project] + name = "finddata" + description = "A program to find data files using ONCat" +-dynamic = ["version"] +-#version = "0.10.0" ++version = "0.10.0" + #requires-python = ">=3.10" + dependencies = [ + # list all runtime dependencies here +@@ -23,26 +22,6 @@ requires = [ + ] + build-backend = "setuptools.build_meta" + +-[tool.versioningit.vcs] +-method = "git" +-default-tag = "0.0.1" +- +-[tool.versioningit.next-version] +-method = "minor" +- +-[tool.versioningit.format] +-distance = "{next_version}.dev{distance}" +-dirty = "{version}+d{build_date:%Y%m%d}" +-distance-dirty = "{next_version}.dev{distance}+d{build_date:%Y%m%d}" +- +-[tool.versioningit.write] +-file = "src/finddata/_version.py" +- +-[tool.versioningit.onbuild] +-source-file = "src/finddata/_version.py" +-build-file = "finddata/_version.py" +-replacement = "{next_version}" +- + [tool.setuptools.packages.find] + where = ["src"] + exclude = ["tests*", "scripts*", "docs*", "notebooks*"] diff --git a/rpmbuild.sh b/rpmbuild.sh index d2a0fc4..a36eabe 100755 --- a/rpmbuild.sh +++ b/rpmbuild.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -x # get the version from the spec file SPECFILE="$(dirname "$(realpath "$0")")/finddata.spec" echo "Finding version from ${SPECFILE}" @@ -10,15 +11,30 @@ if [ -z "${VERSION}" ]; then fi echo "Version is ${VERSION}" - # create the tarball echo "building sdist..." python -m build --sdist --outdir . --no-isolation || exit 127 -TARBALL="finddata-${VERSION}.tar.gz" + +TARBALL_SRC="finddata-$(versioningit).tar.gz" # created +TARBALL_TGT="finddata-${VERSION}.tar.gz" # what we want +# fixup the tarball if necessary +if [ "${TARBALL_SRC}" != "${TARBALL_TGT}" ]; then + echo "cleaning up tarball" + rm -rf "finddata-${VERSION}" + mkdir "python-finddata-${VERSION}" + tar xzf "${TARBALL_SRC}" --strip 1 -C "python-finddata-${VERSION}" || exit 127 + rm "${TARBALL_SRC}" + tar czf "${TARBALL_TGT}" "python-finddata-${VERSION}" || exit 127 + rm -rf "python-finddata-${VERSION}" +fi # setup rpm directories for building - renames the tarball mkdir -p "${HOME}"/rpmbuild/SOURCES -cp "${TARBALL}" "${HOME}/rpmbuild/SOURCES/${TARBALL}" || exit 127 +cp "${TARBALL_TGT}" "${HOME}/rpmbuild/SOURCES/${TARBALL_TGT}" || exit 127 +# move the patchfile into position +# it can be created by editing pyproject.toml then having git create it +# git diff -P pyproject.toml > pyproject.patch && git checkout pyproject.toml +cp pyproject.patch "${HOME}/rpmbuild/SOURCES/finddata-pyproject.patch" || exit 127 # build the rpm and give instructions echo "building the rpm" @@ -28,4 +44,4 @@ rpmbuild -ba finddata.spec || exit 127 DIST=$(rpm --eval %{?dist}) echo "========================================" echo "Successfully built rpm. To manually inspect package run" -echo "rpm -qilRp ~/rpmbuild/RPMS/noarch/python3-finddata-${VERSION}-1${DIST}.noarch.rpm" +echo "rpm -qilRp ~/rpmbuild/RPMS/noarch/python3.11-finddata-${VERSION}-1${DIST}.noarch.rpm"