From: Noa Osherovich <noaos@xxxxxxxxxxxx> Update packaging files and cbuild dependencies to allow pyverbs to be included in Debian-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 | 19 +++++++++----- debian/control | 10 +++++++- debian/python3-pyverbs.install | 1 + debian/rules | 46 ++++++++++++++++++++++++---------- 5 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 debian/python3-pyverbs.install diff --git a/README.md b/README.md index f7ea6030..9b78c78a 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ only load from the system path. ### Debian Derived ```sh -$ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route-3-dev ninja-build pkg-config valgrind +$ apt-get install build-essential cmake gcc libudev-dev libnl-3-dev libnl-route-3-dev ninja-build pkg-config valgrind python3-dev cython3 ``` ### Fedora diff --git a/buildlib/cbuild b/buildlib/cbuild index 83b0c7b1..9ced0de6 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -158,7 +158,7 @@ class fc29(Environment): class APTEnvironment(Environment): is_deb = True; - build_python = False; + build_python = True; 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"%( @@ -180,7 +180,6 @@ class trusty(APTEnvironment): 'ninja-build', 'pandoc', 'pkg-config', - 'python', 'valgrind', }; pkgs = common_pkgs | { @@ -190,10 +189,12 @@ class trusty(APTEnvironment): }; name = "ubuntu-14.04"; aliases = {"trusty"}; + python_cmd = "python"; + build_pyverbs = False; class xenial(APTEnvironment): docker_parent = "ubuntu:16.04" - pkgs = trusty.common_pkgs | {"libsystemd-dev"}; + pkgs = trusty.common_pkgs | {"libsystemd-dev", "python3-dev", "cython3"}; name = "ubuntu-16.04"; aliases = {"xenial"}; @@ -208,7 +209,7 @@ class jessie(APTEnvironment): pkgs = xenial.pkgs; name = "debian-8"; aliases = {"jessie"}; - python_cmd = "python"; + build_pyverbs = False; class stretch(APTEnvironment): docker_parent = "debian:9" @@ -640,6 +641,10 @@ def run_deb_build(args,env): "-e","DEB_BUILD_OPTIONS=parallel=%u"%(multiprocessing.cpu_count()), ]; + if not env.build_pyverbs: + opts.append("-e"); + opts.append("EXTRA_CMAKE_FLAGS=%s"%(' '.join(["-DNO_PYVERBS=1"]))); + # Create a go.py that will let us run the compilation as the user and # then switch to root only for the packaging step. with open(os.path.join(tmpdir,"go.py"),"w") as F: @@ -661,7 +666,7 @@ subprocess.check_call(["debian/rules","debian/rules","binary"]); if args.run_shell: opts.append("/bin/bash"); else: - opts.extend(["python",os.path.join(home,"go.py")]); + opts.extend(["python3",os.path.join(home,"go.py")]); docker_cmd(args,*opts); @@ -806,6 +811,9 @@ def cmd_make(args): dirs.append(BUILD_r); cmake_args = [] + if not env.build_pyverbs: + cmake_args.extend(["-DNO_PYVERBS=1"]); + cmake_envs = [] ninja_args = [] for I in args.ARGS: @@ -815,7 +823,6 @@ def cmd_make(args): cmake_envs.append(I); else: ninja_args.append(I); - if env.use_make: need_cmake = not os.path.exists(os.path.join(BUILD_r,"Makefile")); else: diff --git a/debian/control b/debian/control index 4debe4e9..b132b590 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,8 @@ Build-Depends: cmake (>= 2.8.11), ninja-build, pandoc, pkg-config, - python, + python3-dev, + cython3, valgrind [amd64 arm64 armhf i386 mips mips64el mipsel powerpc ppc64 ppc64el s390x] Standards-Version: 4.2.1 Vcs-Git: https://github.com/linux-rdma/rdma-core.git @@ -324,3 +325,10 @@ Description: Tools for Infiniband attached storage (SRP) In conjunction with the kernel ib_srp driver, srptools allows you to discover and use Infiniband attached storage devices which use the SCSI RDMA Protocol (SRP). + +Package: python3-pyverbs +Architecture: linux-any +Depends: rdma-core (>= 21), + ${python3:Depends} +Description: Pyverbs is a python bindings for rdma-core. + It allows an easy development in python language of RDMA applications. diff --git a/debian/python3-pyverbs.install b/debian/python3-pyverbs.install new file mode 100644 index 00000000..20130d8a --- /dev/null +++ b/debian/python3-pyverbs.install @@ -0,0 +1 @@ +usr/lib/python3/dist-packages/pyverbs diff --git a/debian/rules b/debian/rules index 5ca94e88..dceb6352 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all COHERENT_DMA_ARCHS = amd64 arm64 i386 ia64 powerpc powerpcspe ppc64 ppc64el s390x sparc64 x32 %: - dh $@ --with systemd --builddirectory=build-deb + dh $@ --with python3,systemd --builddirectory=build-deb override_dh_auto_clean: dh_auto_clean @@ -22,19 +22,29 @@ override_dh_auto_clean: # # Upstream encourages the use of Ninja to build the source, convince dh to use # it until someone writes native support for dh+cmake+ninja. +DH_AUTO_CONFIGURE := "--" \ + "-GNinja" \ + "-DDISTRO_FLAVOUR=Debian" \ + "-DCMAKE_BUILD_TYPE=Release" \ + "-DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc" \ + "-DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=/lib/systemd/system" \ + "-DCMAKE_INSTALL_INITDDIR:PATH=/etc/init.d" \ + "-DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib" \ + "-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib" \ + "-DCMAKE_INSTALL_RUNDIR:PATH=/run" \ + "-DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d" \ + "-DENABLE_STATIC=1" \ + $(EXTRA_CMAKE_FLAGS) + override_dh_auto_configure: - dh_auto_configure -- -GNinja \ - -DDISTRO_FLAVOUR=Debian \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc \ - -DCMAKE_INSTALL_SYSTEMD_SERVICEDIR:PATH=/lib/systemd/system \ - -DCMAKE_INSTALL_INITDDIR:PATH=/etc/init.d \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib \ - -DCMAKE_INSTALL_RUNDIR:PATH=/run \ - -DCMAKE_INSTALL_UDEV_RULESDIR:PATH=/lib/udev/rules.d \ - -DENABLE_STATIC=1 \ - $(EXTRA_CMAKE_FLAGS) +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + dh_auto_configure $(DH_AUTO_CONFIGURE) +else + dh_auto_configure $(DH_AUTO_CONFIGURE) \ + -DNO_PYVERBS=0 \ + -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 \ + -DCMAKE_INSTALL_PYTHON_ARCH_LIB:PATH=/usr/lib/python3/dist-packages +endif override_dh_auto_build: ninja -C build-deb -v @@ -57,6 +67,9 @@ INST_EXCLUDE := "etc/init.d/srpd" \ "etc/init.d/ibacm" \ "usr/sbin/run_srp_daemon" \ "usr/sbin/srp_daemon.sh" +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + INST_EXCLUDE := $(INST_EXCLUDE) "usr/lib/python3/dist-packages/pyverbs" +endif INST_EXCLUDE := $(addprefix -X,$(INST_EXCLUDE)) override_dh_install: dh_install --fail-missing $(INST_EXCLUDE) @@ -86,6 +99,13 @@ override_dh_strip: dh_strip -plibrdmacm1 --dbg-package=librdmacm1-dbg dh_strip --remaining-packages +override_dh_builddeb: +ifeq ($(EXTRA_CMAKE_FLAGS), -DNO_PYVERBS=1) + dh_builddeb -Npython3-pyverbs --remaining-packages +else + dh_builddeb --remaining-package +endif + # Upstream encourages the use of 'build' as the developer build output # directory, allow that directory to be present and still allow dh to work. .PHONY: build -- 2.19.1