question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setuptools using CC for compiling C++ files

See original GitHub issue

When compiling an extension like

ext_modules = [
    Extension(
        "_foobar",
        [
           # ...
        ],
        language="C++",
    )
]

setuptools appears to use the CC environment variable when compiling the project. E.g.,

CC=clang++ pip3 install . --user --verbose

will switch to clang++. Since this is a C++ project (as specified in the extension), I would have expected CXX to have an effect, and not CC.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ryandesigncommented, Jun 18, 2020

So is there something that projects need to configure in order to get C++ files compiled with a C++ compiler, or is that simply not possible in setuptools right now, just as it is not possible in distutils? If it’s just not possible, can it please be made possible? (Maybe the patches in the distutils bug report are a starting point?) It is imperative that users (and package management systems acting on their behalf) be able to tell setuptools which C++ compiler to use to compile C++ files and what additional CXXFLAGS to set when doing so.

2reactions
pgansslecommented, Oct 31, 2019

Dear @jaraco and @pganssle it seems that no checks are implemented on the language variable (I can set it to language=‘jadshad’ and the installation process would still work). If you point me in the right direction (where to look in the repo), I would be happy to try to tackle this issue. Thank you.

Can you make a separate issue for this, @filippo82? I don’t want the discussion to be lost in the shuffle of this ticket investigation. I think we need to discuss whether it is feasible to be stricter about the specified language and if so what that would look like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiling & installing C executable using python's setuptools ...
The source for that external executable is part of my python module, distributed as a .tar.gz file. Is there a way of unzipping,...
Read more >
4. Building C and C++ Extensions — Python 3.11.1 ...
A C extension for CPython is a shared library (e.g. a.so file on Linux,.pyd on Windows), which exports an initialization function. To be...
Read more >
Building Extension Modules - Setuptools
To instruct setuptools to compile the foo.c file into the extension module ... CC , CPP , CXX , and LDSHARED are set,...
Read more >
Setuptools can't find my GCC compiler - Numba Discussion
I am attempting to include my AOT-compiled extensions in my setup.py. from ... since I definitely have a C/C++ compiler on my system,...
Read more >
Building a Python C Extension Module
This is a basic C program that uses fputs() to write a string to a file stream: ... use gcc or any other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found