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.

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:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ryandesigncommented, Jun 28, 2020

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++?

0reactions
ryandesigncommented, Jun 29, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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