diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..574116c --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +ctdconverter.egg-info/ diff --git a/debian/patches/add_setup.py.patch b/debian/patches/add_setup.py.patch index 7d1636c..9a575b5 100644 --- a/debian/patches/add_setup.py.patch +++ b/debian/patches/add_setup.py.patch @@ -1,10 +1,30 @@ From: Michael R. Crusoe Subject: Add setup.py Forwarded: https://github.com/WorkflowConversion/CTDConverter/pull/40 +--- ctdconverter.orig/common/utils.py ++++ ctdconverter/common/utils.py +@@ -7,7 +7,7 @@ + from string import strip + from logger import info, error, warning + +-from common.exceptions import ApplicationException ++from .exceptions import ApplicationException + from CTDopts.CTDopts import CTDModel, ParameterGroup + + --- ctdconverter.orig/convert.py +++ ctdconverter/convert.py -@@ -8,7 +8,7 @@ - from common.exceptions import ApplicationException, ModelError +@@ -1,14 +1,14 @@ + import os + import sys + import traceback +-import common.utils as utils ++import .common.utils as utils + + from argparse import ArgumentParser + from argparse import RawDescriptionHelpFormatter +-from common.exceptions import ApplicationException, ModelError ++from . import common.exceptions as exceptions __all__ = [] -__version__ = 2.0 @@ -12,6 +32,38 @@ __date__ = '2014-09-17' __updated__ = '2017-08-09' +@@ -222,13 +222,13 @@ + print("Interrupted...") + return 0 + +- except ApplicationException, e: ++ except exceptions.ApplicationException, e: + traceback.print_exc() + utils.error("CTDConverter could not complete the requested operation.", 0) + utils.error("Reason: " + e.msg, 0) + return 1 + +- except ModelError, e: ++ except exceptions.ModelError, e: + traceback.print_exc() + utils.error("There seems to be a problem with one of your input CTDs.", 0) + utils.error("Reason: " + e.msg, 0) +@@ -250,13 +250,13 @@ + # if input is a single file, we expect output to be a file (and not a dir that already exists) + if len(args.input_files) == 1: + if os.path.isdir(args.output_destination): +- raise ApplicationException("If a single input file is provided, output (%s) is expected to be a file " ++ raise exceptions.ApplicationException("If a single input file is provided, output (%s) is expected to be a file " + "and not a folder.\n" % args.output_destination) + + # if input is a list of files, we expect output to be a folder + if len(args.input_files) > 1: + if not os.path.isdir(args.output_destination): +- raise ApplicationException("If several input files are provided, output (%s) is expected to be an " ++ raise exceptions.ApplicationException("If several input files are provided, output (%s) is expected to be an " + "existing directory.\n" % args.output_destination) + + # check that the provided input files, if provided, contain a valid file path @@ -269,4 +269,4 @@ @@ -19,9 +71,42 @@ - sys.exit(main()) \ No newline at end of file + sys.exit(main()) +--- ctdconverter.orig/cwl/converter.py ++++ ctdconverter/cwl/converter.py +@@ -12,7 +12,7 @@ + import ruamel.yaml as yaml + + from CTDopts.CTDopts import _InFile, _OutFile, ParameterGroup, _Choices, _NumericRange, _FileFormat, ModelError, _Null +-from common import utils, logger ++from ..common import utils, logger + + # all cwl-related properties are defined here + +--- ctdconverter.orig/galaxy/converter.py ++++ ctdconverter/galaxy/converter.py +@@ -8,8 +8,8 @@ + from lxml import etree + from lxml.etree import SubElement, Element, ElementTree, ParseError, parse + +-from common import utils, logger +-from common.exceptions import ApplicationException, InvalidModelException ++from ..common import utils, logger ++from ..common.exceptions import ApplicationException, InvalidModelException + + from CTDopts.CTDopts import _InFile, _OutFile, ParameterGroup, _Choices, _NumericRange, _FileFormat, ModelError, _Null + +--- /dev/null ++++ ctdconverter/__main__.py +@@ -0,0 +1,6 @@ ++from __future__ import absolute_import ++import sys ++ ++from . import convert ++ ++sys.exit(convert.main()) --- /dev/null +++ ctdconverter/setup.py -@@ -0,0 +1,170 @@ +@@ -0,0 +1,167 @@ +"""A setuptools based setup module. + +See: @@ -78,7 +163,8 @@ + # This is a one-line description or tagline of what your project does. This + # corresponds to the "Summary" metadata field: + # https://packaging.python.org/specifications/core-metadata/#summary -+ description='Convert CTD files into Galaxy tool and CWL CommandLineTool files', # Required ++ description='Convert CTD files into Galaxy tool and CWL CommandLineTool ' ++ 'files', # Required + + # This is an optional longer description of your project that represents + # the body of text which users will see when they visit PyPI. @@ -88,17 +174,17 @@ + # + # This field corresponds to the "Description" metadata field: + # https://packaging.python.org/specifications/core-metadata/#description-optional -+ long_description=long_description, # Optional ++ long_description=long_description, + + # This should be a valid link to your project's main homepage. + # + # This field corresponds to the "Home-Page" metadata field: + # https://packaging.python.org/specifications/core-metadata/#home-page-optional -+ url='https://github.com/WorkflowConversion/CTDConverter', # Optional ++ url='https://github.com/WorkflowConversion/CTDConverter', + + # This should be your name or the name of the organization which owns the + # project. -+ author='The WorkflowConversion team', # Optional ++ author='The WorkflowConversion team', + + # This should be a valid email address corresponding to the author listed + # above. @@ -108,7 +194,7 @@ + # + # For a list of valid classifiers, see + # https://pypi.python.org/pypi?%3Aaction=list_classifiers -+ classifiers=[ # Optional ++ classifiers=[ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta @@ -138,16 +224,12 @@ + # Note that this is a string of words separated by whitespace, not a list. + keywords='CTD CWL CommonWL Galaxy Workflows WorkflowConversion', # Optional + -+ # You can just specify package directories manually here if your project is -+ # simple. Or you can use find_packages(). -+ # -+ # Alternatively, if you just want to distribute a single Python file, use -+ # the `py_modules` argument instead as follows, which will expect a file -+ # called `my_module.py` to exist: -+ # -+ py_modules=["convert"], -+ # -+ packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required ++ packages=['ctdconverter', 'ctdconverter.common', 'ctdconverter.galaxy', ++ 'ctdconverter.cwl'], # Required ++ package_dir={ 'ctdconverter': '.', ++ 'ctdconverter.common': 'common', ++ 'ctdconverter.galaxy': 'galaxy', ++ 'ctdconverter.cwl': 'cwl'}, + + # This field lists other packages that your project depends on to run. + # Any package you put here will be installed by pip when your project is @@ -175,7 +257,7 @@ + # + # If using Python 2.6 or earlier, then these have to be included in + # MANIFEST.in as well. -+ package_data={ # Optional ++ package_data={ + 'ctdconverter': ['galaxy/macros.xml'], + }, + @@ -188,7 +270,7 @@ + # executes the function `main` from this package when invoked: + entry_points={ # Optional + 'console_scripts': [ -+ 'CTDConverter=convert:main', ++ 'CTDConverter=ctdconverter', + ], + }, +) diff --git a/debian/patches/upgrade_deprecated_strip b/debian/patches/upgrade_deprecated_strip index d39b370..4caf8dd 100644 --- a/debian/patches/upgrade_deprecated_strip +++ b/debian/patches/upgrade_deprecated_strip @@ -2,16 +2,14 @@ Subject: Upgrade deprecated using of string.strip() --- ctdconverter.orig/common/utils.py +++ ctdconverter/common/utils.py -@@ -4,8 +4,7 @@ +@@ -4,7 +4,6 @@ import os from lxml import etree -from string import strip --from logger import info, error, warning -+from logger import info, error, warning + from logger import info, error, warning - from common.exceptions import ApplicationException - from CTDopts.CTDopts import CTDModel, ParameterGroup + from .exceptions import ApplicationException @@ -73,9 +72,9 @@ if member_value is not None: if isinstance(member_value, list): @@ -24,4 +22,3 @@ for path_to_check in paths_to_check: validate_path_exists(path_to_check) - diff --git a/debian/rules b/debian/rules index 1d00b1a..993d904 100755 --- a/debian/rules +++ b/debian/rules @@ -3,6 +3,7 @@ # DH_VERBOSE := 1 export LC_ALL=C.UTF-8 export PYBUILD_NAME = ctdconverter +export PYBUILD_SYSTEM = distutils include /usr/share/dpkg/default.mk # this provides: @@ -30,3 +31,9 @@ override_dh_installman: debian/CTDConverter.1 dh_installman + +override_dh_auto_test: + dh_auto_install + PYBUILD_SYSTEM=custom PYBUILD_TEST_ARGS="export \ + PYTHONPATH={build_dir} && {interpreter} -m \ + ctdconverter.convert --help" dh_auto_test