From 8c24cd2be58f3e780271f5f8e24d27a3f67c3e51 Mon Sep 17 00:00:00 2001 From: Aaron Mussig Date: Mon, 16 Mar 2020 10:20:06 +1000 Subject: [PATCH] packaging for conda --- .gitignore | 3 +++ README.md | 2 ++ bin/gtdb_migration_tk | 22 ++++++---------------- gtdb_migration_tk/__init__.py | 22 ++++++++++++++++++++++ setup.py | 28 ++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index b6e4761..27346cc 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dmypy.json # Pyre type checker .pyre/ + +# IntelliJ +.idea diff --git a/README.md b/README.md index 9ab5531..fdca406 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # gtdb-migration-tk +[![ace-internal](https://img.shields.io/conda/vn/ace-internal/gtdb_migration_tk.svg?color=green)](https://anaconda.org/ace-internal/gtdb_migration_tk) + Toolkit for updating the GTDB to the next release and test data diff --git a/bin/gtdb_migration_tk b/bin/gtdb_migration_tk index e5e67a2..40e20b6 100755 --- a/bin/gtdb_migration_tk +++ b/bin/gtdb_migration_tk @@ -24,27 +24,17 @@ __maintainer__ = "Pierre Chaumeil" __email__ = "uqpchaum@uq.edu.au" __status__ = "Development" +import argparse import os import sys -import ntpath -import logging -import argparse sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) - from gtdb_migration_tk.main import OptionsParser from biolib.logger import logger_setup from biolib.misc.custom_help_formatter import CustomHelpFormatter -from biolib.common import make_sure_path_exists - - -def version(): - """Read program version from file.""" - import gtdb_migration_tk - version_file = open(os.path.join(gtdb_migration_tk.__path__[0], 'VERSION')) - return version_file.readline().strip() +from gtdb_migration_tk import __version__ def print_help(): @@ -52,7 +42,7 @@ def print_help(): print('') print(' ...::: GTDB Migration Toolkit v' + - version() + ' :::...''') + __version__ + ' :::...''') print('''\ NCBI folder to GTDB folder: @@ -274,7 +264,7 @@ if __name__ == '__main__': # get and check options args = None - if(len(sys.argv) == 1 or sys.argv[1] == '-h' or sys.argv == '--help'): + if len(sys.argv) == 1 or sys.argv[1] in {'-h', '--help'}: print_help() sys.exit(0) else: @@ -284,13 +274,13 @@ if __name__ == '__main__': logger_setup(args.output_dir, 'gtdb_migration_tk.log', 'GTDB Migration Tk', - version(), + __version__, args.silent) except: logger_setup(None, 'gtdb_migration_tk.log', 'GTDB Migration Tk', - version(), + __version__, args.silent) # do what we came here to do diff --git a/gtdb_migration_tk/__init__.py b/gtdb_migration_tk/__init__.py index e69de29..fd1d6ce 100644 --- a/gtdb_migration_tk/__init__.py +++ b/gtdb_migration_tk/__init__.py @@ -0,0 +1,22 @@ +############################################################################### +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +import os + +# Set the module version. +with open(os.path.join(__path__[0], 'VERSION'), 'r') as f: + __version__ = f.readline().strip() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..260b2c5 --- /dev/null +++ b/setup.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import os + +from setuptools import setup + + +def version(): + setup_dir = os.path.dirname(os.path.realpath(__file__)) + with open(os.path.join(setup_dir, 'gtdb_migration_tk', 'VERSION'), 'r') as f: + return f.readline().strip() + + +setup( + name='gtdb_migration_tk', + python_requires='>=3.6', + version=version(), + author='Pierre-Alain Chaumeil', + author_email='p.chaumeil@uq.edu.au', + maintainer='Pierre-Alain Chaumeil, Aaron Mussig, and Donovan Parks', + maintainer_email='p.chaumeil@uq.edu.au', + packages=['gtdb_migration_tk'], + scripts=['bin/gtdb_migration_tk'], + package_data={'gtdb_migration_tk': ['VERSION']}, + url='https://github.com/Ecogenomics/gtdb-migration-tk', + description='Toolkit for updating the GTDB to the next release and test data.', + install_requires=['requests', 'unidecode', 'biolib>=0.1.0', 'pandas', 'numpy'], +)