Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython line tracing for coverage analysis #502

Open
ajfriend opened this issue Jun 9, 2020 · 2 comments
Open

Cython line tracing for coverage analysis #502

ajfriend opened this issue Jun 9, 2020 · 2 comments
Labels
Type: Question User question

Comments

@ajfriend
Copy link
Contributor

ajfriend commented Jun 9, 2020

I'm trying to figure out how to turn on code coverage for Cython files in my project here: https://github.com/uber/h3-py

Based on these notes:

it sounds like the first step is to define CYTHON_TRACE=1.

With scikit-build, I'm not sure if I should be doing this in the setup.py file, the cmake files, or elsewhere.

Has anyone else gotten this to work, and could offer some pointers? Thanks!

@jcfr
Copy link
Contributor

jcfr commented Jun 10, 2020

I suggest you try the following:

python setup.py build -- -DCYTHON_FLAGS:STRING="--directive profile=True" -DCMAKE_CXX_FLAGS:STRING=-DCYTHON_TRACE=1

or

CXXFLAGS=-DCYTHON_TRACE=1 python setup.py build -- -DCYTHON_FLAGS:STRING="--directive profile=True"

@cmpute
Copy link

cmpute commented Feb 3, 2021

I would also suggest that add these lines to your CMakeLists.txt:

if(DEFINED ENV{BUILD_COV})
  add_compile_definitions(CYTHON_TRACE=1)
  set(CYTHON_FLAGS "-X linetrace=True")
endif()

This way you can enable linetrace by set environment variable BUILD_COV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question User question
Projects
None yet
Development

No branches or pull requests

3 participants