Currently, the 'ovstest' package is not included in the default setup.py configuration. However, downstream packaging guidelines (such as the new Fedora Python Packaging Guidelines [1]) imply that all files installed into Python library directories should be managed by standard PyPA tools like setuptools.
Add a separate setup.py for ovstest (in python/ovstest/), allowing it to be built and installed as its own independent Python package. This avoids coupling it to the main 'ovs' package build and lets packagers install it using standard Python build mechanisms. This package is a dependency for utilities such as 'ovs-l3ping' and 'ovs-test'. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ Signed-off-by: Timothy Redaelli <[email protected]> --- v1 -> v2: - Instead of using an environment variable (enable_ovstest) to conditionally include ovstest in the ovs package, add a separate setup.py inside python/ovstest/ to build ovstest as its own independent Python package (as requested by Adrián) --- python/automake.mk | 10 ++++ python/ovstest/setup.py.template | 35 ++++++++++++++ rhel/openvswitch-fedora.spec.in | 80 ++++++++++++++++++++++++++------ 3 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 python/ovstest/setup.py.template diff --git a/python/automake.mk b/python/automake.mk index 060d76cb7..8396b9bb6 100644 --- a/python/automake.mk +++ b/python/automake.mk @@ -95,6 +95,7 @@ EXTRA_DIST += \ python/ovs/flowviz/ovs-flowviz.conf \ python/README.rst \ python/setup.py \ + python/ovstest/setup.py \ python/test_requirements.txt # C extension support. @@ -178,6 +179,15 @@ $(srcdir)/python/setup.py: python/setup.py.template config.status EXTRA_DIST += python/setup.py.template CLEANFILES += python/setup.py +ALL_LOCAL += $(srcdir)/python/ovstest/setup.py +$(srcdir)/python/ovstest/setup.py: python/ovstest/setup.py.template config.status + $(AM_V_GEN)sed \ + -e 's,[@]VERSION[@],$(VERSION),g' \ + < $(srcdir)/python/ovstest/setup.py.template > [email protected] && \ + if cmp -s [email protected] $@; then touch $@; else cp [email protected] $@; fi; rm [email protected] +EXTRA_DIST += python/ovstest/setup.py.template +CLEANFILES += python/ovstest/setup.py + EXTRA_DIST += python/TODO.rst $(srcdir)/python/ovs/flow/ofp_fields.py: $(srcdir)/build-aux/gen_ofp_field_decoders include/openvswitch/meta-flow.h diff --git a/python/ovstest/setup.py.template b/python/ovstest/setup.py.template new file mode 100644 index 000000000..b3721bf52 --- /dev/null +++ b/python/ovstest/setup.py.template @@ -0,0 +1,35 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import setuptools + +VERSION = "@VERSION@" + +setuptools.setup( + name='ovstest', + description='Open vSwitch test utilities library', + version=VERSION, + url='http://www.openvswitch.org/', + author='Open vSwitch', + author_email='[email protected]', + packages=['ovstest'], + package_dir={'ovstest': '.'}, + keywords=['openvswitch', 'ovs', 'test'], + license='Apache 2.0', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Topic :: System :: Networking', + 'License-Expression :: Apache 2.0', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + ], +) diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index 38fbee727..46c77cf9f 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -99,6 +99,11 @@ Obsoletes: openvswitch-controller <= 0:2.1.0-1 %bcond_without check %bcond_with check_datapath_kernel +%if 0%{?rhel} +# sortedcontainers are not packaged on RHEL yet, but ovs includes it +%global __requires_exclude ^python%{python3_version}dist\\(sortedcontainers\\)$ +%endif + %description Open vSwitch provides standard network bridging functions and support for the OpenFlow protocol for remote per-flow control of @@ -116,8 +121,10 @@ Tailored Open vSwitch SELinux policy %package -n python3-openvswitch Summary: Open vSwitch python3 bindings License: ASL 2.0 -BuildArch: noarch +%if (0%{?fedora} && 0%{?fedora} < 31) || (0%{?rhel} && 0%{?rhel} < 9) +%{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}} Requires: python3 +%endif # DNS resolution support in Python IDL. Suggests: python3-unbound @@ -126,15 +133,14 @@ Suggests: python3-netaddr python3-pyparsing # Dependencies of ovs-flowviz. Suggests: python3-click python3-graphviz python3-rich -%{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}} - %description -n python3-openvswitch Python bindings for the Open vSwitch database %package test Summary: Open vSwitch testing utilities License: ASL 2.0 -BuildArch: noarch +Requires: python3-openvswitch = %{version}-%{release} +Requires: tcpdump %description test Utilities that are useful to diagnose performance and connectivity @@ -163,7 +169,9 @@ service. %package ipsec Summary: Open vSwitch IPsec tunneling support License: ASL 2.0 -Requires: openvswitch python3-openvswitch libreswan +Requires: openvswitch = %{version}-%{release} +Requires: python3-openvswitch = %{version}-%{release} +Requires: libreswan %description ipsec This package provides IPsec tunneling support for OVS tunnels. @@ -171,6 +179,17 @@ This package provides IPsec tunneling support for OVS tunnels. %prep %setup -q +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%generate_buildrequires +cd python +# sortedcontainers are not packaged on RHEL yet, but ovs includes it +%if 0%{?rhel} >= 9 +%pyproject_buildrequires -R +%else +%pyproject_buildrequires +%endif +%endif + %build %configure \ %if %{with libcapng} @@ -208,6 +227,26 @@ build-aux/dpdkstrip.py \ make %{?_smp_mflags} make selinux-policy +pushd python +( +export CPPFLAGS="-I $PWD/../include" +export LDFLAGS="%{__global_ldflags} -L $PWD/../lib/.libs" +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%pyproject_wheel +%else +%py3_build +%endif +) +popd + +pushd python/ovstest +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%pyproject_wheel +%else +%py3_build +%endif +popd + %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT @@ -248,12 +287,17 @@ install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \ 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%{python3_sitelib} -cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \ - $RPM_BUILD_ROOT%{python3_sitelib} - -mv $RPM_BUILD_ROOT%{python3_sitelib}/ovs/flowviz/ovs-flowviz \ - $RPM_BUILD_ROOT/%{_bindir}/ovs-flowviz +pushd python +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%pyproject_install +%else +%py3_install +pushd ovstest +%py3_install +popd +%endif +[ -f "$RPM_BUILD_ROOT/%{python3_sitearch}/ovs/_json$(python3-config --extension-suffix)" ] +popd rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ @@ -410,7 +454,12 @@ fi %files -n python3-openvswitch %{_bindir}/ovs-flowviz %{_mandir}/man8/ovs-flowviz.8* -%{python3_sitelib}/ovs +%{python3_sitearch}/ovs/ +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%{python3_sitearch}/ovs-%{version}.dist-info/ +%else +%{python3_sitearch}/ovs-%{version}-py%{python3_version}.egg-info/ +%endif %files test %{_bindir}/ovs-test @@ -426,7 +475,12 @@ fi %{_mandir}/man1/ovs-pcap.1* %{_mandir}/man8/ovs-tcpdump.8* %{_mandir}/man1/ovs-tcpundump.1* -%{python3_sitelib}/ovstest +%{python3_sitelib}/ovstest/ +%if 0%{?fedora} >= 31 || 0%{?rhel} >= 9 +%{python3_sitelib}/ovstest-%{version}.dist-info/ +%else +%{python3_sitelib}/ovstest-%{version}-py%{python3_version}.egg-info/ +%endif %files devel %{_libdir}/lib*.so -- 2.53.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
