|
1 | | -import re |
2 | | -import pathlib |
3 | | -import platform |
4 | | - |
5 | | -from pybind11.setup_helpers import Pybind11Extension |
6 | | -from setuptools.command.build_ext import build_ext |
7 | | - |
8 | | -exclude = ['src/tinymesh/ext'] |
9 | | -sources = pathlib.Path().glob('src/**/*.cpp') |
10 | | -sources = [str(path).replace('\\', '/') for path in sources] |
11 | | -sources = [path for path in sources if all([not re.search(e, path) for e in exclude])] |
12 | | - |
13 | | -include_dirs = [ |
14 | | - 'src/tinymesh', |
15 | | - 'src/tinymesh/ext/tinyobjloader', |
16 | | - 'src/tinymesh/ext/tinyply/source', |
17 | | - 'src/tinymesh/ext/eigen', |
18 | | -] |
19 | | - |
20 | | -extra_compile_args = [] |
21 | | -extra_link_args = [] |
22 | | -define_macros = [('TINYMESH_PYTHON_MODULE', 1)] |
23 | | -if platform.system() == "Windows": |
24 | | - define_macros.append(('_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING', 1)) |
25 | | -elif platform.system() == "Darwin": |
26 | | - extra_compile_args.extend([ |
27 | | - '-std=c++17', |
28 | | - '-mmacosx-version-min=10.15', |
29 | | - ]) |
30 | | - # extra_link_args.extend([ |
31 | | - # '-lstdc++fs', |
32 | | - # ]) |
33 | | -else: |
34 | | - extra_compile_args.extend([ |
35 | | - '-std=c++17', |
36 | | - ]) |
37 | | - extra_link_args.extend([ |
38 | | - '-lstdc++fs', |
39 | | - ]) |
40 | | - |
41 | | -ext_modules = [ |
42 | | - Pybind11Extension('tinymesh', |
43 | | - sources, |
44 | | - language='c++', |
45 | | - include_dirs=include_dirs, |
46 | | - extra_compile_args=extra_compile_args, |
47 | | - extra_link_args=extra_link_args, |
48 | | - define_macros=define_macros) |
49 | | -] |
50 | | - |
51 | | - |
52 | | -def build(setup_kwargs): |
53 | | - setup_kwargs.update({ |
54 | | - 'ext_modules': ext_modules, |
55 | | - 'cmdclass': { |
56 | | - 'build_ext': build_ext |
57 | | - }, |
58 | | - }) |
| 1 | +import re |
| 2 | +import pathlib |
| 3 | +import platform |
| 4 | + |
| 5 | +from pybind11.setup_helpers import Pybind11Extension |
| 6 | +from setuptools.command.build_ext import build_ext |
| 7 | + |
| 8 | +exclude = ['src/tinymesh/ext'] |
| 9 | +sources = pathlib.Path().glob('src/**/*.cpp') |
| 10 | +sources = [str(path).replace('\\', '/') for path in sources] |
| 11 | +sources = [path for path in sources if all([not re.search(e, path) for e in exclude])] |
| 12 | + |
| 13 | +include_dirs = [ |
| 14 | + 'src/tinymesh', |
| 15 | + 'src/tinymesh/ext/tinyobjloader', |
| 16 | + 'src/tinymesh/ext/tinyply/source', |
| 17 | + 'src/tinymesh/ext/eigen', |
| 18 | + 'src/tinymesh/ext/spectra/include', |
| 19 | +] |
| 20 | + |
| 21 | +extra_compile_args = [] |
| 22 | +extra_link_args = [] |
| 23 | +define_macros = [('TINYMESH_PYTHON_MODULE', 1)] |
| 24 | +if platform.system() == "Windows": |
| 25 | + define_macros.append(('_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING', 1)) |
| 26 | +elif platform.system() == "Darwin": |
| 27 | + extra_compile_args.extend([ |
| 28 | + '-std=c++17', |
| 29 | + '-mmacosx-version-min=10.15', |
| 30 | + ]) |
| 31 | + # extra_link_args.extend([ |
| 32 | + # '-lstdc++fs', |
| 33 | + # ]) |
| 34 | +else: |
| 35 | + extra_compile_args.extend([ |
| 36 | + '-std=c++17', |
| 37 | + ]) |
| 38 | + extra_link_args.extend([ |
| 39 | + '-lstdc++fs', |
| 40 | + ]) |
| 41 | + |
| 42 | +ext_modules = [ |
| 43 | + Pybind11Extension('tinymesh', |
| 44 | + sources, |
| 45 | + language='c++', |
| 46 | + include_dirs=include_dirs, |
| 47 | + extra_compile_args=extra_compile_args, |
| 48 | + extra_link_args=extra_link_args, |
| 49 | + define_macros=define_macros) |
| 50 | +] |
| 51 | + |
| 52 | + |
| 53 | +def build(setup_kwargs): |
| 54 | + setup_kwargs.update({ |
| 55 | + 'ext_modules': ext_modules, |
| 56 | + 'cmdclass': { |
| 57 | + 'build_ext': build_ext |
| 58 | + }, |
| 59 | + }) |
0 commit comments