Add platform-python subpackage

This commit is contained in:
Lumír Balhar 2017-08-15 14:42:13 +02:00 committed by Miro Hrončok
parent d884f857bc
commit 41be9f6ac7
2 changed files with 104 additions and 3 deletions

View File

@ -0,0 +1,28 @@
From a69d7fdf52561db56f7c9451872b919db23ee529 Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
Date: Thu, 10 Aug 2017 18:15:42 +0200
Subject: [PATCH] Use `python -m nose` instead of nosetests-<python_version> to
run tests.
This change enables us to build libdnf with various Python version
even with nose available only as a module without binaries.
---
python/hawkey/tests/tests/run_nosetests.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/hawkey/tests/tests/run_nosetests.in b/python/hawkey/tests/tests/run_nosetests.in
index 7b23cca..1361b59 100755
--- a/python/hawkey/tests/tests/run_nosetests.in
+++ b/python/hawkey/tests/tests/run_nosetests.in
@@ -17,7 +17,7 @@ def fatal(msg):
childenv = dict(os.environ)
childenv['PYTHONPATH'] = '${CMAKE_BINARY_DIR}/python/hawkey'
-subprocess.check_call(['nosetests-${PYTHON_MAJOR_DOT_MINOR_VERSION}',
+subprocess.check_call(['${PYTHON_EXECUTABLE}', '-m', 'nose',
'--with-xunit', '--xunit-file=xunit.xml',
'-s', '-v', '${CMAKE_CURRENT_SOURCE_DIR}'],
env=childenv)
--
2.13.4

View File

@ -16,17 +16,21 @@
%bcond_with rhsm
%endif
%bcond_without python2
%bcond_without platform_python
%global _cmake_opts \\\
-DENABLE_RHSM_SUPPORT=%{?with_rhsm:ON}%{!?with_rhsm:OFF} \\\
%{nil}
Name: libdnf
Version: 0.9.3
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: 0001-Use-python-m-nose-instead-of-nosetests-python_versio.patch
BuildRequires: cmake
BuildRequires: gcc
@ -57,6 +61,7 @@ Requires: libsolv-devel%{?_isa} >= %{libsolv_version}
%description devel
Development files for %{name}.
%if %{with python2}
%package -n python2-hawkey
Summary: Python 2 bindings for the hawkey library
%{?python_provide:%python_provide python2-hawkey}
@ -74,11 +79,11 @@ Conflicts: python-dnf < %{dnf_conflict}
%description -n python2-hawkey
Python 2 bindings for the hawkey library.
%endif
%if %{with python3}
%package -n python3-hawkey
Summary: Python 3 bindings for the hawkey library
%{?system_python_abi}
%{?python_provide:%python_provide python3-hawkey}
BuildRequires: python3-devel
BuildRequires: python3-nose
@ -91,18 +96,40 @@ Conflicts: python3-dnf < %{dnf_conflict}
Python 3 bindings for the hawkey library.
%endif
%if %{with platform_python}
%package -n platform-python-hawkey
Summary: Platform Python bindings for the hawkey library
BuildRequires: platform-python-devel
BuildRequires: platform-python-nose
Requires: %{name}%{?_isa} = %{version}-%{release}
# Fix problem with hawkey - dnf version incompatibility
# Can be deleted for distros where only platform-python-dnf >= 2.0.0
Conflicts: platform-python-dnf < %{dnf_conflict}
%description -n platform-python-hawkey
Platform Python bindings for the hawkey library.
%endif
%prep
%autosetup
%autosetup -p1
%if %{with python2}
mkdir build-py2
%endif
%if %{with python3}
mkdir build-py3
%endif
%if %{with platform_python}
mkdir build-platform_python
%endif
%build
%if %{with python2}
pushd build-py2
%cmake -DWITH_MAN=OFF ../ %{!?with_valgrind:-DDISABLE_VALGRIND=1} %{_cmake_opts}
%make_build
popd
%endif
%if %{with python3}
pushd build-py3
@ -111,6 +138,22 @@ pushd build-py3
popd
%endif
%if %{with platform_python}
pushd build-platform_python
export python_so=%{_libdir}/`%{__platform_python} -c 'import sysconfig; print(sysconfig.get_config_var("LDLIBRARY"))'`
export python_include=`%{__platform_python} -c 'import sysconfig; print(sysconfig.get_path("include"))'`
%cmake \
-DPYTHON_EXECUTABLE:FILEPATH=%{__platform_python} \
-DPYTHON_LIBRARY=$python_so \
-DPYTHON_INCLUDE_DIR=$python_include \
-DPYTHON_DESIRED:str=3 \
-DWITH_GIR=1 \
-DWITH_MAN=0 \
-Dgtkdoc=0 ../ %{!?with_valgrind:-DDISABLE_VALGRIND=1} %{_cmake_opts}
%make_build
popd
%endif
%check
if [ "$(id -u)" == "0" ] ; then
cat <<ERROR 1>&2
@ -119,9 +162,12 @@ Please build the package as non-root user.
ERROR
exit 1
fi
%if %{with python2}
pushd build-py2
make ARGS="-V" test
popd
%endif
%if %{with python3}
# Run just the Python tests, not all of them, since
# we have coverage of the core from the first build
@ -130,16 +176,33 @@ pushd build-py3/python/hawkey/tests
popd
%endif
%if %{with platform_python}
# Run just the Python tests, not all of them, since
# we have coverage of the core from the first build
pushd build-platform_python/python/hawkey/tests
make ARGS="-V" test
popd
%endif
%install
%if %{with python2}
pushd build-py2
%make_install
popd
%endif
%if %{with python3}
pushd build-py3
%make_install
popd
%endif
%if %{with platform_python}
pushd build-platform_python
%make_install
popd
%endif
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
@ -156,15 +219,25 @@ popd
%{_includedir}/%{name}/
%{_datadir}/gir-1.0/Dnf-*.gir
%if %{with python2}
%files -n python2-hawkey
%{python2_sitearch}/hawkey/
%endif
%if %{with python3}
%files -n python3-hawkey
%{python3_sitearch}/hawkey/
%endif
%if %{with platform_python}
%files -n platform-python-hawkey
%{platform_python_sitearch}/hawkey/
%endif
%changelog
* Tue Aug 15 2017 Lumír Balhar <lbalhar@redhat.com> - 0.9.3-7
- Add platform-python subpackage
* Fri Aug 11 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.9.3-6
- Rebuilt after RPM update (№ 3)