'Trouble building conda recipe for python/c++ package
This is my first conda recipe, so please bear with me.
I'm trying to create a conda package for the tool NeuSomatic (https://github.com/bioinform/neusomatic). This package requires a build, but to run you just call python files on the command line, e.g. (from repo Readme):
python train.py \
--candidates_tsv work_train/dataset/*/candidates*.tsv \
--out work_train \
--num_threads 10 \
--batch_size 100
What I want to have the recipe do, is be able to just call the separate python packages from the command line after installation, e.g.
neusomatic-train \
--candidates_tsv work_train/dataset/*/candidates*.tsv \
--out work_train \
--num_threads 10 \
--batch_size 100
I thought I could get this right by using entry-points in the build (see meta.yaml example below), but these python files get some arguments in the if __name__ == "__main__" section (see https://github.com/bioinform/neusomatic/blob/master/neusomatic/python/train.py for example).
What am I doing wrong here?
meta.yaml:
{% set version = "0.2.1" %}
package:
name: neusomatic
version: {{ version }}
about:
home: https://github.com/bioinform/neusomatic
license: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
summary: NeuSomatic is based on deep convolutional neural networks for accurate somatic mutation detection.
With properly trained models, it can robustly perform across sequencing platforms, strategies, and
conditions. NeuSomatic summarizes and augments sequence alignments in a novel way and incorporates
multi-dimensional features to capture variant signals effectively. It is not only a universal but
also accurate somatic mutation detection method.
source:
fn: v{{ version }}.tar.gz
url: https://github.com/bioinform/neusomatic/archive/refs/tags/v{{ version }}.tar.gz
md5: d315e16e825e1fbad71bfd7331ab9c3c
build:
number: 1
skip: False
requirements:
build:
- cmake =3.13.2
entry_points:
- neusomatic-preprocess = neusomatic.preprocess
- neusomatic-train = neusomatic.train
- neusomatic-postprocess = neusomatic.postprocess
- neusomatic-call = neusomatic.call
run:
- python >=3.7
- pytorch =1.1.0
- torchvision =0.3.0
- pybedtools =0.8.0
- pysam =0.15.2
- zlib =1.2.11
- numpy =1.15.4
- scipy =1.2.0
- imageio =2.5.0
- biopython =1.73
- cudatoolkit =9.0
- tabix =0.2.6
- bedtools =2.27.1
- samtools =1.9
build.sh:
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P)"
rm -rf $DIR/third_party/SeqLib/ $DIR/third_party/seqan/ $DIR/neusomatic/build
pushd $DIR/neusomatic
mkdir build
pushd build
cmake ..
make
popd
popd
Solution 1:[1]
I managed to find a solution, by using some bash trickery in the build.sh script:
build.sh:
#!/bin/bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P)"
rm -rf $DIR/third_party/SeqLib/ $DIR/third_party/seqan/ $DIR/neusomatic/build
pushd $DIR/neusomatic
mkdir build
pushd build
cmake ..
make
popd
popd
### SOLUTION BELOW ###
outdir=$PREFIX/share/$PKG_NAME-$PKG_VERSION-$PKG_BUILDNUM
mkdir -p $outdir
mkdir -p $PREFIX/bin
cp -R neusomatic $outdir/neusomatic
ls -l $outdir
ln -s $outdir/neusomatic/python/preprocess.py $PREFIX/bin/neusomatic-preprocess
ln -s $outdir/neusomatic/python/train.py $PREFIX/bin/neusomatic-train
ln -s $outdir/neusomatic/python/call.py $PREFIX/bin/neusomatic-call
ln -s $outdir/neusomatic/python/postprocess.py $PREFIX/bin/neusomatic-postprocess
chmod 0755 "${PREFIX}/bin/neusomatic-preprocess"
chmod 0755 "${PREFIX}/bin/neusomatic-train"
chmod 0755 "${PREFIX}/bin/neusomatic-call"
chmod 0755 "${PREFIX}/bin/neusomatic-postprocess"
meta.yaml:
{% set version = "0.2.1" %}
package:
name: neusomatic
version: {{ version }}
about:
home: https://github.com/bioinform/neusomatic
license: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
summary: NeuSomatic is based on deep convolutional neural networks for accurate somatic mutation detection.
With properly trained models, it can robustly perform across sequencing platforms, strategies, and
conditions. NeuSomatic summarizes and augments sequence alignments in a novel way and incorporates
multi-dimensional features to capture variant signals effectively. It is not only a universal but
also accurate somatic mutation detection method.
source:
fn: v{{ version }}.tar.gz
url: https://github.com/bioinform/neusomatic/archive/refs/tags/v{{ version }}.tar.gz
md5: d315e16e825e1fbad71bfd7331ab9c3c
build:
number: 1
skip: False
requirements:
build:
- cmake =3.13.2
run:
- python >=3.7
- pytorch =1.1.0
- torchvision =0.3.0
- pybedtools =0.8.0
- pysam =0.15.2
- zlib =1.2.11
- numpy =1.15.4
- scipy =1.2.0
- imageio =2.5.0
- biopython =1.73
- cudatoolkit =9.0
- tabix =0.2.6
- bedtools =2.27.1
- samtools =1.9
test:
commands:
- neusomatic-preprocess --help 2> /dev/null
- neusomatic-train --help 2> /dev/null
- neusomatic-call --help 2> /dev/null
- neusomatic-postprocess --help 2> /dev/null
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ljc |
