Skip to content

Commit

Permalink
debian: add python3-bcc package
Browse files Browse the repository at this point in the history
This patch extends the PYTHON_CMD cmake variable to allow a list of
Python binaries and installs the bcc Python bindings for each Python
installation. The Debian control files are updated to generate bindings
for Python 2 and Python 3. Compiled Python files are excluded from the
Debian packages.

Signed-off-by: Andreas Gerstmayr <[email protected]>
  • Loading branch information
andreasgerstmayr authored and drzaeus77 committed Mar 21, 2018
1 parent 130b594 commit e0d808e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
8 changes: 7 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Build-Depends: debhelper (>= 9), cmake, libllvm3.7 | libllvm3.8,
libelf-dev, bison, flex, libfl-dev, libedit-dev, zlib1g-dev, git,
clang-format | clang-format-3.7 | clang-format-3.8, python (>= 2.7),
python-netaddr, python-pyroute2, luajit, libluajit-5.1-dev, arping,
inetutils-ping | iputils-ping, iperf, netperf, ethtool, devscripts
inetutils-ping | iputils-ping, iperf, netperf, ethtool, devscripts,
python3
Homepage: https://github.com/iovisor/bcc

Package: libbcc
Expand All @@ -28,6 +29,11 @@ Architecture: all
Depends: libbcc, python, binutils
Description: Python wrappers for BPF Compiler Collection (BCC)

Package: python3-bcc
Architecture: all
Depends: libbcc, python3, binutils
Description: Python3 wrappers for BPF Compiler Collection (BCC)

Package: bcc-tools
Architecture: all
Depends: python-bcc
Expand Down
2 changes: 1 addition & 1 deletion debian/python-bcc.install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
usr/lib/python*
usr/lib/python2*
1 change: 1 addition & 0 deletions debian/python3-bcc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/python3*
4 changes: 2 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ DEBIAN_REVISION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: ([0-9.]+)
UPSTREAM_VERSION := $(shell dpkg-parsechangelog | sed -rne "s,^Version: ([0-9.]+)(~|-)(.*),\1,p")

%:
dh $@ --buildsystem=cmake --parallel
dh $@ --buildsystem=cmake --parallel --with python2,python3

# tests cannot be run in parallel
override_dh_auto_test:
dh_auto_test -O--buildsystem=cmake -O--no-parallel

# FIXME: LLVM_DEFINITIONS is broken somehow in LLVM cmake upstream
override_dh_auto_configure:
dh_auto_configure -- -DREVISION_LAST=$(UPSTREAM_VERSION) -DREVISION=$(UPSTREAM_VERSION) -DLLVM_DEFINITIONS="-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
dh_auto_configure -- -DREVISION_LAST=$(UPSTREAM_VERSION) -DREVISION=$(UPSTREAM_VERSION) -DLLVM_DEFINITIONS="-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS" -DPYTHON_CMD="python2;python3"
29 changes: 17 additions & 12 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ if(NOT PYTHON_CMD)
set(PYTHON_CMD "python")
endif()

set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist/bcc-${REVISION}.tar.gz")
configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY)
# build the pip installable
add_custom_command(OUTPUT ${PIP_INSTALLABLE}
COMMAND ${PYTHON_CMD} setup.py sdist
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bcc/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py
)
add_custom_target(bcc_py ALL DEPENDS ${PIP_INSTALLABLE})

if(EXISTS "/etc/debian_version")
set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
endif()
install(CODE "execute_process(COMMAND ${PYTHON_CMD} setup.py install -f ${PYTHON_FLAGS}
--prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
COMPONENT python)

foreach(PY_CMD ${PYTHON_CMD})
string(REPLACE "/" "-" PY_CMD_ESCAPED ${PY_CMD})

set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist-${PY_CMD_ESCAPED}/bcc-${REVISION}.tar.gz")
# build the pip installable
add_custom_command(OUTPUT ${PIP_INSTALLABLE}
COMMAND ${PY_CMD} setup.py sdist --dist-dir dist-${PY_CMD_ESCAPED}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bcc/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py
)
add_custom_target(bcc_py_${PY_CMD_ESCAPED} ALL DEPENDS ${PIP_INSTALLABLE})

install(CODE "execute_process(COMMAND ${PY_CMD} setup.py install -f ${PYTHON_FLAGS}
--prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
COMPONENT python)
endforeach()

0 comments on commit e0d808e

Please sign in to comment.