/
setup.py.in
79 lines (63 loc) · 2.46 KB
/
setup.py.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright (c) 2017 Hartmut Kaiser
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# partially taken from http://www.benjack.io/2017/06/12/python-cpp-tests.html
# @ADDITIONAL_COMMENT@
import os
import platform
import sys
import shutil
try:
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
except ImportError:
from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
# enable this to see more output from distutils
#os.environ["DISTUTILS_DEBUG"] = "1"
class CopyExtension(Extension):
def __init__(self, name, source_dir='', binary_base_dir=''):
Extension.__init__(self, name, sources=[])
self.source_dir = os.path.abspath(source_dir)
self.binary_base_dir = os.path.abspath(binary_base_dir)
class CopyBuildExt(build_ext):
def __init__(self, *args, **kwargs):
build_ext.__init__(self, *args, **kwargs)
self.build_type = '@CONFIG@'
def build_extension(self, ext):
fullpath = self.get_ext_fullpath(ext.name)
filename = self.get_ext_filename(ext.name)
extdir = os.path.abspath(os.path.dirname(fullpath))
extdir = os.path.join(extdir, 'phylanx')
if not os.path.exists(extdir):
os.make_dirs(extdir)
source_path = ext.binary_base_dir
if platform.system() == "Windows":
source_path = os.path.join(source_path, self.build_type)
source_path = os.path.join(source_path, 'bin')
source_path = os.path.join(source_path, filename)
shutil.copyfile(source_path, os.path.join(extdir, filename))
setup_args = {
'name' : 'phylanx',
'version' : '@PHYLANX_VERSION@',
'author' : 'The STE||AR Group',
'author_email' : 'phylanx@stellar-group.org',
'url' : 'phylanx.stellar-group.org',
'description' : 'A Python wrapper for the Phylanx execution engine',
'long_description' : '',
'packages' : ['phylanx'],
'package_dir' : { '' : '@PYTHON_PACKAGE_BASE_DIR@' },
'ext_modules' : [
CopyExtension('@PYTHON_PACKAGE_NAME@',
'@PYTHON_PACKAGE_BASE_DIR@',
'@PYTHON_BINARY_BASE_DIR@')
],
'cmdclass' : {
'build_ext' : CopyBuildExt
},
'platforms' : 'All',
'zip_safe' : False,
'license' : 'Boost Software License, Version 1.0 (http://www.boost.org/LICENSE_1_0.txt)'
}
setup(**setup_args)