diff --git a/preprocess.spec b/preprocess.spec index 3c72387..ffa12fb 100644 --- a/preprocess.spec +++ b/preprocess.spec @@ -1,38 +1,35 @@ -%global checkout 6e868bcc692fc46819ac56e1b1fae2d7b272edca -%global date 20170318 - -%if 0%{?fedora} +%if 0%{?fedora} && 0%{?fedora} < 30 %global with_python3 1 -%global python3_pkgversion 3 - -## Make python?_shortver macros -%{!?python2_shortver: %global python2_shortver %(%{__python2} -c 'import sys; print(str(sys.version_info.major) + "." + str(sys.version_info.minor))')} -%{!?python3_shortver: %global python3_shortver %(%{__python3} -c 'import sys; print(str(sys.version_info.major) + "." + str(sys.version_info.minor))')} +%global with_python2 1 %endif -%if 0%{?rhel} && 0%{?rhel} <= 6 -%{!?__python2: %global __python2 /usr/bin/python2} -%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} -%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} -%global with_python3 0 -%global python2_version 2.6 +%if 0%{?fedora} && 0%{?fedora} >= 30 +%global with_python3 1 +%global with_python2 0 %endif -%if 0%{?rhel} && 0%{?rhel} > 6 -%global with_python3 0 -%{!?python2_shortver: %global python2_shortver %(%{__python2} -c 'import sys; print(str(sys.version_info.major) + "." + str(sys.version_info.minor))')} -%{!?python3_shortver: %global python3_shortver %(%{__python3} -c 'import sys; print(str(sys.version_info.major) + "." + str(sys.version_info.minor))')} +%if 0%{?rhel} && 0%{?rhel} >= 7 +%global with_python3 1 +%global with_python2 1 %endif +%global commit 6e868bcc692fc46819ac56e1b1fae2d7b272edca +%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%global date 20170318 + Name: preprocess Summary: A portable multi-language file Python2 preprocessor Version: 1.2.3 -Release: 0.6.%{date}git%(echo %{checkout} | cut -c-6)%{?dist} +Release: 0.7.%{date}git%{shortcommit}%{?dist} License: MIT URL: https://github.com/doconce/preprocess/ -Source0: https://github.com/doconce/preprocess/archive/%{checkout}.zip#/preprocess-%{checkout}.zip +Source0: https://github.com/doconce/preprocess/archive/%{checkout}.zip#/preprocess-%{commit}.zip BuildArch: noarch +%if 0%{?with_python3_other} +BuildRequires: python%{python3_other_pkgversion}-devel +%endif + %description There are millions of templating systems out there (most of them developed for the web). @@ -48,6 +45,7 @@ Languages for which it works include: C++, Python, Perl, Tcl, XML, JavaScript, CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. Preprocess is usable both as a command line app and as a Python module. +%if 0%{?with_python2} %package -n python2-%{name} Summary: A portable multi-language file Python2 preprocessor @@ -55,9 +53,7 @@ Summary: A portable multi-language file Python2 preprocessor BuildRequires: python2-devel BuildRequires: python2-future -%if 0%{?rhel} -BuildRequires: python-setuptools -%endif +BuildRequires: python2-setuptools Provides: preprocess = 0:%{version}-%{release} Obsoletes: preprocess < 0:1.2.2-6 @@ -75,16 +71,18 @@ preprocess.py is targeted at build systems that deal with many types of files. Languages for which it works include: C++, Python, Perl, Tcl, XML, JavaScript, CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. Preprocess is usable both as a command line app and as a Python module. +%endif %if 0%{?with_python3} -%package -n python3-%{name} +%package -n python%{python3_pkgversion}-%{name} Summary: A portable multi-language file Python3 preprocessor -BuildRequires: python3-devel -BuildRequires: python3-future -%{?python_provide:%python_provide python3-%{name}} +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-future +BuildRequires: python%{python3_pkgversion}-setuptools +%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}} -%description -n python3-%{name} +%description -n python%{python3_pkgversion}-%{name} There are millions of templating systems out there (most of them developed for the web). This isn't one of those, though it does share some basics: @@ -100,38 +98,77 @@ CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. Preprocess is usable both as a command line app and as a Python module. %endif # with_python3 +%if 0%{?with_python3_other} +%package -n python%{python3_other_pkgversion}-%{name} +Summary: A portable multi-language file Python3 preprocessor + +BuildRequires: python%{python3_other_pkgversion}-devel +BuildRequires: python%{python3_other_pkgversion}-future +BuildRequires: python%{python3_other_pkgversion}-setuptools +%{?python_provide:%python_provide python%{python3_other_pkgversion}-%{name}} + +%description -n python%{python3_other_pkgversion}-%{name} +There are millions of templating systems out there +(most of them developed for the web). +This isn't one of those, though it does share some basics: +a markup syntax for templates that are processed to give resultant text output. +The main difference with preprocess.py is that its syntax is hidden in comments +(whatever the syntax for comments may be in the target file type) +so that the file can still have valid syntax. +A comparison with the C preprocessor is more apt. + +preprocess.py is targeted at build systems that deal with many types of files. +Languages for which it works include: C++, Python, Perl, Tcl, XML, JavaScript, +CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. +Preprocess is usable both as a command line app and as a Python module. +%endif # with_python3_other + %prep %setup -qc -mv preprocess-%{checkout} python2 +%if 0%{?with_python2} +cp -a preprocess-%{commit} python2 pushd python2 find . -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python2}|' popd +%endif %if 0%{?with_python3} -cp -a python2 python3 +cp -a preprocess-%{commit} python3 find python3 -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python3}|' -find python3 -name '*.py' | xargs sed -i '1s|^#!/usr/bin/python2|#!%{__python3}|' %endif # with_python3 +%if 0%{?with_python3_other} +cp -a preprocess-%{commit} python%{python3_other_pkgversion} +find python%{python3_other_pkgversion} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python3}|' +%endif # with_python3_other + %build %if 0%{?with_python3} pushd python3 -CFLAGS="%{optflags}" %{__python3} setup.py build --executable="%{__python3} -s" +%py3_build popd %endif # with_python3 +%if 0%{?with_python3_other} +pushd python%{python3_other_pkgversion} +%py3_other_build +popd +%endif # with_python3_other + +%if 0%{?with_python2} pushd python2 -CFLAGS="%{optflags}" %{__python2} setup.py build --executable="%{__python2} -s" +%py2_build popd +%endif %install %if 0%{?with_python3} pushd python3 -CFLAGS="%{optflags}" %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +%py3_install mv $RPM_BUILD_ROOT%{_bindir}/preprocess $RPM_BUILD_ROOT%{_bindir}/python%{python3_version}-preprocess -for i in preprocess-3 preprocess-%{?python3_shortver}; do +for i in preprocess-3 preprocess-%{python3_version}; do touch -r $RPM_BUILD_ROOT%{_bindir}/python%{python3_version}-preprocess $i install -p $i $RPM_BUILD_ROOT%{_bindir} ln -sf %{_bindir}/python%{python3_version}-preprocess $RPM_BUILD_ROOT%{_bindir}/$i @@ -142,8 +179,25 @@ popd find $RPM_BUILD_ROOT%{python3_sitelib} -name '*.py' | xargs chmod a+x %endif +%if 0%{?with_python3_other} +pushd python%{python3_other_pkgversion} +%py3_other_install +mv $RPM_BUILD_ROOT%{_bindir}/preprocess $RPM_BUILD_ROOT%{_bindir}/python%{python3_other_version}-preprocess + +for i in preprocess-3 preprocess-%{python3_other_version}; do + touch -r $RPM_BUILD_ROOT%{_bindir}/python%{python3_other_version}-preprocess $i + install -p $i $RPM_BUILD_ROOT%{_bindir} + ln -sf %{_bindir}/python%{python3_other_version}-preprocess $RPM_BUILD_ROOT%{_bindir}/$i +done +popd + +##Fix non-executable script errors +find $RPM_BUILD_ROOT%{python3_other_sitelib} -name '*.py' | xargs chmod a+x +%endif + +%if 0%{?with_python2} pushd python2 -CFLAGS="%{optflags}" %{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +%py2_install mv $RPM_BUILD_ROOT%{_bindir}/preprocess $RPM_BUILD_ROOT%{_bindir}/python%{python2_version}-preprocess for i in preprocess preprocess-2 preprocess-%{python2_version}; do @@ -155,6 +209,7 @@ popd ##Fix non-executable script errors find $RPM_BUILD_ROOT%{python2_sitelib} -name '*.py' | xargs chmod a+x +%endif %check %if 0%{?with_python3} @@ -164,14 +219,23 @@ find . -name '*.pyc' -delete popd %endif +%if 0%{?with_python3_other} +pushd python%{python3_other_pkgversion}/test +find . -name '*.pyc' -delete +%{__python3} test.py test python cpln -v +popd +%endif + +%if 0%{?with_python2} pushd python2 find . -name '*.pyc' -delete cd test %{__python2} test.py test python cpln -v popd +%endif +%if 0%{?with_python2} %files -n python2-%{name} -%{!?_licensedir:%global license %doc} %doc python2/README.md python2/CONTRIBUTORS.txt python2/BUGS.txt python2/TODO.txt %license python2/LICENSE.txt %{_bindir}/preprocess @@ -180,21 +244,37 @@ popd %{_bindir}/python%{python2_version}-preprocess %{python2_sitelib}/preprocess.py* %{python2_sitelib}/*.egg-info +%endif %if 0%{?with_python3} -%files -n python3-%{name} -%{!?_licensedir:%global license %doc} +%files -n python%{python3_pkgversion}-%{name} %doc python3/README.md python3/CONTRIBUTORS.txt python3/BUGS.txt python3/TODO.txt %license python3/LICENSE.txt %{_bindir}/preprocess-3 -%{_bindir}/preprocess-%{?python3_shortver} +%{_bindir}/preprocess-%{python3_version} %{_bindir}/python%{python3_version}-preprocess %{python3_sitelib}/preprocess.py* %{python3_sitelib}/__pycache__/*.py* %{python3_sitelib}/*.egg-info %endif +%if 0%{?with_python3_other} +%files -n python%{python3_other_pkgversion}-%{name} +%doc python%{python3_other_pkgversion}/README.md python%{python3_other_pkgversion}/CONTRIBUTORS.txt python%{python3_other_pkgversion}/BUGS.txt python%{python3_other_pkgversion}/TODO.txt +%license python%{python3_other_pkgversion}/LICENSE.txt +%{_bindir}/preprocess-3 +%{_bindir}/preprocess-%{python3_other_version} +%{_bindir}/python%{python3_other_version}-preprocess +%{python3_other_sitelib}/preprocess.py* +%{python3_other_sitelib}/__pycache__/*.py* +%{python3_other_sitelib}/*.egg-info +%endif + %changelog +* Sat Sep 29 2018 Antonio Trande - 1.2.3-0.7.20170318git6e868b +- Prepare SPEC file for deprecation of Python2 on fedora 30+ +- Prepare SPEC file for Python3-modules packaging on epel7 + * Fri Jul 13 2018 Fedora Release Engineering - 1.2.3-0.6.20170318git6e868b - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild