MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / get_pybind_include

Class get_pybind_include

engine/3rdparty/tinyobjloader/python/setup.py:10–47  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

8
9# Adapted from https://github.com/pybind/python_example/blob/master/setup.py
10class get_pybind_include(object):
11 """Helper class to determine the pybind11 include path
12 The purpose of this class is to postpone importing pybind11
13 until it is actually installed, so that the ``get_include()``
14 method can be invoked. """
15
16 def __init__(self, user=False, pep517=False):
17 self.user = user
18 self.pep517 = pep517
19
20 def __str__(self):
21 import os
22 import pybind11
23
24 interpreter_include_path = pybind11.get_include(self.user)
25
26 if self.pep517:
27 # When pybind11 is installed permanently in site packages, the headers
28 # will be in the interpreter include path above. PEP 517 provides an
29 # experimental feature for build system dependencies. When installing
30 # a package from a source distribvution, first its build dependencies
31 # are installed in a temporary location. pybind11 does not return the
32 # correct path for this condition, so we glom together a second path,
33 # and ultimately specify them _both_ in the include search path.
34 # https://github.com/pybind/pybind11/issues/1067
35 return os.path.abspath(
36 os.path.join(
37 os.path.dirname(pybind11.__file__),
38 "..",
39 "..",
40 "..",
41 "..",
42 "include",
43 os.path.basename(interpreter_include_path),
44 )
45 )
46 else:
47 return interpreter_include_path
48
49
50# unix = default compiler name?

Callers 1

setup.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected