Extension ignores CXXFLAGS
See original GitHub issue(I’m not sure if I should report this here, or at the Cython project.)
When using Extension (I used it for Cython, not sure about other cases), the CXXFLAGS variable is ignored during compile. This is a problem because it is normally set as an environmental variable for OSX/clang instead of CFLAGS (which is the norm for linux/gcc). For example, conda will not build C++11 code at all without the extra options present in CXXFLAGS.
I had to write a workaround to insert the CXXFLAGS into the Extension through the extra_compile_args parameter. Example code below:
def get_cxxflags():
"""If the CXXFLAGS variable is defined (clang/osx) then get it"""
return os.environ.get("CXXFLAGS", "").split()
....
ext_modules=[Extension(
"x.cext",
sources=["x/cext.pyx"] + glob.glob("x/*.cpp"),
depends=glob.glob("x/*.hpp"),
extra_compile_args=get_cxxflags(),
language="c++",
),
Software tested (from conda):
cython 0.26.1 py36hd51f8eb_0
python 3.6.3 h5ce8c04_4
setuptools 36.5.0 py36h2134326_0
...
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Why does scons ignore my CXXFlags in SConscript
This undefined reference issue can be resolved with the '-ldl' compile argument, but for some reason, scons won't append it. How do I...
Read more >Tree - rpms/redhat-rpm-config - Fedora Package Sources
(This flag is added to both CFLAGS and CXXFLAGS ; C compilations will simply ignore it.) -fstack-protector-strong : Instrument functions to detect stack-based ......
Read more >Writing R Extensions - The Comprehensive R Archive Network
The ' ZipData ' logical field has been ignored since R 2.13.0. ... names (such as CXX17 ) appropriate to the standard, but...
Read more >Anaconda compiler tools — conda-build 3.23.3+5.g16ab6a5b ...
When building C++ extensions with Cython, CXXFLAGS must be similarly modified. ... itself understands its own sysroot, CMake insists on ignoring that.
Read more >CXXFLAGS — CMake 3.25.1 Documentation
For any configuration run (including the first), the environment variable will be ignored if the CMAKE_CXX_FLAGS variable is already defined.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So what’s going to happen with this? How many more decades do we need to wait for Python to properly support modules written in C++?
I’m probably not the best person to do it. Besides being very busy with many other projects, I have no knowledge of the distutils/setuptools source code and only a very basic understanding of python. I would suggest that someone already familiar with those would be a better choice. Perhaps a good starting point is to look at the patches submitted to the distutils bug report to see if any of that code is still applicable to setuptools.