[ovs-dev,v1,1/1] Build the JSON C extension for the Python lib
diff mbox

Message ID 20170817191413.31390-1-twilson@redhat.com
State Deferred
Delegated to: Russell Bryant
Headers show

Commit Message

Terry Wilson Aug. 17, 2017, 7:14 p.m. UTC
The JSON C extensions performs much better than the pure Python
version, so build it when producing RPMs.

Signed-off-by: Terry Wilson <twilson@redhat.com>
---
 rhel/openvswitch-fedora.spec.in | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

Comments

Ben Pfaff Oct. 31, 2017, 7:55 p.m. UTC | #1
On Thu, Aug 17, 2017 at 02:14:13PM -0500, Terry Wilson wrote:
> The JSON C extensions performs much better than the pure Python
> version, so build it when producing RPMs.
> 
> Signed-off-by: Terry Wilson <twilson@redhat.com>

Hi Russell, would you mind taking a look at this?  It is Pythonic and
touches only the RHEL directory, so I don't feel entirely qualified to
review it.
Russell Bryant Dec. 5, 2017, 6:49 p.m. UTC | #2
On Tue, Oct 31, 2017 at 3:55 PM, Ben Pfaff <blp@ovn.org> wrote:
> On Thu, Aug 17, 2017 at 02:14:13PM -0500, Terry Wilson wrote:
>> The JSON C extensions performs much better than the pure Python
>> version, so build it when producing RPMs.
>>
>> Signed-off-by: Terry Wilson <twilson@redhat.com>
>
> Hi Russell, would you mind taking a look at this?  It is Pythonic and
> touches only the RHEL directory, so I don't feel entirely qualified to
> review it.

I'm sorry for letting this sit so long.  I seem to recall there were
some concerns with this, so I never really got into it.

Terry - can you please recap the status of this patch?  Do you feel
it's ready as-is, or was there more work that needs to be done?

Patch
diff mbox

diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index 59e8ff8..29982e8 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -125,9 +125,9 @@  Tailored Open vSwitch SELinux policy
 %package -n %{_py2}-openvswitch
 Summary: Open vSwitch python2 bindings
 License: ASL 2.0
-BuildArch: noarch
 Requires: %{_py2}
 Requires: %{_py2}-six
+Requires: openvswitch-devel
 %{?python_provide:%python_provide python2-openvswitch = %{version}-%{release}}
 %description -n %{_py2}-openvswitch
 Python bindings for the Open vSwitch database
@@ -136,9 +136,9 @@  Python bindings for the Open vSwitch database
 %package -n python3-openvswitch
 Summary: Open vSwitch python3 bindings
 License: ASL 2.0
-BuildArch: noarch
 Requires: python3
 Requires: python3-six
+Requires: openvswitch-devel
 %{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}}
 
 %description -n python3-openvswitch
@@ -227,7 +227,8 @@  Docker network plugins for OVN.
 	--with-dpdk=$(dirname %{_datadir}/dpdk/*/.config) \
 %endif
 	--enable-ssl \
-	--with-pkidir=%{_sharedstatedir}/openvswitch/pki
+	--with-pkidir=%{_sharedstatedir}/openvswitch/pki \
+	--enable-shared
 
 /usr/bin/perl build-aux/dpdkstrip.pl \
 %if %{with dpdk}
@@ -283,14 +284,25 @@  install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
 
 install -d -m 0755 $RPM_BUILD_ROOT%{python2_sitelib}
-cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
+cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ovstest \
    $RPM_BUILD_ROOT%{python2_sitelib}
 
+# We can't build the Python lib until after the libopenvswitch install
+pushd python
+# py2/py3_build, but with extra CFLAGS--is there a better way to do this?
+CFLAGS="%{optflags} -I ../include -L $RPM_BUILD_ROOT%{_libdir}" %{__python} \
+        setup.py %{?py_setup_args} build --executable="%{__python2} -s"
+
+%if 0%{?fedora} > 22 || %{with build_python3}
+CFLAGS="%{optflags} -I ../include -L $RPM_BUILD_ROOT%{_libdir}" %{__python3} \
+        setup.py %{?py_setup_args} build --executable="%{__python3} -s"
+%endif
+
+%py2_install
 %if 0%{?fedora} > 22 || %{with build_python3}
-install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
-cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ovs \
-   $RPM_BUILD_ROOT%{python3_sitelib}
+%py3_install
 %endif
+popd
 
 rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
 
@@ -481,12 +493,14 @@  fi
 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
 
 %files -n %{_py2}-openvswitch
-%{python2_sitelib}/ovs
+%{python2_sitearch}/ovs
+%{python2_sitearch}/ovs-*.egg-info
 %doc COPYING
 
 %if 0%{?fedora} > 22 || %{with build_python3}
 %files -n python3-openvswitch
-%{python3_sitelib}/ovs
+%{python3_sitearch}/ovs
+%{python3_sitearch}/ovs-*.egg-info
 %doc COPYING
 %endif
 
@@ -508,6 +522,7 @@  fi
 %files devel
 %{_libdir}/*.a
 %{_libdir}/*.la
+%{_libdir}/lib*.so*
 %{_libdir}/pkgconfig/*.pc
 %{_includedir}/openvswitch/*
 %{_includedir}/openflow/*