1#!/usr/bin/env python3
2#
3# Copyright 2022 Google LLC
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18from setuptools import setup, Extension
19import os, sys, glob
20import numpy
21
22if len(sys.argv) <= 1:
23  sys.argv = sys.argv + [
24    'build', '--build-platlib', os.getcwd() + os.sep + 'build' ]
25
26INC_DIR = '..' + os.sep + 'include'
27SRC_DIR = '..' + os.sep + 'src'
28
29sources = glob.glob('*_py.c') + \
30          [ SRC_DIR + os.sep + 'tables.c',
31            SRC_DIR + os.sep + 'bits.c',
32            SRC_DIR + os.sep + 'plc.c' ]
33
34depends = [ 'ctypes.h' ] + \
35          glob.glob(INC_DIR + os.sep + '*.h') + \
36          glob.glob(SRC_DIR + os.sep + '*.[c,h]')
37
38includes = [ SRC_DIR, INC_DIR, numpy.get_include() ]
39
40extension = Extension('lc3',
41  extra_compile_args = [ '-std=c11', '-ffast-math' ],
42  define_macros = [ ('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION') ],
43  sources = sources,
44  depends = depends,
45  include_dirs = includes)
46
47setup(name = 'LC3',
48      version = '1.0',
49      description = 'LC3 Test Python Module',
50      ext_modules = [ extension ])
51