Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion cppimport/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,26 @@ def setup_pybind11(cfg):
import pybind11

cfg["include_dirs"] += [pybind11.get_include(), pybind11.get_include(True)]

# Prefix with c++11 arg instead of suffix so that if a user specifies c++14
# (or later!) then it won't be overridden.
cfg["compiler_args"] = ["-std=c++11", "-fvisibility=hidden"] + cfg["compiler_args"]
prefix_args = ["-std=c++11", "-fvisibility=hidden"]
# MSVC compiler do not support "-std=c++11" nor "-fvisibility=hidden"
if os.name == "nt":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels a little awkward. what's the motivation for building the list and then remove entries versus just pushing the list inside the conditional?

if os.name == 'nt' and ...
    prefix_args = []
else:
    prefix_args = ["-std=c++11", "-fvisibility=hidden"]

import sys
if sys.version_info[0] >=3 and sys.version_info[1] > 11:
from setuptools._distutils import ccompiler
else:
from distutils import ccompiler
compiler = ccompiler.new_compiler()
if compiler.compiler_type == "msvc":
for k in ["-std=c++11", "-fvisibility=hidden"]: # remove unsupported flags
try:
prefix_args.remove(k)
except ValueError:
pass

cfg["compiler_args"] = prefix_args + cfg["compiler_args"]


def get_rendered_source_filepath(filepath):
Expand Down