Skip to content

Commit d5868ce

Browse files
committed
Avoid using wrong compiler command on Windows
1 parent 00cf79f commit d5868ce

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

bindings/pyroot/pythonizations/python/ROOT/__init__.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515
import subprocess
1616
import textwrap
1717

18-
try:
19-
# Mimic what cling does to find standard headers include path
20-
cmd = shlex.split('c++ -xc++ -E -v /dev/null')
21-
env = os.environ
22-
env.update({'LC_ALL': 'C'})
23-
subprocess.run(cmd, env=env, check=True,
24-
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
25-
except Exception as e:
26-
msg = (
27-
"Could not find a C++ compiler when importing ROOT. Make sure a C++ compiler as well as the C++ standard "
28-
"libraries are installed. For example, run `[apt,dnf] install g++` or follow similar instructions for your "
29-
"distribution. For more info, visit https://root.cern/install/dependencies"
30-
)
31-
raise ImportError(textwrap.fill(msg, width=80)) from e
18+
import platform
19+
if platform.system() != "Windows":
20+
try:
21+
# Mimic what cling does to find standard headers include path
22+
cmd = shlex.split('c++ -xc++ -E -v /dev/null')
23+
env = os.environ
24+
env.update({'LC_ALL': 'C'})
25+
subprocess.run(cmd, env=env, check=True,
26+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
27+
except Exception as e:
28+
msg = (
29+
"Could not find a C++ compiler when importing ROOT. Make sure a C++ compiler as well as the C++ standard "
30+
"libraries are installed. For example, run `[apt,dnf] install g++` or follow similar instructions for your "
31+
"distribution. For more info, visit https://root.cern/install/dependencies"
32+
)
33+
raise ImportError(textwrap.fill(msg, width=80)) from e
3234

3335
# Prevent cppyy's check for the PCH
3436
os.environ["CLING_STANDARD_PCH"] = "none"

0 commit comments

Comments
 (0)