[python-llvmpy] Support Python3

Sergio Pascual sergiopr at fedoraproject.org
Tue Sep 17 12:05:05 UTC 2013


commit 57132692423e3c39b28d433765122700c029a3d0
Author: Sergio Pascual <sergiopr at fis.ucm.es>
Date:   Tue Sep 17 14:04:49 2013 +0200

    Support Python3

 python-llvmpy.spec |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 2 deletions(-)
---
diff --git a/python-llvmpy.spec b/python-llvmpy.spec
index 4d4fdfb..3063db1 100644
--- a/python-llvmpy.spec
+++ b/python-llvmpy.spec
@@ -1,12 +1,15 @@
 %global upname llvmpy
+%global with_python3 1
 
 Name: python-%{upname}
 Version: 0.12.0
-Release: 4%{?dist}
+Release: 5%{?dist}
 Summary: Python bindings for LLVM
 License: BSD
 
 URL: http://www.llvmpy.org/
+# I'd better have a pypi link here, but it's outdated
+# https://github.com/llvmpy/llvmpy/issues/84
 Source0: https://github.com/llvmpy/llvmpy/archive/%{version}.tar.gz
 
 # bz #1005869
@@ -19,7 +22,18 @@ llvmpy is a Python wrapper around the llvm C++ library which allows simple
 access to compiler tools. 
 
 # we don't want to provide private python extension libs
-%global __provides_exclude_from ^(%{python_sitearch}/.*\\.so)$
+%global __provides_exclude_from ^(%{python_sitearch}|%{python3_sitearch})/.*\\.so$
+
+%if 0%{?with_python3}
+%package -n python3-%{upname}
+Summary: Python bindings for LLVM
+BuildRequires: python3-devel llvm-devel zlib-devel
+BuildRequires: python3-sphinx python3-nose
+
+%description -n python3-%{upname}
+llvmpy is a Python wrapper around the llvm C++ library which allows simple 
+access to compiler tools. 
+%endif # with_python3
 
 %prep
 %setup -qn %{upname}-%{version}
@@ -30,13 +44,41 @@ for i in $(grep -l -r "/usr/bin/env"); do
    done
 popd
 
+%if 0%{?with_python3}
+rm -rf %{py3dir}
+cp -a . %{py3dir}
+find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
+%endif # with_python3
+
+find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'
+
 %build
 CFLAGS="%{optflags}" %{__python} setup.py build
 make %{?_smp_mflags} html -C docs
 # Empty file
 rm docs/_build/html/.buildinfo
 
+%if 0%{?with_python3}
+pushd %{py3dir}
+CFLAGS="%{optflags}" %{__python3} setup.py build
+make %{?_smp_mflags} html -C docs
+# Empty file
+rm docs/_build/html/.buildinfo
+popd
+# workaround to bz 563622
+cp -r %{py3dir}/docs docs-py3
+%endif # with_python3
+
 %install
+%if 0%{?with_python3}
+pushd %{py3dir}
+%{__python3} setup.py install --skip-build --root %{buildroot}
+ pushd %{buildroot}%{python3_sitearch}
+  find -name "*.so" | xargs chmod 755
+ popd
+popd
+%endif # with_python3
+
 %{__python} setup.py install --skip-build --root %{buildroot}
 pushd %{buildroot}%{python_sitearch}
  find -name "*.so" | xargs chmod 755
@@ -47,6 +89,12 @@ pushd %{buildroot}%{python_sitearch}
 %{__python} -c "import llvm; llvm.test()"
 popd
 
+%if 0%{?with_python3}
+pushd %{buildroot}%{python3_sitearch}
+%{__python3} -c "import llvm; llvm.test()"
+popd
+%endif # with_python3
+
 %files
 %doc CHANGELOG README_LLVM_CBUILDER.md LICENSE README.rst docs/_build/html
 %{python_sitearch}/llpython
@@ -56,7 +104,21 @@ popd
 %{python_sitearch}/llvm_cbuilder
 %{python_sitearch}/llvmpy-tag_.%{version}-py2.7.egg-info
 
+%if 0%{?with_python3}
+%files -n python3-%{upname}
+%doc CHANGELOG README_LLVM_CBUILDER.md LICENSE README.rst docs-py3/_build/html
+%{python3_sitearch}/llpython
+%{python3_sitearch}/llvm
+%{python3_sitearch}/llvmpy
+%{python3_sitearch}/llvm_array
+%{python3_sitearch}/llvm_cbuilder
+%{python3_sitearch}/llvmpy-tag_.%{version}-py3.3.egg-info
+%endif # with_python3
+
 %changelog
+* Mon Sep 16 2013 Sergio Pascual <sergiopr at fedoraproject.org> - 0.12.0-5
+- Support Python3
+
 * Mon Sep 09 2013 Sergio Pascual <sergiopr at fedoraproject.org> - 0.12.0-4
 - Use arm macro
 


More information about the scm-commits mailing list