From 5778eeab366bf22ac930de3dc848d60daf32a14d Mon Sep 17 00:00:00 2001 From: Daniel Connelly Date: Sun, 21 Jan 2024 23:57:09 +0800 Subject: [PATCH] Changes needed for PyPi update. (#3) * Changes needed for PyPi update. 1.0.1 as I messed up on the 1.0 push. * Accounting for how github actions + other users might run our script (directly rather than as package) --- CITATION.cff | 2 +- python-port/sendpy/__main__.py | 18 +++++++++++++----- python-port/setup.py | 11 ++++++++--- sendmsg.sh | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 7b4f486..d103815 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -14,4 +14,4 @@ abstract: >- attachments, from the command line. Optionally use your own e-mail address and an external SMTP server. license: GPL-3.0 -version: '1.0' +version: '1.0.1' diff --git a/python-port/sendpy/__main__.py b/python-port/sendpy/__main__.py index bc8265c..dbec69c 100644 --- a/python-port/sendpy/__main__.py +++ b/python-port/sendpy/__main__.py @@ -15,9 +15,17 @@ from email.utils import parseaddr from shutil import which -import configuration -import usage -from send import sendEmail +if __name__ == "__main__": + # The script is being run directly, use absolute imports + import configuration + import usage + from send import sendEmail +else: + # The script is being run as part of a package, use relative imports + from . import configuration + from . import usage + from .send import sendEmail + """Copyright © Daniel Connelly and Teal Dulcet @@ -35,7 +43,7 @@ parser = argparse.ArgumentParser( description="One or more To, CC or BCC e-mail addresses are required. Send text messages by using the mobile providers e-mail to SMS or MMS gateway (see the --gateways option). See examples with the --examples option.") parser.add_argument("-v", "--version", action="version", - version="%(prog)s 1.0") + version="%(prog)s 1.0.1") parser.add_argument("-s", "--subject", dest="subject", help="Subject. Escape sequences are expanded. Supports Unicode characters.") parser.add_argument("-m", "--message", dest="message", default="", @@ -446,4 +454,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/python-port/setup.py b/python-port/setup.py index 03123e7..84f50d2 100644 --- a/python-port/setup.py +++ b/python-port/setup.py @@ -1,12 +1,12 @@ import setuptools - +from setuptools import setup, find_packages def readme(): with open("README.rst") as fh: return fh.read() setuptools.setup(name="sendpy", - version="1.0", + version="1.0.1", description="Email and text notification program", long_description=readme(), long_description_content_type="text/markdown", @@ -14,7 +14,12 @@ def readme(): author="Daniel Connelly and Teal Dulcet", author_email="connellyd2050@gmail.com", license="GPL", - packages=["sendpy"], + entry_points={ + 'console_scripts': [ + 'sendpy=sendpy.__main__:main' + ] + }, + packages=find_packages(), scripts=["bin/sendpy"], classifiers=[ "Programming Language :: Python :: 3.6", diff --git a/sendmsg.sh b/sendmsg.sh index f116240..e2c628b 100644 --- a/sendmsg.sh +++ b/sendmsg.sh @@ -242,7 +242,7 @@ while getopts "a:b:c:df:hk:lm:p:rs:t:u:vz:C:P:S:T:UV" c; do USERNAME=$OPTARG ;; v ) - echo -e "Send Msg CLI 1.0\n" + echo -e "Send Msg CLI 1.0.1\n" exit 0 ;; z )