From c7fcd22b9ff5e9689c34abc7aed46d526717e0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Thu, 22 Oct 2020 19:20:42 +0100 Subject: [PATCH] Move script to package. --- ognibuild.py => ognibuild/__init__.py | 23 --------------- ognibuild/__main__.py | 41 +++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 42 insertions(+), 24 deletions(-) rename ognibuild.py => ognibuild/__init__.py (93%) create mode 100644 ognibuild/__main__.py diff --git a/ognibuild.py b/ognibuild/__init__.py similarity index 93% rename from ognibuild.py rename to ognibuild/__init__.py index c5f05f1..f37d875 100644 --- a/ognibuild.py +++ b/ognibuild/__init__.py @@ -239,26 +239,3 @@ class PlainSession(object): def Popen(self, args, stdout=None, stderr=None, user=None, cwd=None): return subprocess.Popen( args, stdout=stdout, stderr=stderr, cwd=cwd) - - -def main(argv): - import argparse - parser = argparse.ArgumentParser() - parser.add_argument('subcommand', type=str, choices=['dist']) - parser.add_argument( - '--directory', '-d', type=str, help='Directory for project.', - default='.') - args = parser.parse_args() - session = PlainSession() - os.chdir(args.directory) - try: - if args.subcommand == 'dist': - run_dist(session) - except NoBuildToolsFound: - note('No build tools found.') - return 1 - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/ognibuild/__main__.py b/ognibuild/__main__.py new file mode 100644 index 0000000..2367354 --- /dev/null +++ b/ognibuild/__main__.py @@ -0,0 +1,41 @@ +# Copyright (C) 2019-2020 Jelmer Vernooij +# encoding: utf-8 +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import os +import sys +from . import PlainSession, run_dist, NoBuildToolsFound, note + + +def main(): + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('subcommand', type=str, choices=['dist']) + parser.add_argument( + '--directory', '-d', type=str, help='Directory for project.', + default='.') + args = parser.parse_args() + session = PlainSession() + os.chdir(args.directory) + try: + if args.subcommand == 'dist': + run_dist(session) + except NoBuildToolsFound: + note('No build tools found.') + return 1 + return 0 + +sys.exit(main()) diff --git a/setup.py b/setup.py index 86ef505..9cb11ae 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup(name="ognibuild", maintainer_email="jelmer@jelmer.uk", license="GNU GPLv2 or later", url="https://jelmer.uk/code/ognibuild", - scripts=['ognibuild.py'], + packages=['ognibuild'], classifiers=[ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: '