Build python2 and python3 packages

OBS-URL: https://build.opensuse.org/package/show/devel:tools/pam_wrapper?expand=0&rev=12
This commit is contained in:
Andreas Schneider 2018-02-12 11:57:39 +00:00 committed by Git OBS Bridge
parent d9e02580ed
commit 71e03ed8a9
3 changed files with 192 additions and 8 deletions

View File

@ -0,0 +1,159 @@
From 9beb9f9aaa223864128fd8222f0f92ba8ae697b7 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Wed, 22 Nov 2017 15:27:44 +0100
Subject: [PATCH 1/2] cmake: Improve PAM_WRAPPER_LOACATION
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
---
src/CMakeLists.txt | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 713625b..76a87d6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -74,8 +74,4 @@ if (PYTHONLIBS_FOUND)
endif()
# This needs to be at the end
-if (POLICY CMP0026)
- cmake_policy(SET CMP0026 OLD)
-endif()
-get_target_property(PAM_WRAPPER_LOCATION pam_wrapper LOCATION)
-set(PAM_WRAPPER_LOCATION ${PAM_WRAPPER_LOCATION} PARENT_SCOPE)
+set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE)
--
2.16.1
From 84cd3dac56dbcb5815867b02876bb99759aecfd9 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 12 Feb 2018 12:01:22 +0100
Subject: [PATCH 2/2] cmake: Build python2 and python3 modules if possible
Signed-off-by: Andreas Schneider <asn@samba.org>
---
CMakeLists.txt | 5 -----
src/CMakeLists.txt | 4 +---
src/python/CMakeLists.txt | 15 ++-------------
src/python/python2/CMakeLists.txt | 23 +++++++++++++++++++++++
src/python/python3/CMakeLists.txt | 23 +++++++++++++++++++++++
5 files changed, 49 insertions(+), 21 deletions(-)
create mode 100644 src/python/python2/CMakeLists.txt
create mode 100644 src/python/python3/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f03a137..af00610 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,11 +46,6 @@ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source buil
set(CMAKE_THREAD_PREFER_PTHREADS ON)
find_package(Threads)
-find_package(PythonInterp)
-set(Python_ADDITIONAL_VERSIONS 2.6 2.7 3.3 3.4 3.6)
-find_package(PythonLibs)
-find_package(PythonSiteLibs)
-
# config.h checks
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 76a87d6..e3a1efd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -69,9 +69,7 @@ install(TARGETS pamtest
ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
add_subdirectory(modules)
-if (PYTHONLIBS_FOUND)
- add_subdirectory(python)
-endif()
+add_subdirectory(python)
# This needs to be at the end
set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE)
diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
index cbee2a6..3394a84 100644
--- a/src/python/CMakeLists.txt
+++ b/src/python/CMakeLists.txt
@@ -1,15 +1,4 @@
project(pypamtest C)
-include_directories(${CMAKE_BINARY_DIR})
-include_directories(${pam_wrapper-headers_DIR})
-include_directories(${PYTHON_INCLUDE_DIR})
-
-python_add_module(pypamtest pypamtest.c)
-target_link_libraries(pypamtest pamtest ${PYTHON_LIBRARY})
-
-install(
- TARGETS
- pypamtest
- DESTINATION
- ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}
-)
+add_subdirectory(python2)
+add_subdirectory(python3)
diff --git a/src/python/python2/CMakeLists.txt b/src/python/python2/CMakeLists.txt
new file mode 100644
index 0000000..c258d9e
--- /dev/null
+++ b/src/python/python2/CMakeLists.txt
@@ -0,0 +1,23 @@
+project(python2-pamtest C)
+
+unset(PYTHON_EXECUTABLE CACHE)
+
+set(Python_ADDITIONAL_VERSIONS 2.7 2.6)
+find_package(PythonLibs)
+find_package(PythonInterp)
+find_package(PythonSiteLibs)
+
+if (PYTHONLIBS_FOUND)
+ include_directories(${CMAKE_BINARY_DIR})
+ include_directories(${pam_wrapper-headers_DIR})
+ include_directories(${PYTHON_INCLUDE_DIR})
+
+ python_add_module(python2-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c)
+ target_link_libraries(python2-pamtest pamtest ${PYTHON_LIBRARY})
+ set_target_properties(python2-pamtest PROPERTIES OUTPUT_NAME "pypamtest")
+
+ install(TARGETS
+ python2-pamtest
+ DESTINATION
+ ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB})
+endif()
diff --git a/src/python/python3/CMakeLists.txt b/src/python/python3/CMakeLists.txt
new file mode 100644
index 0000000..19a5459
--- /dev/null
+++ b/src/python/python3/CMakeLists.txt
@@ -0,0 +1,23 @@
+project(python3-pamtest C)
+
+unset(PYTHON_EXECUTABLE CACHE)
+
+set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6)
+find_package(PythonLibs)
+find_package(PythonInterp)
+find_package(PythonSiteLibs)
+
+if (PYTHONLIBS_FOUND)
+ include_directories(${CMAKE_BINARY_DIR})
+ include_directories(${pam_wrapper-headers_DIR})
+ include_directories(${PYTHON_INCLUDE_DIR})
+
+ python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c)
+ target_link_libraries(python3-pamtest pamtest ${PYTHON_LIBRARY})
+ set_target_properties(python3-pamtest PROPERTIES OUTPUT_NAME "pypamtest")
+
+ install(TARGETS
+ python3-pamtest
+ DESTINATION
+ ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB})
+endif()
--
2.16.1

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Feb 12 11:56:57 UTC 2018 - asn@cryptomilk.org
- Build python2 and python3 packages
------------------------------------------------------------------- -------------------------------------------------------------------
Sun Feb 4 09:31:44 UTC 2018 - asn@cryptomilk.org Sun Feb 4 09:31:44 UTC 2018 - asn@cryptomilk.org

