Skip to content

Commit

Permalink
Add support for setup.py --debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed Feb 10, 2020
1 parent d603c14 commit 6115abc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
21 changes: 17 additions & 4 deletions apis/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@
import os
import shutil
import subprocess
import sys

args = sys.argv[:]
for arg in args:
if arg.find('--debug') == 0:
TILEDBVCF_DEBUG_BUILD = True
sys.argv.remove(arg)
else:
TILEDBVCF_DEBUG_BUILD = False

class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
Expand Down Expand Up @@ -84,7 +92,8 @@ def find_libtiledbvcf():
return None


def get_cmake_env_config():
def get_cmake_overrides():
import sys
conf = list()

key = "TILEDBVCF_CMAKE_PREFIX_PATH"
Expand All @@ -97,6 +106,9 @@ def get_cmake_env_config():
if val:
conf.append("-DTILEDBVCF_FORCE_EXTERNAL_HTSLIB={}".format(val))

if TILEDBVCF_DEBUG_BUILD :
conf.append("-DCMAKE_BUILD_TYPE=Debug")

return conf

def build_libtiledbvcf():
Expand All @@ -114,7 +126,7 @@ def build_libtiledbvcf():
'-DCMAKE_BUILD_TYPE=Release',
src_dir]

env_conf = get_cmake_env_config()
env_conf = get_cmake_overrides()
cmake_cmd.extend(env_conf)

build_cmd = ['make', '-j{}'.format(multiprocessing.cpu_count() or 2)]
Expand Down Expand Up @@ -182,7 +194,9 @@ class BuildExtCmd(build_ext):
"""Builds the Pybind11 extension module."""

def build_extensions(self):
opts = ['-std=c++11', '-g', '-O2']
opts = ['-std=c++11', '-g']
if not TILEDBVCF_DEBUG_BUILD:
opts.append('-O2')
link_opts = []
for ext in self.extensions:
ext.extra_compile_args = opts
Expand All @@ -208,7 +222,6 @@ def run(self):
find_or_build_libtiledbvcf(self)
bdist_wheel.run(self)


setup(
name='tiledbvcf',
version='0.1.0',
Expand Down
3 changes: 2 additions & 1 deletion apis/python/tests/test_tiledbvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def test_missing_sample_raises_exception(test_ds):
with pytest.raises(RuntimeError):
test_ds.count(samples=['abcde'])


# TODO remove skip
@pytest.mark.skip
def test_bad_contig_raises_exception(test_ds):
with pytest.raises(RuntimeError):
test_ds.count(regions=['chr1:1-1000000'])
Expand Down

0 comments on commit 6115abc

Please sign in to comment.