From 4c847893b85f0b3ce9b3e44b1048cc17f34e57cf Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 10 Aug 2023 17:57:30 -0500 Subject: [PATCH] feat: Installable using pipx --- .gitignore | 1 + pyproject.toml | 18 ++++++++++++++++ requirements.txt | 4 ---- .../ReVancedBuilder/APKPure_dl.py | 4 +++- Cleanup.py => src/ReVancedBuilder/Cleanup.py | 5 +++-- .../ReVancedBuilder/JAVABuilder.py | 3 ++- .../ReVancedBuilder/Notifications.py | 0 .../ReVancedBuilder/ReVancedBuilder.py | 21 ++++++++++--------- 8 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt rename APKPure_dl.py => src/ReVancedBuilder/APKPure_dl.py (98%) rename Cleanup.py => src/ReVancedBuilder/Cleanup.py (96%) rename JAVABuilder.py => src/ReVancedBuilder/JAVABuilder.py (98%) rename Notifications.py => src/ReVancedBuilder/Notifications.py (100%) rename ReVancedBuilder.py => src/ReVancedBuilder/ReVancedBuilder.py (94%) diff --git a/.gitignore b/.gitignore index 2228d0b..244f09d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ patches.txt .directory .venv/ __pycache__/ +ReVancedBuilder.egg-info/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..439366b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "ReVancedBuilder" +authors = [{ name = "Sayantan Santra", email = "sayantan.santra689@gmail.com" }] +description = "A tool to automatically build latest releases of ReVanced apps" +readme = "README.md" +requires-python = ">=3.10" +keywords = ["revanced", "patch"] +license = { file = "LICENSE" } +classifiers = ["Programming Language :: Python :: 3"] +dependencies = ["requests", "packaging", "bs4"] +version = "1.0" + +[project.scripts] +ReVancedBuilder = "ReVancedBuilder:ReVancedBuilder" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d8c6174..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -requests -semver -packaging -bs4 \ No newline at end of file diff --git a/APKPure_dl.py b/src/ReVancedBuilder/APKPure_dl.py similarity index 98% rename from APKPure_dl.py rename to src/ReVancedBuilder/APKPure_dl.py index e4480c6..598ed45 100644 --- a/APKPure_dl.py +++ b/src/ReVancedBuilder/APKPure_dl.py @@ -6,10 +6,12 @@ import os import sys import json + from packaging.version import Version import requests as req from bs4 import BeautifulSoup as bs -from Cleanup import clean_exit + +from ReVancedBuilder.Cleanup import clean_exit # Determine the best version available to download def apkpure_best_match(version, soup): diff --git a/Cleanup.py b/src/ReVancedBuilder/Cleanup.py similarity index 96% rename from Cleanup.py rename to src/ReVancedBuilder/Cleanup.py index 2be3d2b..3adfb38 100644 --- a/Cleanup.py +++ b/src/ReVancedBuilder/Cleanup.py @@ -5,9 +5,10 @@ import os import sys -from Notifications import send_notif import time +from ReVancedBuilder.Notifications import send_notif + # Move apps to proper location def move_apps(appstate): build_config = appstate['build_config'] @@ -63,4 +64,4 @@ def clean_exit(msg, appstate, code=1): # Delete the lockfile os.remove('lockfile') - exit(code) \ No newline at end of file + sys.exit(code) \ No newline at end of file diff --git a/JAVABuilder.py b/src/ReVancedBuilder/JAVABuilder.py similarity index 98% rename from JAVABuilder.py rename to src/ReVancedBuilder/JAVABuilder.py index e7c91eb..a6021ad 100644 --- a/JAVABuilder.py +++ b/src/ReVancedBuilder/JAVABuilder.py @@ -7,9 +7,10 @@ import os import sys import configparser as cp import json -from Cleanup import clean_exit import subprocess +from ReVancedBuilder.Cleanup import clean_exit + # Build the revanced apps def build_apps(appstate): build_config = appstate['build_config'] diff --git a/Notifications.py b/src/ReVancedBuilder/Notifications.py similarity index 100% rename from Notifications.py rename to src/ReVancedBuilder/Notifications.py diff --git a/ReVancedBuilder.py b/src/ReVancedBuilder/ReVancedBuilder.py similarity index 94% rename from ReVancedBuilder.py rename to src/ReVancedBuilder/ReVancedBuilder.py index b3c4b5e..80b5f16 100755 --- a/ReVancedBuilder.py +++ b/src/ReVancedBuilder/ReVancedBuilder.py @@ -6,20 +6,21 @@ import sys import os import configparser as cp -import requests as req import json -from packaging.version import Version -from APKPure_dl import * -from JAVABuilder import * -from datetime import datetime -from Notifications import send_notif -from Cleanup import * import logging import subprocess +import requests as req +from packaging.version import Version +from datetime import datetime + +from ReVancedBuilder.APKPure_dl import apkpure_best_match, apkpure_dl, get_apks +from ReVancedBuilder.JAVABuilder import build_apps +from ReVancedBuilder.Notifications import send_notif +from ReVancedBuilder.Cleanup import move_apps, clean_exit + # TODO: README # TODO: PATCHES_GUIDE.md (maybe delete it?) -# TODO: Install using pip # Update the ReVanced tools, if needed def update_tools(appstate): @@ -92,9 +93,9 @@ appstate['timestamp'] = time.strftime('%Y%m%d%H%M%S') try: os.chdir(sys.argv[1]) except IndexError: - clean_exit('Please provide a working directory as argument!', appstate) + sys.exit('Please provide a working directory as argument!') except FileNotFoundError: - clean_exit('Invalid working directory provided!', appstate) + sys.exit('Invalid working directory provided!') # Try to make sure only one instance is running in a given working directory try: