MCPcopy Create free account
hub / github.com/pybind/pybind11 / __init__

Method __init__

pybind11/setup_helpers.py:122–158  ·  view source on GitHub ↗
(self, *args: Any, **kwargs: Any)

Source from the content-addressed store, hash-verified

120 self.extra_link_args[:0] = flags
121
122 def __init__(self, *args: Any, **kwargs: Any) -> None:
123 self._cxx_level = 0
124 cxx_std = kwargs.pop("cxx_std", 0)
125
126 if "language" not in kwargs:
127 kwargs["language"] = "c++"
128
129 include_pybind11 = kwargs.pop("include_pybind11", True)
130
131 super().__init__(*args, **kwargs)
132
133 # Include the installed package pybind11 headers
134 if include_pybind11:
135 # If using setup_requires, this fails the first time - that's okay
136 try:
137 import pybind11
138
139 pyinc = pybind11.get_include()
140
141 if pyinc not in self.include_dirs:
142 self.include_dirs.append(pyinc)
143 except ModuleNotFoundError:
144 pass
145
146 self.cxx_std = cxx_std
147
148 cflags = []
149 if WIN:
150 cflags += ["/EHsc", "/bigobj"]
151 else:
152 cflags += ["-fvisibility=hidden"]
153 env_cflags = os.environ.get("CFLAGS", "")
154 env_cppflags = os.environ.get("CPPFLAGS", "")
155 c_cpp_flags = shlex.split(env_cflags) + shlex.split(env_cppflags)
156 if not any(opt.startswith("-g") for opt in c_cpp_flags):
157 cflags += ["-g0"]
158 self._add_cflags(cflags)
159
160 @property
161 def cxx_std(self) -> int:

Callers

nothing calls this directly

Calls 4

_add_cflagsMethod · 0.95
__init__Method · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected