From: Noa Osherovich <noaos@xxxxxxxxxxxx> Update spec file and cbuild dependencies to allow pyverbs to be included in RedHat-based distributions. Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx> Signed-off-by: Alaa Hleihel <alaa@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- README.md | 2 +- buildlib/cbuild | 17 ++++++++++++++--- redhat/rdma-core.spec | 30 +++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0594272f..d72b408e 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ $ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route- ### Fedora ```sh -$ dnf install cmake gcc libnl3-devel libudev-devel pkgconfig valgrind-devel ninja-build +$ dnf install cmake gcc libnl3-devel libudev-devel pkgconfig valgrind-devel ninja-build python3-devel python3-Cython ``` NOTE: Fedora Core uses the name 'ninja-build' for the 'ninja' command. diff --git a/buildlib/cbuild b/buildlib/cbuild index f22d9270..597b146a 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -74,10 +74,11 @@ class DockerFile(object): class Environment(object): pandoc = True; - python_cmd = "python"; + python_cmd = "python3"; aliases = set(); use_make = False; proxy = True; + build_pyverbs = True; def image_name(self): return "build-%s/%s"%(project,self.name); @@ -110,6 +111,8 @@ class centos6(YumEnvironment): use_make = True; pandoc = False; is_rpm = False; + build_pyverbs = False; + python_cmd = "python"; class centos7(YumEnvironment): docker_parent = "centos:7"; @@ -117,10 +120,12 @@ class centos7(YumEnvironment): name = "centos7"; use_make = True; pandoc = False; + build_pyverbs = False; specfile = "redhat/rdma-core.spec"; + python_cmd = "python"; class centos7_epel(centos7): - pkgs = (centos7.pkgs - {"cmake","make"}) | {"ninja-build","cmake3","pandoc"}; + pkgs = (centos7.pkgs - {"cmake","make"}) | {"ninja-build","cmake3","pandoc", 'python3-Cython', 'python3-devel'}; name = "centos7_epel"; use_make = False; pandoc = True; @@ -136,7 +141,7 @@ class centos7_epel(centos7): class fc29(Environment): docker_parent = "fedora:29"; - pkgs = (centos7.pkgs - {"make", "python-argparse" }) | {"ninja-build","pandoc","perl-generators"}; + pkgs = (centos7.pkgs - {"make", "python-argparse" }) | {"ninja-build","pandoc","perl-generators","python3-Cython","python3-devel"}; name = "fc29"; specfile = "redhat/rdma-core.spec"; ninja_cmd = "ninja-build"; @@ -153,6 +158,7 @@ class fc29(Environment): class APTEnvironment(Environment): is_deb = True; + build_python = False; def get_docker_file(self): res = DockerFile(self.docker_parent); res.lines.append("RUN apt-get update && apt-get install -y --no-install-recommends %s && apt-get clean"%( @@ -202,6 +208,7 @@ class jessie(APTEnvironment): pkgs = xenial.pkgs; name = "debian-8"; aliases = {"jessie"}; + python_cmd = "python"; class stretch(APTEnvironment): docker_parent = "debian:9" @@ -314,6 +321,7 @@ class travis(APTEnvironment): class ZypperEnvironment(Environment): is_rpm = True; + build_pyverbs = False; def get_docker_file(self): res = DockerFile(self.docker_parent); res.lines.append("RUN zypper --non-interactive refresh"); @@ -583,6 +591,9 @@ os.symlink({tarfn!r},os.path.join(b"SOURCES",tarfn)); bopts.extend(["--with", arg]); for arg in args.without_flags: bopts.extend(["--without", arg]); + if "pyverbs" not in args.with_flags + args.without_flags: + if env.build_pyverbs: + bopts.extend(["--with", "pyverbs"]); print >> F,'os.execlp("rpmbuild","rpmbuild",%s)'%( ",".join(repr(I) for I in bopts)); diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec index 14af2a04..ea0d6046 100644 --- a/redhat/rdma-core.spec +++ b/redhat/rdma-core.spec @@ -23,7 +23,13 @@ BuildRequires: pkgconfig(libnl-route-3.0) BuildRequires: valgrind-devel BuildRequires: systemd BuildRequires: systemd-devel +%define with_pyverbs %{?_with_pyverbs: 1} %{?!_with_pyverbs: 0} +%if %{with_pyverbs} +BuildRequires: python3-devel +BuildRequires: python3-Cython +%else BuildRequires: python +%endif %if 0%{?fedora} >= 21 BuildRequires: perl-generators %endif @@ -211,6 +217,14 @@ Requires: %{name}%{?_isa} = %{version}-%{release} In conjunction with the kernel ib_srp driver, srp_daemon allows you to discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand. +%package -n python3-pyverbs +Summary: Python3 API over IB verbs +%{?python_provide:%python_provide python3-pyverbs} + +%description -n python3-pyverbs +Pyverbs is a Cython-based Python API over libibverbs, providing an +easy, object-oriented access to IB verbs. + %prep %setup @@ -245,7 +259,16 @@ discover and use SCSI devices via the SCSI RDMA Protocol over InfiniBand. %if %{with_static} -DENABLE_STATIC=1 \ %endif - %{EXTRA_CMAKE_FLAGS} + %{EXTRA_CMAKE_FLAGS} \ +%if %{defined __python3} + -DPYTHON_EXECUTABLE:PATH=%{__python3} \ + -DCMAKE_INSTALL_PYTHON_ARCH_LIB:PATH=%{python3_sitearch} \ +%endif +%if %{with_pyverbs} + -DNO_PYVERBS=0 +%else + -DNO_PYVERBS=1 +%endif %make_jobs %install @@ -469,3 +492,8 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh %{_mandir}/man5/srp_daemon.service.5* %{_mandir}/man5/srp_daemon_port@.service.5* %doc %{_docdir}/%{name}-%{version}/ibsrpdm.md + +%if %{with_pyverbs} +%files -n python3-pyverbs +%{python3_sitearch}/pyverbs +%endif -- 2.19.1