View File

@ -1,7 +1,7 @@
# #
# spec file for package pam_wrapper # spec file for package pam_wrapper
# #
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -35,13 +35,16 @@ Url: http://cwrap.org/
Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz
Source1: %{name}-rpmlintrc Source1: %{name}-rpmlintrc
# PATCH-FIX-UPSTREAM Build python2 and python3 modules if possible
Patch0: pam_wrapper-1.0.3-build-python2-and-python3-modules.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: doxygen BuildRequires: doxygen
BuildRequires: libcmocka-devel BuildRequires: libcmocka-devel
BuildRequires: pam-devel BuildRequires: pam-devel
BuildRequires: pkg-config
BuildRequires: python-devel
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(python2)
BuildRequires: pkgconfig(python3)
Recommends: pkg-config Recommends: pkg-config
Recommends: cmake Recommends: cmake
@ -89,13 +92,26 @@ Group: Development/Libraries/C and C++
%description -n libpamtest-devel-doc %description -n libpamtest-devel-doc
Documentation for libpamtest development. Documentation for libpamtest development.
%package -n python-libpamtest %package -n python2-libpamtest
Summary: A python wrapper for libpamtest
Group: Development/Libraries/C and C++
Requires: libpamtest0 = %{version}-%{release}
Requires: pam_wrapper = %{version}-%{release}
Obsoletes: python-libpamtest
Provides: python-libpamtest
%description -n python2-libpamtest
If you plan to develop python tests for a PAM module, you can use this
library, which simplifies testing of modules. This subpackage includes
the header files for libpamtest
%package -n python3-libpamtest
Summary: A python wrapper for libpamtest Summary: A python wrapper for libpamtest
Group: Development/Libraries/C and C++ Group: Development/Libraries/C and C++
Requires: libpamtest0 = %{version}-%{release} Requires: libpamtest0 = %{version}-%{release}
Requires: pam_wrapper = %{version}-%{release} Requires: pam_wrapper = %{version}-%{release}
%description -n python-libpamtest %description -n python3-libpamtest
If you plan to develop python tests for a PAM module, you can use this If you plan to develop python tests for a PAM module, you can use this
library, which simplifies testing of modules. This subpackage includes library, which simplifies testing of modules. This subpackage includes
the header files for libpamtest the header files for libpamtest
@ -103,6 +119,8 @@ the header files for libpamtest
%prep %prep
%setup -q %setup -q
%patch0 -p1
%build %build
%cmake \ %cmake \
-DUNIT_TESTING=ON -DUNIT_TESTING=ON
@ -160,8 +178,10 @@ popd
%defattr(-,root,root) %defattr(-,root,root)
%doc build/doc/html %doc build/doc/html
%files -n python-libpamtest %files -n python2-libpamtest
%defattr(-,root,root,-) %{python2_sitearch}/pypamtest.so
%{python_sitearch}/pypamtest.so
%files -n python3-libpamtest
%{python3_sitearch}/pypamtest.so
%changelog %changelog