From d1bd33b80a429184758fdfa7f492979f7d972926 Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Wed, 11 Dec 2019 00:33:48 -0500 Subject: [PATCH] Restructured for PyPi --- README.md | 23 ++++++++--- RetroUFO.py => RetroUFO/RetroUFO.py | 42 ++++++++++----------- RetroUFO_GUI.py => RetroUFO/RetroUFO_GUI.py | 6 ++- RetroUFO/__init__.py | 0 setup.py | 9 +++++ 5 files changed, 52 insertions(+), 28 deletions(-) rename RetroUFO.py => RetroUFO/RetroUFO.py (90%) rename RetroUFO_GUI.py => RetroUFO/RetroUFO_GUI.py (99%) create mode 100644 RetroUFO/__init__.py diff --git a/README.md b/README.md index 01dbe36..bcea1ce 100644 --- a/README.md +++ b/README.md @@ -5,31 +5,43 @@ A ~~messy~~ Python script that grabs the latest version of every libretro core from the [build bot](https://buildbot.libretro.com/). *** + +### Installation + +The package can be installed via pip: + +```bash +pip install --user RetroUFO +``` + + ### Usage-CLI Just run the script with _Python 3_: ```bash -python3 ./RetroUFO.py +RetroUFO ``` It will then download and extract all the latest versions of each core to their default location based on `retroarch.default.cfg` for each platform -_(Which is only Linux & Windows for right now)_ +_(Which is only Linux, macOS, & Windows for right now)_ If you are more of a advance user, and want to do things a bit more manually, you can view all the scripts arguments by: ```bash -python3 ./RetroUFO.py --help +RetroUFO --help ``` ### Usage-GUI -The GUI script uses [Qt for Python](https://wiki.qt.io/Qt_for_Python) ([PySide2](https://pypi.org/project/PySide2/)). So you can make sure you have that package installed by running: +The GUI script uses [Qt for Python](https://wiki.qt.io/Qt_for_Python) ([PySide2](https://pypi.org/project/PySide2/)). So you can make sure you have that package installed by running if you plan to run the script manually: ```bash pip3 install --user PySide2 ``` + + After that you can just run the script like so: ```bash -python3 ./RetroUFO_GUI.py +RetroUFO_GUI ``` You can then just click the `Grab Cores` button at the bottom and then you should be all set. @@ -57,3 +69,4 @@ If you have your core directory set somewhere special you can override where the - ~~Make GUI~~ - Real error handling - Support for ARM detection +- ~~Make a PyPi package~~ diff --git a/RetroUFO.py b/RetroUFO/RetroUFO.py similarity index 90% rename from RetroUFO.py rename to RetroUFO/RetroUFO.py index 9b0d083..5f71d25 100755 --- a/RetroUFO.py +++ b/RetroUFO/RetroUFO.py @@ -25,13 +25,29 @@ CORE_LOCATION = { } -def main(_args): +def main(): """ Where the magic happens """ + parser = argparse.ArgumentParser() + + parser.add_argument('-p', '--platform', metavar='STRING', required=False, + help='Platform you desire to download for') + + parser.add_argument('-a', '--architecture', metavar='STRING', required=False, + help='Architecture for the platform you desire to download for') + + parser.add_argument('-l', '--location', metavar='STRING', required=False, + help='Location you wish the cores to extract to') + + parser.add_argument('-k', '--keep', action='store_true', + help='Keeps downloaded core archives') + + args = parser.parse_args() + # If a platform and/or architecture is not supplied it is grabbed automatically - target_platform = _args.platform if _args.platform else get_platform() - architecture = _args.architecture if _args.architecture else get_architecture() - location = _args.location if _args.location else CORE_LOCATION[target_platform] + target_platform = args.platform if args.platform else get_platform() + architecture = args.architecture if args.architecture else get_architecture() + location = args.location if args.location else CORE_LOCATION[target_platform] download_cores(target_platform, architecture) extract_cores(location) @@ -117,20 +133,4 @@ def clean_up(): if __name__ == "__main__": - """ This is executed when run from the command line """ - parser = argparse.ArgumentParser() - - parser.add_argument('-p', '--platform', metavar='STRING', required=False, - help='Platform you desire to download for') - - parser.add_argument('-a', '--architecture', metavar='STRING', required=False, - help='Architecture for tha platform you desire to download for') - - parser.add_argument('-l', '--location', metavar='STRING', required=False, - help='Location you wish the cores to extract to') - - parser.add_argument('-k', '--keep', action='store_true', - help='Keeps downloaded core archives') - - args = parser.parse_args() - main(args) + main() diff --git a/RetroUFO_GUI.py b/RetroUFO/RetroUFO_GUI.py similarity index 99% rename from RetroUFO_GUI.py rename to RetroUFO/RetroUFO_GUI.py index be3ee44..f9977c6 100755 --- a/RetroUFO_GUI.py +++ b/RetroUFO/RetroUFO_GUI.py @@ -260,8 +260,7 @@ class Form(QDialog): if os.path.isdir('cores'): rmtree('cores/') - -if __name__ == '__main__': +def main(): # Create the Qt Application app = QApplication(sys.argv) # Create and show the form @@ -271,3 +270,6 @@ if __name__ == '__main__': form.show() # Run the main Qt loop sys.exit(app.exec_()) + +if __name__ == '__main__': + main() diff --git a/RetroUFO/__init__.py b/RetroUFO/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index e2f063f..da5bab1 100644 --- a/setup.py +++ b/setup.py @@ -15,10 +15,19 @@ setuptools.setup( keywords=["libretro", "retroarch", "core"], url="https://github.com/pypa/sampleproject", packages=["RetroUFO"], + install_requires=[ + 'PySide2', + ], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], python_requires='>=3.6', + entry_points={ + 'console_scripts': [ + "RetroUFO=RetroUFO.RetroUFO:main", + "RetroUFO-GUI=RetroUFO.RetroUFO_GUI:main" + ] + }, ) \ No newline at end of file