2013-04-15 22:57:00 +00:00
|
|
|
##
|
2013-04-23 20:24:30 +00:00
|
|
|
## This file is part of the libsigrok project.
|
2013-04-15 22:57:00 +00:00
|
|
|
##
|
|
|
|
## Copyright (C) 2013 Martin Ling <martin-sigrok@earth.li>
|
|
|
|
##
|
|
|
|
## This program is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2013-04-15 19:01:07 +00:00
|
|
|
|
2013-04-17 02:50:27 +00:00
|
|
|
from setuptools import setup, find_packages, Extension
|
2014-08-16 21:44:19 +00:00
|
|
|
from distutils.command.build_py import build_py as _build_py
|
|
|
|
from distutils.command.build_ext import build_ext as _build_ext
|
2014-11-22 03:52:58 +00:00
|
|
|
import numpy as np
|
2013-04-15 19:01:07 +00:00
|
|
|
import subprocess
|
2014-07-17 17:45:29 +00:00
|
|
|
import os
|
|
|
|
|
2014-08-16 21:44:19 +00:00
|
|
|
srcdir = os.path.split(__file__)[0]
|
|
|
|
|
2013-04-19 16:41:44 +00:00
|
|
|
sr_includes, sr_lib_dirs, sr_libs, (sr_version,) = [
|
|
|
|
subprocess.check_output(
|
2014-07-17 17:45:29 +00:00
|
|
|
["pkg-config", option, "glib-2.0", "glibmm-2.4", "pygobject-3.0"]
|
|
|
|
).decode().rstrip().split(' ')
|
2013-04-19 16:41:44 +00:00
|
|
|
for option in
|
|
|
|
("--cflags-only-I", "--libs-only-L", "--libs-only-l", "--modversion")]
|
2013-04-15 19:01:07 +00:00
|
|
|
|
2014-08-16 21:44:19 +00:00
|
|
|
includes = ['../../include', '../cxx/include']
|
|
|
|
includes += [os.path.join(srcdir, path) for path in includes]
|
2015-01-17 19:11:53 +00:00
|
|
|
includes += ['../..', '../../include/libsigrok', '../cxx/include/libsigrokcxx']
|
2014-08-16 21:44:19 +00:00
|
|
|
includes += [i[2:] for i in sr_includes]
|
2014-11-22 03:52:58 +00:00
|
|
|
includes += [np.get_include(), ]
|
2014-07-17 17:45:29 +00:00
|
|
|
libdirs = ['../../.libs', '../cxx/.libs'] + [l[2:] for l in sr_lib_dirs]
|
2015-01-17 17:49:04 +00:00
|
|
|
libs = [l[2:] for l in sr_libs] + ['sigrokcxx']
|
2014-07-17 17:45:29 +00:00
|
|
|
|
2014-08-16 21:44:19 +00:00
|
|
|
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)]
|
|
|
|
|
2013-04-15 19:01:07 +00:00
|
|
|
setup(
|
|
|
|
name = 'libsigrok',
|
2013-04-17 02:50:27 +00:00
|
|
|
namespace_packages = ['sigrok'],
|
2014-08-16 21:44:19 +00:00
|
|
|
packages = find_packages(srcdir),
|
2013-04-15 19:01:07 +00:00
|
|
|
version = sr_version,
|
|
|
|
description = "libsigrok API wrapper",
|
2014-07-19 20:22:12 +00:00
|
|
|
zip_safe = False,
|
2014-08-16 21:44:19 +00:00
|
|
|
script_name = __file__,
|
2013-04-15 19:01:07 +00:00
|
|
|
ext_modules = [
|
2014-07-17 17:45:29 +00:00
|
|
|
Extension('sigrok.core._classes',
|
2014-08-16 21:44:19 +00:00
|
|
|
sources = [vpath('sigrok/core/classes.i')],
|
|
|
|
swig_opts = ['-c++', '-threads', '-Isigrok/core'] +
|
2014-07-17 17:45:29 +00:00
|
|
|
['-I%s' % i for i in includes],
|
2014-11-22 21:06:02 +00:00
|
|
|
extra_compile_args = ['-std=c++11', '-Wno-uninitialized'],
|
2014-05-04 20:13:52 +00:00
|
|
|
include_dirs = includes,
|
|
|
|
library_dirs = libdirs,
|
|
|
|
libraries = libs)
|
2013-04-15 19:01:07 +00:00
|
|
|
],
|
2014-08-16 21:44:19 +00:00
|
|
|
cmdclass = {'build_py': build_py, 'build_ext': build_ext},
|
2013-04-15 19:01:07 +00:00
|
|
|
)
|