From 2cc4b66ec91350379fb36dc6774d0f7fbda1ae1c Mon Sep 17 00:00:00 2001 From: Gaik Tamazian Date: Mon, 24 Aug 2015 16:21:45 +0300 Subject: [PATCH 1/5] Option to specify path to executable files --- demo/run_demo_analysis.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/demo/run_demo_analysis.py b/demo/run_demo_analysis.py index 6df4d78..4abcfc7 100755 --- a/demo/run_demo_analysis.py +++ b/demo/run_demo_analysis.py @@ -30,12 +30,17 @@ parser.add_argument('-c', '--clear', action='store_true', help='remove files created by the demo') + parser.add_argument('-e', '--executable', default='.', + help='the path to the Cookiecutter executable ' + 'file') + args = parser.parse_args() fastq_file1 = args.fastq1 fastq_file2 = args.fastq2 data = { + "cookiecutter": os.path.join(args.executable, 'cookiecutter'), "fastq1": fastq_file1, "fastq2": fastq_file2, "output_dir_1a": "../demo/temp_results_remove", @@ -54,16 +59,16 @@ e='removing alpha satDNA') command_launches = dict( - a='cookiecutter remove -1 %(fastq1)s -2 %(fastq2)s -o %(' + a='%(cookiecutter)s remove -1 %(fastq1)s -2 %(fastq2)s -o %(' 'output_dir_1a)s --fragments ../data/illumina.dat', - b='cookiecutter rm_reads -1 %(fastq1)s -2 %(fastq2)s -o %(' + b='%(cookiecutter)s rm_reads -1 %(fastq1)s -2 %(fastq2)s -o %(' 'output_dir_1b)s --polygc 13 --length 50 --fragments ' '../data/illumina.dat --dust_cutoff 3 --dust_k 4 --dust', - c='cookiecutter remove -i %(fastq1)s -o %(' + c='%(cookiecutter)s remove -i %(fastq1)s -o %(' 'output_dir_1c)s --fragments ../data/rdna.dat', - d='cookiecutter extract -1 %(fastq1)s -2 %(fastq2)s -o %(' + d='%(cookiecutter)s extract -1 %(fastq1)s -2 %(fastq2)s -o %(' 'output_dir_1d)s --fragments ../data/mtdna.dat', - e='cookiecutter separate -1 %(fastq1)s -2 %(fastq2)s -o %(' + e='%(cookiecutter)s separate -1 %(fastq1)s -2 %(fastq2)s -o %(' 'output_dir_1e)s --fragments ../data/alpha.dat' ) From bd8d2a8328e2f01011a91acdec4616aa6d804924 Mon Sep 17 00:00:00 2001 From: Gaik Tamazian Date: Mon, 24 Aug 2015 16:43:48 +0300 Subject: [PATCH 2/5] README updated --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index dc71583..939b6be 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,24 @@ Cookiecutter is designed for use on Linux/UNIX and OS X systems. ## Installation +You may install Cookiecutter from a binary package or compile it from +source codes. + +### Binary package + +Unpack the downloaded archive using tar: + +``` +tar -xvzf cookiecutter_osx.tar.gz +``` + +Executable files are located in the `bin` subdirectory. You may +either launch Cookiecutter from the directory to which the archive was +unpacked or copy executable files to any directory specified in the +`PATH` variable of your environment. + +### Source codes + The package should be compiled from its source code using the provided Makefile in the following way. From f3aa8ae5cb8539dac6ee136013e3ff89e04dc0c8 Mon Sep 17 00:00:00 2001 From: Gaik Tamazian Date: Mon, 24 Aug 2015 17:50:50 +0300 Subject: [PATCH 3/5] Script to prepare binary packages --- create_package.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 create_package.sh diff --git a/create_package.sh b/create_package.sh new file mode 100755 index 0000000..4314c3c --- /dev/null +++ b/create_package.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -eu +set -o pipefail + +if [ $# -lt 1 ]; then + echo Please specify the output file name. + echo For example: ./create_package ~/Desktop/cookiecutter_osx.tar.gz + exit 1 +fi + +OUTPUT_FILE="$1" +PACKAGE_NAME=$( basename "$OUTPUT_FILE" ) +PACKAGE_NAME=$( echo "$PACKAGE_NAME" | sed "s/\..*//" ) + +TEMPDIR=$( mktemp -d "/tmp/${PACKAGE_NAME}.XXXXXX" ) || exit 1 + +# compile binary files +cd src +make +cd .. + +# copy executable files +mkdir "${TEMPDIR}/bin" +for FILE in cookiecutter extract remove separate rm_reads; do + cp "./src/${FILE}" "${TEMPDIR}/bin/${FILE}" +done + +# copy demo and data directories +for DIR in data demo; do + cp -R "$DIR" "${TEMPDIR}/${DIR}" +done + +# adjust the path for executable files in the demo script +sed -i "s#default='.'#default='..\/bin/'#" \ + ${TEMPDIR}/demo/run_demo_analysis.py + +# copy LICENSE and README files +for FILE in LICENSE README.md; do + cp "$FILE" "${TEMPDIR}/${FILE}" +done + +# create a gzipped TAR archive +TEMPFILE=$( tempfile ) +tar -C "/tmp" -cvf "${TEMPFILE}.tar" $( basename "$TEMPDIR" ) +gzip -9 "${TEMPFILE}.tar" +mv "${TEMPFILE}.tar.gz" "$OUTPUT_FILE" + +# remove compiled files +cd src +make clean +cd .. + +rm -r "$TEMPDIR" + From 24bcbc5c0131fff5eface9d93c2d356ebe318f64 Mon Sep 17 00:00:00 2001 From: Gaik Tamazian Date: Mon, 24 Aug 2015 18:11:46 +0300 Subject: [PATCH 4/5] Use binaries in Cookiecutter directory first --- src/cookiecutter | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/cookiecutter b/src/cookiecutter index b3a105d..65043b8 100755 --- a/src/cookiecutter +++ b/src/cookiecutter @@ -433,19 +433,14 @@ def verify_binaries(): Check if Cookiecutter binaries are present in the same directory that contains the wrapper script. """ - for i in program_names.itervalues(): - path = os.path.join(os.path.dirname(os.path.realpath( - __file__)), i) - if not os.path.isfile(path) or not os.access(path, os.X_OK): - return False - wrapper_path = os.path.dirname(os.path.realpath(__file__)) - # if binaries are present in the PATH directory, mofity the way - # they are called + for i in program_names.keys(): - if not is_path_binary(program_names[i]): - program_names[i] = os.path.join(wrapper_path, - program_names[i]) + path = os.path.join(wrapper_path, program_names[i]) + if not os.path.isfile(path) or not os.access(path, os.X_OK): + return False + else: + program_names[i] = path return True From 8194250a3cbf775ae0aea30890aa4e95377df605 Mon Sep 17 00:00:00 2001 From: Gaik Tamazian Date: Mon, 24 Aug 2015 18:27:28 +0300 Subject: [PATCH 5/5] Missing binaries message updated --- src/cookiecutter | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cookiecutter b/src/cookiecutter index 65043b8..accc9b7 100755 --- a/src/cookiecutter +++ b/src/cookiecutter @@ -712,8 +712,11 @@ def cookiecutter(): if __name__ == '__main__': if not verify_binaries(): - message = 'Missing Cookiecutter binaries, please ' \ - 'install the program using \'make && make ' \ + message = 'Error: missing Cookiecutter binaries! If you use a ' \ + 'binary package, please check that all executable ' \ + 'files are in the same directory with ' \ + 'cookiecutter. If you downloaded source codes, ' \ + 'please install the program using \'make && make ' \ 'install\' or launch it in the source ' \ 'directory after running \'make\'. If you do not have ' \ 'privileges to install to the system directory, you may ' \