-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
83 lines (70 loc) · 2.73 KB
/
setup.py
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
79
80
81
82
83
### Adapted from Uncalled setup.py by Sam Kovaka
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
import os
import subprocess
import sys
try:
from pybind11.setup_helpers import Pybind11Extension, ParallelCompile, naive_recompile
ParallelCompile("NPY_NUM_BUILD_JOBS", default=4, needs_recompile=naive_recompile).install()
except:
from setuptools import Extension as Pybind11Extension
ROOT_DIR = os.getcwd()
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __str__(self):
import pybind11
from pybind11.setup_helpers import Pybind11Extension
return pybind11.get_include()
digest = Pybind11Extension(
"Digest",
sources = ['pybind/bindings.cpp'],
include_dirs = [
'build/include',
'pybind',
get_pybind_include()
],
library_dirs=['build/lib'],
define_macros = [("PYBIND", None)],
extra_compile_args=['-std=c++17', '-fPIC']
)
# class MesonBuildExt(build_ext):
# def run(self):
# # Check for Meson and Ninja installation
# try:
# subprocess.check_output(['meson', '--version'])
# except FileNotFoundError:
# raise RuntimeError("Meson must be installed to build the extensions")
# try:
# subprocess.check_output(['ninja', '--version'])
# except FileNotFoundError:
# raise RuntimeError("Ninja must be installed to build the extensions")
# def build_extension(self):
# build_temp = os.path.abspath(self.build_temp)
# # ext_fullpath = self.get_ext_fullpath(ext.name)
# # ext_dir = os.path.abspath(os.path.dirname(ext_fullpath))
# ext_dir = os.path.abspath(os.path.join(ROOT_DIR, 'build'))
# meson_build_dir = os.path.join(build_temp, 'meson_build')
# # Create build directory if it doesn't exist
# if not os.path.exists(meson_build_dir):
# os.makedirs(meson_build_dir)
# meson_args = [
# 'meson', 'setup', '--prefix', ext_dir,
# '--buildtype=release', meson_build_dir
# ]
# subprocess.check_call(meson_args)
# subprocess.check_call(['meson', 'install', '-C', meson_build_dir])
setup(
name = 'Digest',
version = '0.2',
python_requires=">=3.8",
setup_requires=['setuptools', 'pybind11>=2.6.0', 'meson','ninja'],
install_requires=['pybind11>=2.6.0'],
packages=find_packages(),
ext_modules = [digest],
include_package_data=True,
# cmdclass={'build_ext': MesonBuildExt},
)