Makefile.am: Fix out-of-tree build for Python bindings
This commit is contained in:
parent
2ba308ecc6
commit
0e1a7fe91a
11
Makefile.am
11
Makefile.am
|
@ -447,23 +447,24 @@ PDIR = bindings/python
|
|||
PDOC = bindings/python/sigrok/core/doc.i
|
||||
|
||||
$(PDOC): bindings/swig/doc.py $(CPPXMLDOC)
|
||||
$(AM_V_GEN)python bindings/swig/doc.py python $(CPPXMLDOC) > $@
|
||||
$(AM_V_at)test -d $(PDIR)/sigrok/core || mkdir -p $(PDIR)/sigrok/core
|
||||
$(AM_V_GEN)python $< python $(CPPXMLDOC) > $@
|
||||
|
||||
python-build: $(PDIR)/timestamp
|
||||
|
||||
python-quietclean:
|
||||
$(AM_V_at)cd $(PDIR) && python setup.py --quiet clean --all 3>&1 1>&2 2>&3 \
|
||||
$(AM_V_at)cd $(PDIR) && python $(abs_srcdir)/$(PDIR)/setup.py --quiet clean --all 3>&1 1>&2 2>&3 \
|
||||
| grep -v "can.t clean it"; true
|
||||
|
||||
$(PDIR)/timestamp: bindings/cxx/libsigrokxx.la $(PDIR)/sigrok/core/classes.i \
|
||||
bindings/swig/classes.i $(PDOC) $(library_include_HEADERS)
|
||||
$(AM_V_at)$(MAKE) python-quietclean
|
||||
$(AM_V_GEN)cd $(PDIR) && python setup.py --quiet build 3>&1 1>&2 2>&3 \
|
||||
$(AM_V_GEN)cd $(PDIR) && python $(abs_srcdir)/$(PDIR)/setup.py --quiet build 3>&1 1>&2 2>&3 \
|
||||
| grep -v "command line option.*Wstrict-prototypes"; true
|
||||
$(AM_V_at)touch $(PDIR)/timestamp
|
||||
|
||||
python-install:
|
||||
cd $(PDIR) && python setup.py --quiet install --prefix $(prefix)
|
||||
cd $(PDIR) && python $(abs_srcdir)/$(PDIR)/setup.py --quiet install --prefix $(prefix)
|
||||
|
||||
python-clean:
|
||||
$(AM_V_at)$(MAKE) python-quietclean
|
||||
|
@ -471,7 +472,7 @@ python-clean:
|
|||
$(AM_V_at)rm -rf $(PDIR)/doxy/
|
||||
|
||||
python-doc:
|
||||
$(AM_V_at)cd $(PDIR) && doxygen Doxyfile 2>/dev/null
|
||||
$(AM_V_at)cd $(srcdir)/$(PDIR) && BUILDDIR=$(abs_builddir)/$(PDIR)/ doxygen Doxyfile 2>/dev/null
|
||||
|
||||
BUILD_EXTRA += python-build
|
||||
INSTALL_EXTRA += python-install
|
||||
|
|
|
@ -58,7 +58,7 @@ PROJECT_LOGO = ../../contrib/sigrok-logo-notext.png
|
|||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = doxy
|
||||
OUTPUT_DIRECTORY = $(BUILDDIR)doxy
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
|
@ -743,7 +743,7 @@ WARN_LOGFILE =
|
|||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = sigrok/core/classes.py
|
||||
INPUT = $(BUILDDIR)sigrok/core/classes.py
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
|
|
@ -18,9 +18,13 @@
|
|||
##
|
||||
|
||||
from setuptools import setup, find_packages, Extension
|
||||
from distutils.command.build_py import build_py as _build_py
|
||||
from distutils.command.build_ext import build_ext as _build_ext
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
srcdir = os.path.split(__file__)[0]
|
||||
|
||||
sr_includes, sr_lib_dirs, sr_libs, (sr_version,) = [
|
||||
subprocess.check_output(
|
||||
["pkg-config", option, "glib-2.0", "glibmm-2.4", "pygobject-3.0"]
|
||||
|
@ -28,25 +32,55 @@ sr_includes, sr_lib_dirs, sr_libs, (sr_version,) = [
|
|||
for option in
|
||||
("--cflags-only-I", "--libs-only-L", "--libs-only-l", "--modversion")]
|
||||
|
||||
includes = ['../../include', '../cxx/include'] + [i[2:] for i in sr_includes]
|
||||
includes = ['../../include', '../cxx/include']
|
||||
includes += [os.path.join(srcdir, path) for path in includes]
|
||||
includes += ['../..', '../../include/libsigrok', '../cxx/include/libsigrok']
|
||||
includes += [i[2:] for i in sr_includes]
|
||||
libdirs = ['../../.libs', '../cxx/.libs'] + [l[2:] for l in sr_lib_dirs]
|
||||
libs = [l[2:] for l in sr_libs] + ['sigrokxx']
|
||||
|
||||
def vpath(file):
|
||||
vfile = os.path.join(srcdir, file)
|
||||
return vfile if os.path.exists(vfile) else file
|
||||
|
||||
def unvpath(file):
|
||||
return os.path.relpath(file, srcdir) if file.startswith(srcdir) else file
|
||||
|
||||
class build_py(_build_py):
|
||||
def find_package_modules(self, package, pkg_dir):
|
||||
mods = _build_py.find_package_modules(self, package, pkg_dir)
|
||||
vmods = _build_py.find_package_modules(self, package, vpath(pkg_dir))
|
||||
mods.extend([mod for mod in vmods if mod not in mods])
|
||||
return mods
|
||||
def check_package(self, package, package_dir):
|
||||
return _build_py.check_package(self, package, vpath(package_dir))
|
||||
|
||||
class build_ext(_build_ext):
|
||||
def spawn (self, cmd):
|
||||
cmd[1:-1] = [arg if arg.startswith('-') else unvpath(arg) for arg in
|
||||
cmd[1:-1]]
|
||||
_build_ext.spawn(self, cmd)
|
||||
def swig_sources (self, sources, extension):
|
||||
return [unvpath(src) for src in
|
||||
_build_ext.swig_sources(self, sources, extension)]
|
||||
|
||||
setup(
|
||||
name = 'libsigrok',
|
||||
namespace_packages = ['sigrok'],
|
||||
packages = find_packages(),
|
||||
packages = find_packages(srcdir),
|
||||
version = sr_version,
|
||||
description = "libsigrok API wrapper",
|
||||
zip_safe = False,
|
||||
script_name = __file__,
|
||||
ext_modules = [
|
||||
Extension('sigrok.core._classes',
|
||||
sources = ['sigrok/core/classes.i'],
|
||||
swig_opts = ['-c++', '-threads'] +
|
||||
sources = [vpath('sigrok/core/classes.i')],
|
||||
swig_opts = ['-c++', '-threads', '-Isigrok/core'] +
|
||||
['-I%s' % i for i in includes],
|
||||
extra_compile_args = ['-std=c++11'],
|
||||
include_dirs = includes,
|
||||
library_dirs = libdirs,
|
||||
libraries = libs)
|
||||
],
|
||||
cmdclass = {'build_py': build_py, 'build_ext': build_ext},
|
||||
)
|
||||
|
|
|
@ -51,7 +51,7 @@ PyObject *GLib;
|
|||
PyTypeObject *IOChannel;
|
||||
PyTypeObject *PollFD;
|
||||
|
||||
#include "../../../../config.h"
|
||||
#include "config.h"
|
||||
|
||||
#if PYGOBJECT_FLAGS_SIGNED
|
||||
typedef gint pyg_flags_type;
|
||||
|
|
Loading…
Reference in New Issue