From patchwork Mon Nov 28 09:37:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 699900 X-Patchwork-Delegate: rbryant@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tS1mV4dQ9z9vF7 for ; Mon, 28 Nov 2016 20:37:14 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 69EE67A9; Mon, 28 Nov 2016 09:37:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 2D055415 for ; Mon, 28 Nov 2016 09:37:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 521F314B for ; Mon, 28 Nov 2016 09:37:08 +0000 (UTC) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEEFC31B31F for ; Mon, 28 Nov 2016 09:37:07 +0000 (UTC) Received: from nusiddiq.blr.redhat.com ([10.70.1.226]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAS9b6m7012431; Mon, 28 Nov 2016 04:37:06 -0500 From: Numan Siddique To: ovs dev Organization: Red Hat Message-ID: Date: Mon, 28 Nov 2016 15:07:05 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 28 Nov 2016 09:37:07 +0000 (UTC) X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] rhel: Support building python ovs package with native json impl X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Since building python-openvswitch _json.so requires libopenvswitch.so a separate spec file is added which configures Open vSwitch with --enable-shared flag. The resulting RPM also includes the Open vSwitch shared library. $ rpm -qlp python-openvswitch-2.6.90-1.fc25.x86_64.rpm /usr/lib64/libopenvswitch.so /usr/lib64/libopenvswitch.so.1 /usr/lib64/libopenvswitch.so.1.0.0 /usr/lib64/python2.7/site-packages/ovs /usr/lib64/python2.7/site-packages/ovs-2.6.90-py2.7.egg-info ... /usr/lib64/python2.7/site-packages/ovs/_json.so ... CC: Terry Wilson Signed-off-by: Numan Siddique --- INSTALL.Fedora.rst | 13 +++++ python/setup.py | 9 ++- rhel/automake.mk | 9 +++ rhel/python-openvswitch-fedora.spec.in | 103 +++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 rhel/python-openvswitch-fedora.spec.in diff --git a/INSTALL.Fedora.rst b/INSTALL.Fedora.rst index b9be0ed..40eacfc 100644 --- a/INSTALL.Fedora.rst +++ b/INSTALL.Fedora.rst @@ -83,6 +83,8 @@ This will create the RPMs `openvswitch`, `python-openvswitch`, `openvswitch-ovn-central`, `openvswitch-ovn-host`, `openvswitch-ovn-vtep`, `openvswitch-ovn-docker`, and `openvswitch-debuginfo`. +`python-openvswitch` RPM doesn't include the native json library. + To enable DPDK support in the openvswitch package, the ``--with dpdk`` option can be added: @@ -98,6 +100,17 @@ these tests, the ``--without check`` option can be added: $ make rpm-fedora RPMBUILD_OPT="--without check" +Open vSwitch python binding RPM with native json library +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To build the `python-openvswitch` RPM with native json library, run: + + +:: + $ make rpm-fedora-python-ovs + +This also builds the Open vSwitch shared library and includes it in the RPM. + Kernel OVS Tree Datapath RPM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/python/setup.py b/python/setup.py index 19c1f18..5070c9b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -12,6 +12,7 @@ from __future__ import print_function import sys +import os from distutils.command.build_ext import build_ext from distutils.errors import CCompilerError, DistutilsExecError, \ @@ -33,6 +34,10 @@ ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) if sys.platform == 'win32': ext_errors += (IOError, ValueError) +# Get the include path if defined +include_dirs = os.environ.get('OVS_INCLUDE_DIR', '.') +library_dirs = os.environ.get('OVS_LIB_DIR', '.') + class BuildFailed(Exception): pass @@ -77,7 +82,9 @@ setup_args = dict( 'Programming Language :: Python :: 3.4', ], ext_modules=[setuptools.Extension("ovs._json", sources=["ovs/_json.c"], - libraries=['openvswitch'])], + libraries=['openvswitch'], + include_dirs=[include_dirs], + library_dirs=[library_dirs])], cmdclass={'build_ext': try_build_ext}, ) diff --git a/rhel/automake.mk b/rhel/automake.mk index 45aa9b1..1113fd8 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -23,6 +23,7 @@ EXTRA_DIST += \ rhel/openvswitch.spec.in \ rhel/openvswitch-fedora.spec \ rhel/openvswitch-fedora.spec.in \ + rhel/python-openvswitch-fedora.spec.in \ rhel/usr_share_openvswitch_scripts_sysconfig.template \ rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \ rhel/usr_lib_systemd_system_openvswitch.service \ @@ -62,6 +63,14 @@ rpm-fedora: dist $(srcdir)/rhel/openvswitch-fedora.spec -D "_topdir ${RPMBUILD_TOP}" \ -ba $(srcdir)/rhel/openvswitch-fedora.spec +# Build Python binding RPM with native json +rpm-fedora-python-ovs: dist $(srcdir)/rhel/python-openvswitch-fedora.spec + ${MKDIR_P} ${RPMBUILD_TOP}/SOURCES + cp ${DIST_ARCHIVES} ${RPMBUILD_TOP}/SOURCES + rpmbuild ${RPMBUILD_OPT} \ + -D "_topdir ${RPMBUILD_TOP}" \ + -ba $(srcdir)/rhel/python-openvswitch-fedora.spec + # Build kernel datapath RPM rpm-fedora-kmod: dist $(srcdir)/rhel/openvswitch-kmod-fedora.spec ${MKDIR_P} ${RPMBUILD_TOP}/SOURCES diff --git a/rhel/python-openvswitch-fedora.spec.in b/rhel/python-openvswitch-fedora.spec.in new file mode 100644 index 0000000..cd863d8 --- /dev/null +++ b/rhel/python-openvswitch-fedora.spec.in @@ -0,0 +1,103 @@ +# Spec file for Python Open vSwitch with native json library + +# Copyright (C) 2016 Red Hat, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without warranty of any kind. +# + +# If libcap-ng isn't available and there is no need for running OVS +# as regular user, specify the '--without libcapng' +%bcond_without libcapng + +# Enable PIE, bz#955181 +%global _hardened_build 1 + +# some distros (e.g: RHEL-7) don't define _rundir macro yet +# Fedora 15 onwards uses /run as _rundir +%if 0%{!?_rundir:1} +%define _rundir /run +%endif + +%global pkgname openvswitch +%global srcname openvswitch + +Name: python-%{pkgname} +Summary: Open vSwitch python bindings +Group: System Environment/Daemons +URL: http://www.openvswitch.org/ +Version: @VERSION@ + +# Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the +# lib/sflow*.[ch] files are SISSL +License: ASL 2.0 and LGPLv2+ and SISSL +Release: 1%{?dist} +Source: http://openvswitch.org/releases/%{pkgname}-%{version}.tar.gz + +BuildRequires: autoconf automake libtool +BuildRequires: systemd-units openssl openssl-devel +BuildRequires: python python-twisted-core python-zope-interface python-six +BuildRequires: desktop-file-utils +BuildRequires: groff graphviz +BuildRequires: checkpolicy, selinux-policy-devel +# make check dependencies +BuildRequires: procps-ng +%if %{with libcapng} +BuildRequires: libcap-ng libcap-ng-devel +%endif + +Requires: openssl iproute module-init-tools +Requires: python +Requires: python-six + +%description +Python bindings for the Open vSwitch database + +%prep +rm -rf $RPM_BUILD_DIR/%{pkgname}-%{version} +cp $RPM_SOURCE_DIR/%{pkgname}-%{version}.tar.gz . +tar xzvf %{pkgname}-%{version}.tar.gz + +%build +cd %{pkgname}-%{version} +%configure \ +%if %{with libcapng} + --enable-libcapng \ +%else + --disable-libcapng \ +%endif +%if %{with dpdk} + --with-dpdk=$(dirname %{_datadir}/dpdk/*/.config) \ +%endif + --enable-ssl \ + --with-pkidir=%{_sharedstatedir}/openvswitch/pki \ + --enable-shared + +make %{?_smp_mflags} + +export OVS_INCLUDE_DIR=$PWD/include/ +export OVS_LIB_DIR=$PWD/lib/.libs/ +cd python +%{__python2} setup.py build + +%install +rm -rf $RPM_BUILD_ROOT + +cd %{pkgname}-%{version}/python +%{__python2} setup.py install -O1 --skip-build --root %{buildroot} +cd .. +cp -d lib/.libs/libopenvswitch.so* %{buildroot}/%{_libdir}/ + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%{python2_sitearch}/ovs +%{python2_sitearch}/ovs-%{version}-py?.?.egg-info +%{_libdir}/*.so* + +%changelog +* Fri Nov 25 2016 Numan Siddique +- First build on F25