From patchwork Mon Jun 18 11:51:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Leblond X-Patchwork-Id: 930833 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=regit.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 418Vdy0jwhz9s0W for ; Mon, 18 Jun 2018 22:24:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933189AbeFRMYh (ORCPT ); Mon, 18 Jun 2018 08:24:37 -0400 Received: from home.regit.org ([37.187.126.138]:59450 "EHLO home.regit.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934281AbeFRMYf (ORCPT ); Mon, 18 Jun 2018 08:24:35 -0400 Received: from [2001:bf0:c001:30:8590:e614:7c18:3fd4] (helo=tiger-3.in-berlin.de) by home.regit.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fUshI-000644-TU; Mon, 18 Jun 2018 13:51:50 +0200 From: Eric Leblond To: pablo@netfilter.org Cc: netfilter-devel@vger.kernel.org, Eric Leblond Subject: [PATCH nft 3/8] python: installation of binding via make install Date: Mon, 18 Jun 2018 13:51:23 +0200 Message-Id: <20180618115128.20920-4-eric@regit.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618115128.20920-1-eric@regit.org> References: <20180618115128.20920-1-eric@regit.org> X-Spam-Score: -1.0 (-) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org setup.py is used to build and install the python binding. Call to setup.py are done in Makefile to proceed to build and installation. --- Makefile.am | 3 ++- configure.ac | 6 ++++++ py/Makefile.am | 31 +++++++++++++++++++++++++++++++ py/__init__.py | 1 + py/nftables.py | 2 ++ py/setup.py | 23 +++++++++++++++++++++++ 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 py/Makefile.am create mode 100644 py/__init__.py create mode 100755 py/setup.py diff --git a/Makefile.am b/Makefile.am index 09664c3..e567d32 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,8 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src \ include \ files \ - doc + doc \ + py EXTRA_DIST = tests \ files diff --git a/configure.ac b/configure.ac index 4d21cb4..2a19733 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,11 @@ AC_DEFINE([HAVE_LIBJANSSON], [1], [Define if you have libjansson]) AC_SUBST(with_json) AM_CONDITIONAL([BUILD_JSON], [test "x$with_json" != xno]) +AC_ARG_ENABLE(python, + AS_HELP_STRING([--enable-python], [Enable python]),,[enable_python=yes]) +AC_PATH_PROGS(HAVE_PYTHON, python python2 python2.7, "no") +AM_CONDITIONAL([HAVE_PYTHON], [test "x$enable_python" = "xyes"]) + AC_CONFIG_FILES([ \ Makefile \ libnftables.pc \ @@ -143,6 +148,7 @@ AC_CONFIG_FILES([ \ files/Makefile \ files/nftables/Makefile \ doc/Makefile \ + py/Makefile \ ]) AC_OUTPUT diff --git a/py/Makefile.am b/py/Makefile.am new file mode 100644 index 0000000..a34f9e8 --- /dev/null +++ b/py/Makefile.am @@ -0,0 +1,31 @@ +EXTRA_DIST = setup.py __init__.py nftables.py + +if HAVE_PYTHON + +all-local: + cd $(srcdir) && \ + $(HAVE_PYTHON) setup.py build --build-base $(abs_builddir) + +install-exec-local: + cd $(srcdir) && \ + $(HAVE_PYTHON) setup.py build --build-base $(abs_builddir) \ + install --prefix $(DESTDIR)$(prefix) + +uninstall-local: + rm -rf $(DESTDIR)$(prefix)/lib*/python*/site-packages/nftables + rm -rf $(DESTDIR)$(prefix)/lib*/python*/dist-packages/nftables + rm -rf $(DESTDIR)$(prefix)/lib*/python*/site-packages/nftables-[0-9]*.egg-info + rm -rf $(DESTDIR)$(prefix)/lib*/python*/dist-packages/nftables-[0-9]*.egg-info + rm -rf $(DESTDIR)$(prefix)/lib*/python*/site-packages/nftables-[0-9]*.egg + rm -rf $(DESTDIR)$(prefix)/lib*/python*/dist-packages/nftables-[0-9]*.egg + +clean-local: + cd $(srcdir) && \ + $(HAVE_PYTHON) setup.py clean \ + --build-base $(abs_builddir) + rm -rf scripts-* lib* build dist bdist.* nftables.egg-info + find . -name \*.pyc -print0 | xargs -0 rm -f + +distclean-local: + rm -f version +endif diff --git a/py/__init__.py b/py/__init__.py new file mode 100644 index 0000000..7567f09 --- /dev/null +++ b/py/__init__.py @@ -0,0 +1 @@ +from .nftables import * diff --git a/py/nftables.py b/py/nftables.py index e6e66fb..d613505 100644 --- a/py/nftables.py +++ b/py/nftables.py @@ -2,6 +2,8 @@ import json from ctypes import * import sys +NFTABLES_VERSION = "0.1" + class Nftables: """A class representing libnftables interface""" diff --git a/py/setup.py b/py/setup.py new file mode 100755 index 0000000..663574a --- /dev/null +++ b/py/setup.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +from distutils.core import setup +from nftables import NFTABLES_VERSION + +setup(name='nftables', + version=NFTABLES_VERSION, + description='Libnftables binding', + author='Phil Sutter', + author_email='phil@nwl.cc', + url='https://netfilter.org/projects/nftables/index.html', + packages=['nftables'], + provides=['nftables'], + package_dir={'nftables':'.'}, + classifiers=[ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Topic :: System :: Networking :: Firewalls', + ], + )