[packages/python-pysnmp] Python 3 support added

jajcus jajcus at pld-linux.org
Wed Oct 30 10:28:07 CET 2013


commit 02af488dfdb40021042964ecf110d846434773c7
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date:   Wed Oct 30 09:05:25 2013 +0100

    Python 3 support added

 python-pysnmp.spec | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 82 insertions(+), 5 deletions(-)
---
diff --git a/python-pysnmp.spec b/python-pysnmp.spec
index cac2e6f..b22a06d 100644
--- a/python-pysnmp.spec
+++ b/python-pysnmp.spec
@@ -1,5 +1,7 @@
 #
 %define		module	pysnmp
+%bcond_without	python2 # CPython 2.x module
+%bcond_without	python3 # CPython 3.x module
 #
 Summary:	SNMP engine for Python
 Summary(pl.UTF-8):	Obsługa SNMP dla Pythona
@@ -11,7 +13,16 @@ Group:		Libraries/Python
 Source0:	http://downloads.sourceforge.net/pysnmp/pysnmp-%{version}.tar.gz
 # Source0-md5:	1f75d3e392a050e84348904fc1be3212
 URL:		http://pysnmp.sourceforge.net/
+%if %{with python2}
 BuildRequires:	python >= 1:2.5
+BuildRequires:	python-distribute
+BuildRequires:	python-modules
+%endif
+%if %{with python3}
+BuildRequires:	python3 >= 1:2.3
+BuildRequires:	python3-distribute
+BuildRequires:	python3-modules
+%endif
 BuildRequires:	rpm-pythonprov
 %pyrequires_eq	python-modules
 Requires:	python-Crypto
@@ -30,11 +41,26 @@ protokołu SNMP. Zawiera procedury służące do zarządzania obiektami MIB
 (Management Information Base), opisanych przez normy SMI (Structure of
 Management Information) v1 i v2.
 
+%package -n python3-%{module}
+Summary:	SNMP engine for Python
+Summary(pl.UTF-8):	Obsługa SNMP dla Pythona
+Group:		Libraries/Python
+
+%description -n python3-%{module}
+This is a set of tools required by the Structure of Management
+Information (SMI v.1 & v.2) to be used in Python programming
+environment. Primarily, they are SNMP engine and MIB compiler.
+
+%description -n python3-%{module} -l pl.UTF-8
+Zestaw narzędzi pozwalających pisać w Pythonie programy korzystające z
+protokołu SNMP. Zawiera procedury służące do zarządzania obiektami MIB
+(Management Information Base), opisanych przez normy SMI (Structure of
+Management Information) v1 i v2.
+
 %package doc
 Summary:	Documentation for Python pysnmp module
 Summary(pl.UTF-8):	Dokumentacja do modułu Pythona pysnmp
 Group:		Libraries/Python
-Requires:	%{name} = %{version}-%{release}
 
 %description doc
 This package contains documentation files for Python pysnmp module.
@@ -54,39 +80,90 @@ This package contains example programs for Python pysnmp module.
 %description examples -l pl.UTF-8
 Ten pakiet zawiera przykładowe programy do modułu Pythona pysnmp.
 
+%package -n python3-%{module}-examples
+Summary:	Example programs for Python pysnmp module
+Summary(pl.UTF-8):	Programy przykładowe do modułu Pythona pysnmp
+Group:		Libraries/Python
+Requires:	python3-%{module} = %{version}-%{release}
+
+%description -n python3-%{module}-examples
+This package contains example programs for Python pysnmp module.
+
+%description -n python3-%{module}-examples -l pl.UTF-8
+Ten pakiet zawiera przykładowe programy do modułu Pythona pysnmp.
+
 %prep
 %setup -q -n %{module}-%{version}
 
 %build
-%{__python} setup.py build
+%if %{with python2}
+%{__python} setup.py build --build-base build-2
+%endif
+
+%if %{with python3}
+%{__python3} setup.py build --build-base build-3 %{?with_tests:test}
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_examplesdir}/%{name}-%{version}}
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_examplesdir}}
 
-%{__python} setup.py install \
+%if %{with python2}
+%{__python} setup.py \
+	build --build-base build-2 \
+	install --skip-build \
 	--optimize=2 \
 	--root=$RPM_BUILD_ROOT
 
 find $RPM_BUILD_ROOT%{py_sitescriptdir} -type f -name "*.py" '!' -path '*/v4/smi/mibs/*' | xargs rm
 
-cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+cp -a examples $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+%endif
+
+%if %{with python3}
+%{__python3} setup.py \
+	build --build-base build-3 \
+	install --skip-build \
+	--optimize=2 \
+	--root=$RPM_BUILD_ROOT
+
+cp -a examples $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
+%endif
+
 install tools/libsmi2pysnmp $RPM_BUILD_ROOT%{_bindir}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %files
 %defattr(644,root,root,755)
 %doc README CHANGES TODO docs/mibs/*
 %attr(755,root,root) %{_bindir}/*
 %{py_sitescriptdir}/%{module}
 %{py_sitescriptdir}/pysnmp-*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc README CHANGES TODO docs/mibs/*
+%{py3_sitescriptdir}/%{module}
+%{py3_sitescriptdir}/pysnmp-*.egg-info
+%endif
 
 %files doc
 %defattr(644,root,root,755)
 %doc docs/*
 
+%if %{with python2}
 %files examples
 %defattr(644,root,root,755)
 %{_examplesdir}/%{name}-%{version}
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}-examples
+%defattr(644,root,root,755)
+%{_examplesdir}/python3-%{module}-%{version}
+%endif
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-pysnmp.git/commitdiff/02af488dfdb40021042964ecf110d846434773c7



More information about the pld-cvs-commit mailing list