
Python lets you do things like ```python "these are " "one string" 'so are' "these" ``` This can be useful for breaking strings over multiple lines. It also often happens unintentionally and indicates that there are subtle errors in the code. There are a lot of variant descriptions that have implicit concatenation harmlessly due to refactors, e.g.: ```python variant("myvariant", default=True, description="this used to be" "on two lines") ``` But there are also real bugs, like this, where the author probably omitted a comma and didn't notice that `black` reformatted the implicit concatenation onto one line: ```python args = [ "--with-thing", "--with-second-thing" "--with-third-thing", ] ``` And other bugs like this, where the author probably intended to add a space, but didn't: ```python options = "${CFLAGS}" "${SPECIAL_PIC_OPTION}" ``` Some things are harmless but confusing: ```python "first part of string {0} " "second part {1}".format("zero", "one") ``` It's not broken. String concatenation happens *before* the `format()` call, and the whole string is formatted. But it sure is hard to read. Unfortunately, you can't detect this stuff with an AST pass, as implicit concatenation is done at the parsing phase. I had to detect this with grep: ```console > grep -l '^[^"]*"[^"]*" "' */package.py > grep -l "^[^']*'[^']*' '" */package.py ``` - [x] Get rid of nearly all implicit string concatenation in packages Signed-off-by: Todd Gamblin <tgamblin@llnl.gov>
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
|
#
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
from spack.package import *
|
|
|
|
|
|
class Cnvnator(MakefilePackage):
|
|
"""A tool for CNV discovery and genotyping
|
|
from depth-of-coverage by mapped reads."""
|
|
|
|
homepage = "https://github.com/abyzovlab/CNVnator"
|
|
url = "https://github.com/abyzovlab/CNVnator/archive/v0.3.3.tar.gz"
|
|
|
|
version("0.3.3", sha256="58c5acf61f9a1e5febf546c196f8917a5e084b729e5c4cfd3eba83471b3fe5c1")
|
|
|
|
depends_on("cxx", type="build") # generated
|
|
|
|
depends_on("samtools@:1.13")
|
|
depends_on("htslib")
|
|
depends_on("root")
|
|
depends_on("bzip2")
|
|
depends_on("curl")
|
|
depends_on("xz")
|
|
depends_on("zlib-api")
|
|
depends_on("libdeflate")
|
|
depends_on("openssl")
|
|
|
|
def edit(self, spec, prefix):
|
|
makefile = FileFilter("Makefile")
|
|
# Replace -fopenmp with self.compiler.openmp_flag
|
|
makefile.filter("-fopenmp", self.compiler.openmp_flag)
|
|
# Replace CXX with CXXFLAGS
|
|
cxx11_flag = self.compiler.cxx11_flag
|
|
makefile.filter(
|
|
"CXX.*=.*", rf"CXXFLAGS = -DCNVNATOR_VERSION=\"$(VERSION)\" $(OMPFLAGS) {cxx11_flag}"
|
|
)
|
|
makefile.filter("$(CXX)", "$(CXX) $(CXXFLAGS)", string=True)
|
|
# Replace -I$(SAMDIR) with -I$(SAMINC)
|
|
makefile.filter("-I$(SAMDIR)", "-I$(SAMINC)", string=True)
|
|
|
|
# Link more libs
|
|
ldflags = [
|
|
spec["zlib-api"].libs.ld_flags,
|
|
spec["bzip2"].libs.ld_flags,
|
|
spec["curl"].libs.ld_flags,
|
|
spec["xz"].libs.ld_flags,
|
|
spec["libdeflate"].libs.ld_flags,
|
|
spec["openssl"].libs.ld_flags,
|
|
]
|
|
makefile.filter("^override LIBS.*", "override LIBS += {0}".format(" ".join(ldflags)))
|
|
|
|
def build(self, spec, prefix):
|
|
make(
|
|
"ROOTSYS={0}".format(spec["root"].prefix),
|
|
"SAMINC={0}".format(spec["samtools"].prefix.include),
|
|
"SAMDIR={0}".format(spec["samtools"].prefix.lib),
|
|
"HTSDIR={0}".format(spec["htslib"].prefix.lib),
|
|
)
|
|
|
|
def install(self, spec, prefix):
|
|
mkdir(prefix.bin)
|
|
install("cnvnator", prefix.bin)
|