forked from tinyobjloader/tinyobjloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
95 lines (83 loc) · 3.32 KB
/
setup.py
File metadata and controls
95 lines (83 loc) · 3.32 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
import setuptools
import platform
with open("README.md", "r") as fh:
long_description = fh.read()
# Adapted from https://github.com/pybind/python_example/blob/master/setup.py
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 __init__(self, user=False, pep517=False):
self.user = user
self.pep517 = pep517
def __str__(self):
import os
import pybind11
interpreter_include_path = pybind11.get_include(self.user)
if self.pep517:
# When pybind11 is installed permanently in site packages, the headers
# will be in the interpreter include path above. PEP 517 provides an
# experimental feature for build system dependencies. When installing
# a package from a source distribvution, first its build dependencies
# are installed in a temporary location. pybind11 does not return the
# correct path for this condition, so we glom together a second path,
# and ultimately specify them _both_ in the include search path.
# https://github.com/pybind/pybind11/issues/1067
return os.path.abspath(
os.path.join(
os.path.dirname(pybind11.__file__),
"..",
"..",
"..",
"..",
"include",
os.path.basename(interpreter_include_path),
)
)
else:
return interpreter_include_path
ext_compile_args = ["-std=c++11"]
ext_link_args = []
# Developer option
#
# if platform.system() == "Darwin":
# # XCode10 or later does not support libstdc++, so we need to use libc++.
# # macosx-version 10.6 does not support libc++, so we require min macosx version 10.9.
# ext_compile_args.append("-stdlib=libc++")
# ext_compile_args.append("-mmacosx-version-min=10.9")
# ext_link_args.append("-stdlib=libc++")
# ext_link_args.append("-mmacosx-version-min=10.9")
# `tiny_obj_loader.cc` contains implementation of tiny_obj_loader.
m = setuptools.Extension(
"tinyobjloader",
extra_compile_args=ext_compile_args,
extra_link_args=ext_link_args,
sources=["bindings.cc", "tiny_obj_loader.cc"],
include_dirs=[
# Support `build_ext` finding tinyobjloader (without first running
# `sdist`).
"..",
# Support `build_ext` finding pybind 11 (provided it's permanently
# installed).
get_pybind_include(),
get_pybind_include(user=True),
# Support building from a source distribution finding pybind11 from
# a PEP 517 temporary install.
get_pybind_include(pep517=True),
],
language="c++",
)
setuptools.setup(
name="tinyobjloader",
version="0.1",
description="Python module for tinyobjloader",
long_description=long_description,
long_description_content_type="text/markdown",
author="Syoyo Fujita",
author_email="syoyo@lighttransport.com",
url="https://github.com/syoyo/tinyobjloader",
classifiers=["License :: OSI Approved :: MIT License"],
packages=setuptools.find_packages(),
ext_modules=[m],
)