# PYTHON # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/ # https://python-rpm-porting.readthedocs.io/en/latest/application-modules.html # https://rpmbuildtut.wordpress.com/python-setuptools/ # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages # https://docs.fedoraproject.org/en-US/quick-docs/publish-rpm-on-copr # http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html # https://rpm-software-management.github.io/rpm/manual/macros.html # https://rpm-packaging-guide.github.io/ %global _owner pgnd %global _build_timestamp %( date +%%Y%%m%%d_%%H%%M%%S --utc ) %global _dist .%{_build_timestamp}.%{_owner}.fc%{fedora} # https://stackoverflow.com/questions/47838041/rpmbuild-how-to-disable-check-buildroot # https://rpm-software-management.github.io/rpm/manual/dependency_generators.html # %%global __spec_install_pre /bin/true # %%global __arch_install_post %%{nil} # %%global __os_install_post %%{nil} %global _disable_source_fetch 0 %global debug_package %{nil} # %%undefine _auto_set_build_flags %global _hardened_build 1 # %%global __brp_mangle_shebangs %%{nil} # %%global __brp_strip %%{nil} # %%global __requires_exclude ^.*/xxx/bin/python.*$ # %%global __requires_exclude_from ^.*/xxx/bin/python.*$ # RHEL8 rpmbuild and /usr/lib/.build-id # https://access.redhat.com/discussions/5045161 %global _build_id_links none # %%bcond_with XXX : opt build with XXX; default, without # %%bcond_without XXX : opt build without XXX; default, with # PYZOR # https://github.com/SpamExperts/pyzor # https://www.pyzor.org/en/latest/ # https://src.fedoraproject.org/rpms/pyzor/blob/master/f/pyzor.spec %global _pyz_name pyzor %global _pyz_pkgnm pyzor %global _pyz_comment Collaborative spam filtering system %global _pyz_descrip %{expand: %{_pyz_comment}.} # https://spdx.org/licenses/GPL-2.0-only.html %global _pyzor_license GPL-2.0-only %global _pyz_install_dir /usr/local/postfix-pgnd/pyzor # https://docs.fedoraproject.org/en-US/packaging-guidelines/SourceURL/ %global _pyz0_scm_repo SpamExperts/pyzor %global _pyz0_scm_branch master %global _pyz0_scm_repo_esc %( echo %{_pyz0_scm_repo} | sed 's|_|-|g' | sed 's|/|%2F|g') %global _pyz0_scm_repo_norm %( echo %{_pyz0_scm_repo} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _pyz0_scm_branch_norm %( echo %{_pyz0_scm_branch} | sed 's|_|-|g' | sed 's|/|-|g' ) %global _pyz0_scm_host https://github.com %global _pyz0_scm_host_api https://api.github.com/repos %global _pyz0_scm_url %{_pyz0_scm_host}/%{_pyz0_scm_repo} %global _pyz0_scm_tarball %{_pyz0_scm_host_api}/%{_pyz0_scm_repo}/tarball/%{commit0} # !!NOTE!! GH API tarball extracts to: %global _pyz0_scm_extract_dir %{_pyz0_scm_repo_norm}-%{shortcommit0} %global forgeurl0 %{_pyz0_scm_url} %global commit0 %( git ls-remote %{forgeurl0} | grep /%{_pyz0_scm_branch}$ | cut -f1 ) %global shortcommit0 %( c=%{commit0}; echo ${c} | head -c 7 ) %global forgesource0 %{_pyz0_scm_tarball} %global extractdir0 %{_pyz0_scm_extract_dir} %global forgesetupargs0 -T -D -b 0 -n %{extractdir0} %forgemeta -i -a %global dist %{_dist} # Vendor Pinning Vendor: %{_owner} # NEVRA (n-e:v-r.a) Name: %{_pyz_pkgnm} Epoch: 3 # https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ Version: %{scm0}_%( echo %{_pyz0_scm_branch} | sed 's|-|_|g' ) Release: 0%{?dist} # https://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/ %global _same_evr %{epoch}:%{version}-%{release} Summary: %{_pyz_comment} License: %{_pyz_license} URL: %{forgeurl0} Source0: %{forgesource0} # https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets # https://docs.pagure.org/packaging-guidelines/Packaging:Scriptlets.html BuildRequires: findutils BuildRequires: gcc BuildRequires: pkgconfig(python3) BuildRequires: python3-pytest-cov BuildRequires: python3-redis Provides: %{_pyz_name} = %{_same_evr} Obsoletes: %{_pyz_name} < %{_same_evr} Recommends: postfix-current %description %{_pyz_descrip} %prep echo '##### STARTING PREP #####' %forgesetup -a %build echo '##### STARTING BUILD #####' cd %{_builddir}/%{extractdir0} # https://github.com/kevinconway/rpmvenv # https://stackoverflow.com/questions/60959081/python-script-in-systemd-virtual-environment-or-real-environment python3 -m venv --clear --copies %{_builddir}/%{_pyz_pkgnm}.venv source %{_builddir}/%{_pyz_pkgnm}.venv/bin/activate echo '##### VERIFY VENV #####' pip3 -V # pip 23.2.1 from /builddir/build/BUILD/fangfrisch-5cb2fbb1a5eb24946f5c999af88b87e1a844676d/fangfrisch/lib64/python3.12/site-packages/pip (python 3.12) echo '##### PIP BUILD/INSTALL #####' pip3 -q install --upgrade pip wheel pip3 -q install . pip3 -q cache purge deactivate %install echo '##### STARTING INSTALL #####' cd %{_builddir}/%{extractdir0} # FIX venv SHEBANGS # https://docs.fedoraproject.org/en-US/packaging-guidelines/#_shebang_lines # Deploying python application internally using venv and rpm # https://stackoverflow.com/questions/58088468/deploying-python-application-internally-using-venv-and-rpm sed -i \ "1s|.*|#\!%{_pyz_install_dir}/bin/python3|" \ $(grep -rlni '^#!.*python3' %{_builddir}/%{_pyz_pkgnm}.venv) mkdir -p ${RPM_BUILD_ROOT}/$(dirname %{_pyz_install_dir}) cp -prT \ %{_builddir}/%{_pyz_pkgnm}.venv \ ${RPM_BUILD_ROOT}/%{_pyz_install_dir} # REMOVE git artifacts from pkging find ${RPM_BUILD_ROOT} -name '.gitignore' -type f -exec rm -f {} + %pre %post -e %preun %postun %files # http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html %dir %{_pyz_install_dir} %{_pyz_install_dir}/* %changelog * Wed Nov 13 2024 pgnd _ - bump 1731532934