|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +# ------------------------------ |
| 4 | +# License |
| 5 | + |
| 6 | +# Copyright 2023 Aldrin Montana |
| 7 | +# |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | +# you may not use this file except in compliance with the License. |
| 10 | +# You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | +# See the License for the specific language governing permissions and |
| 18 | +# limitations under the License. |
| 19 | + |
| 20 | + |
| 21 | +# ------------------------------ |
| 22 | +# Module Docstring |
| 23 | +""" |
| 24 | +Build script for the mohair module. |
| 25 | +
|
| 26 | +This includes how to compile cython bindings for prototyping integration with Faodel. |
| 27 | +""" |
| 28 | + |
| 29 | + |
| 30 | +# ------------------------------ |
| 31 | +# Dependencies |
| 32 | + |
| 33 | +# >> Modules |
| 34 | +from pathlib import Path |
| 35 | + |
| 36 | +# >> Third-party |
| 37 | +import pkgconfig |
| 38 | +import numpy |
| 39 | +import pyarrow |
| 40 | + |
| 41 | +# >> Classes |
| 42 | +from setuptools import Extension |
| 43 | + |
| 44 | +# >> Functions |
| 45 | +from setuptools import setup |
| 46 | +from Cython.Build import cythonize |
| 47 | + |
| 48 | + |
| 49 | +# ------------------------------ |
| 50 | +# Module variables |
| 51 | + |
| 52 | +# >> reference variables |
| 53 | +cppsrc_dirpath = Path('src') / 'cpp' |
| 54 | +pysrc_dirpath = Path('src') / 'python' |
| 55 | + |
| 56 | +# TODO: these will eventually be migrated into skytether components |
| 57 | +# and mohair will be more of a leaf dependency |
| 58 | +pkgsrc_dirpath = pysrc_dirpath / 'mohair' / 'cybindings' |
| 59 | + |
| 60 | + |
| 61 | +# ------------------------------ |
| 62 | +# Extension definitions |
| 63 | + |
| 64 | +# >> Mohair bindings to faodel and acero wrappers |
| 65 | + |
| 66 | +# |> Resources for the extension |
| 67 | +pkgsrc_filelist = [ |
| 68 | + pkgsrc_dirpath / 'scytether.pyx' |
| 69 | + ,cppsrc_dirpath / 'engines' / 'faodel.cpp' |
| 70 | + ,cppsrc_dirpath / 'engines' / 'acero.cpp' |
| 71 | +] |
| 72 | + |
| 73 | +pkgdep_inclist = [ |
| 74 | + numpy.get_include() |
| 75 | + ,pyarrow.get_include() |
| 76 | + ,pkgconfig.variables('arrow-acero')['includedir'] |
| 77 | + ,pkgconfig.variables('mohair')['includedir'] |
| 78 | + ,f"{pkgconfig.variables('faodel')['includedir']}/faodel" |
| 79 | +] |
| 80 | + |
| 81 | +pkgdep_liblist = [ |
| 82 | + 'arrow' |
| 83 | + ,'arrow_acero' |
| 84 | + ,'arrow_substrait' |
| 85 | + ,'arrow_python' |
| 86 | + ,'mpi' |
| 87 | + ,'mpi_cxx' |
| 88 | + ,'faodel-common' |
| 89 | + ,'faodel-services' |
| 90 | + ,'dirman' |
| 91 | + ,'lunasa' |
| 92 | + ,'kelpie' |
| 93 | +] |
| 94 | + |
| 95 | +pkgdep_libdirs = ( |
| 96 | + pyarrow.get_library_dirs() |
| 97 | + + [ |
| 98 | + '/usr/lib' |
| 99 | + ,'/usr/local/faodel-dev/lib' |
| 100 | + ] |
| 101 | +) |
| 102 | + |
| 103 | +# |> The extension itself |
| 104 | +scytether_extension = Extension('scytether' |
| 105 | + ,list(map(str, pkgsrc_filelist)) |
| 106 | + ,include_dirs=pkgdep_inclist |
| 107 | + ,library_dirs=pkgdep_libdirs |
| 108 | + ,libraries=pkgdep_liblist |
| 109 | +) |
| 110 | + |
| 111 | + |
| 112 | +# ------------------------------ |
| 113 | +# Main build logic |
| 114 | + |
| 115 | +# >> use README.md for long description |
| 116 | +with open('README.md', mode='r', encoding='utf-8') as readme_handle: |
| 117 | + readme_content = readme_handle.read() |
| 118 | + |
| 119 | + |
| 120 | +# >> simple variables to capture cython configuration |
| 121 | +cythonize_modulelist = [ scytether_extension ] |
| 122 | +cythonize_compdirs = { 'language_level': 3 } |
| 123 | + |
| 124 | +setup( |
| 125 | + name = 'mohair' |
| 126 | + ,version = '0.1.0' |
| 127 | + ,zip_safe = False |
| 128 | + ,author = 'Aldrin Montana' |
| 129 | + , author_email = '[email protected]' |
| 130 | + ,description = ('Query processing for decomposable queries') |
| 131 | + ,license = 'MPL 2.0' |
| 132 | + ,keywords = 'example documentation tutorial' |
| 133 | + ,url = 'https://github.com/drin/mohair-faodel/' |
| 134 | + ,long_description = readme_content |
| 135 | + |
| 136 | + ,package_dir = { '': str(pysrc_dirpath) } |
| 137 | + ,packages = [ |
| 138 | + 'mohair' |
| 139 | + ,'mohair.query' |
| 140 | + ,'mohair.storage' |
| 141 | + ,'mohair.mohair' |
| 142 | + ,'mohair.substrait' |
| 143 | + ,'mohair.substrait.extensions' |
| 144 | + ] |
| 145 | + ,ext_modules = cythonize( |
| 146 | + module_list=cythonize_modulelist |
| 147 | + ,compiler_directives=cythonize_compdirs |
| 148 | + ) |
| 149 | + |
| 150 | + ,classifiers = [ |
| 151 | + 'Development Status :: 1 - Planning' |
| 152 | + ,'Topic :: Utilities' |
| 153 | + ,'License :: OSI Approved :: Apache Software License' |
| 154 | + ] |
| 155 | +) |
0 commit comments