From 87a8074cacde6f58f3aaabd02564cf5f4a734188 Mon Sep 17 00:00:00 2001 From: Phillip Stromberg Date: Fri, 22 Mar 2024 14:45:07 -0500 Subject: [PATCH] Add setup.py to allow pip install After install, "gyb" can be used on the command line anywhere. --- gyb.py | 15 +++++++++++++- setup.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 setup.py diff --git a/gyb.py b/gyb.py index e321361..4209743 100755 --- a/gyb.py +++ b/gyb.py @@ -2804,7 +2804,7 @@ def main(argv): for label in labels: createLabel(label) -if __name__ == '__main__': +def command_line(): if sys.version_info[0] < 3 or sys.version_info[1] < 7: print('ERROR: GYB requires Python 3.7 or greater.') sys.exit(3) @@ -2834,3 +2834,16 @@ def main(argv): except NameError: pass sys.exit(4) + +def _installed_main(): + """ + If gyb was installed with pip or setup.py, set the default --config-folder + paramter to be the directory this script was called from instead of where + the script actually is. + """ + if "--config-folder" not in sys.argv: + sys.argv.extend(["--config-folder", "."]) + command_line() + +if __name__ == '__main__': + command_line() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..86d3930 --- /dev/null +++ b/setup.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +from setuptools import setup + +# from gyb import __author__, __email__, __program_name__, __version__ + +__author__ = "Jay Lee" +__email__ = 'jay0lee@gmail.com' +__program_name__ = 'Got Your Back: Gmail Backup' +__version__ = '1.80' + + +with open("README.md", "r") as _: + readme = _.read() + +setup( + name="gyb", + version=__version__, + packages=["."], + zip_safe=True, + url="https://github.com/GAM-team/got-your-back", + license="Apache 2.0", + author=__author__, + author_email=__email__, + description=__program_name__, + long_description=readme, + long_description_content_type="text/markdown", + python_requires=">=3.7", + install_requires=[ + "httplib2>=0.17.0", + "google-api-python-client>=2.0", + "google-auth>=1.11.2", + "google-auth-httplib2", + "google-auth-oauthlib>=0.4.1", + ], + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Communications :: Email", + "Topic :: Utilities", + ], + entry_points={ + "console_scripts": [ + "gyb=gyb:_installed_main" + ], + } +)