diff --git a/ci-scripts/incrementVersion b/ci-scripts/incrementVersion index ec16ad1..55a842c 100755 --- a/ci-scripts/incrementVersion +++ b/ci-scripts/incrementVersion @@ -28,9 +28,12 @@ if __name__ == '__main__': try: opts, args = getopt.getopt(sys.argv[1:], '', ['major', 'minor', 'patch']) for o, a in opts: - if o == '--major': major = True - if o == '--minor': minor = True - if o == '--patch': patch = True + if o == '--major': + major = True + if o == '--minor': + minor = True + if o == '--patch': + patch = True except getopt.GetoptError as err: print(err, file=sys.stderr) @@ -38,13 +41,12 @@ if __name__ == '__main__': versioner = Versioner() old_version = versioner.get_version_str() - updated_file_list = [] if major: - updated_file_list = versioner.increment_major() + versioner.increment_major() elif minor: - updated_file_list = versioner.increment_minor() + versioner.increment_minor() elif patch: - updated_file_list = versioner.increment_patch() + versioner.increment_patch() else: print('Specify either --major, --minor or --patch', file=sys.stderr) exit(os.EX_USAGE) @@ -52,6 +54,4 @@ if __name__ == '__main__': new_version = versioner.get_version_str() print(f'::set-output name=oldVersion::{old_version}') print(f'::set-output name=newVersion::{new_version}') - - updated_file_list = ' '.join(updated_file_list) - print(f'::set-output name=files::{updated_file_list}') + print(f'::set-output name=files::{versioner.version_file}') diff --git a/ci-scripts/version.py b/ci-scripts/version.py index 0bc8610..dfaa659 100755 --- a/ci-scripts/version.py +++ b/ci-scripts/version.py @@ -15,45 +15,26 @@ # along with this program. If not, see . import os.path +import pathlib class Versioner: def __init__(self): - abs_dir_name = os.path.abspath(os.path.dirname(__file__)) - self.__version_files = [os.path.abspath(os.path.join(abs_dir_name, f)) for f in ('../pyproject.toml', '../src/adbPullAs/__init__.py')] - self.__version_str = self.__get_version() - if not self.__version_str: - raise RuntimeError("Unable to find version string.") + here = pathlib.Path(__file__).parent.resolve() + self.version_file = os.path.abspath(here.parent / 'src' / 'adbPullAs' / 'VERSION') + with open(self.version_file, 'r') as f: + self.__version_str = f.read().strip() self.__version = list(map(int, self.__version_str.split('.'))) - def __get_version(self): - for f in self.__version_files: - with open(f, 'r') as fp: - for line in fp: - if line.startswith('version = '): - delimiter = '"' if '"' in line else "'" - return line.split(delimiter)[1] - return False + def get_version(self): + return self.__version def get_version_str(self): return self.__version_str - def __save_version_file(self, file): - with open(file, 'r+') as fh: - position = 0 - for line in fh: - if line.startswith('version = '): - fh.seek(position) - fh.write(f"version = '{self.__version_str}' #") - return True - position += len(line) - def __save_version(self): - updated_list = [] - for file in self.__version_files: - if self.__save_version_file(file): - updated_list.append(file) - return updated_list + with open(self.version_file, 'w') as f: + f.write(self.__version_str) def increment_major(self): self.__version[0] += 1 diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 0411281..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,18 +0,0 @@ -[project] -name = 'adbPullAs' -version = '1.0.1' ####################### buffer for in-place file modification, in case version STRING needs to grow -description = 'adb pull wrapper to pull package private files from Android device' -authors = [{name="Vilius Sutkus '89", email="ViliusSutkus89@gmail.com"}] -readme = 'README.md' -license = { file="LICENSE" } - -[project.urls] -"Homepage" = "https://github.com/ViliusSutkus89/adbPullAs/" -"Bug Tracker" = "https://github.com/ViliusSutkus89/adbPullAs/issues" - -[build-system] -requires = ['setuptools'] -build-backend = 'setuptools.build_meta' - -[projects.scripts] -adbPullAs = 'adbPullAs:main' diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ebcb3ba --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +from setuptools import setup, find_packages +import pathlib + + +here = pathlib.Path(__file__).parent.resolve() +version = (here / 'src' / 'adbPullAs' / 'VERSION').read_text(encoding='utf-8') +long_description = (here / 'README.md').read_text(encoding='utf-8') + +setup( + name='adbPullAs', + version=version, + description='adb pull wrapper to pull package private files from Android device', + long_description=long_description, + long_description_content_type='text/markdown', + url='https://github.com/ViliusSutkus89/adbPullAs/', + author="Vilius Sutkus '89", + author_email='ViliusSutkus89@gmail.com', + license='GPLv3', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + 'Natural Language :: English', + 'Operating System :: Android', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.9', + 'Topic :: Utilities' + ], + keywords='adb pull run-as', + project_urls={ + 'Tracker': 'https://github.com/ViliusSutkus89/adbPullAs/issues' + }, + package_dir={'': 'src'}, + packages=find_packages(where='src'), + python_requires='>=3.9', + package_data={'adbPullAs': ['VERSION']}, + entry_points={'console_scripts': ['adbPullAs=adbPullAs:main']} +) diff --git a/src/adbPullAs/VERSION b/src/adbPullAs/VERSION new file mode 100644 index 0000000..7f20734 --- /dev/null +++ b/src/adbPullAs/VERSION @@ -0,0 +1 @@ +1.0.1 \ No newline at end of file diff --git a/src/adbPullAs/__init__.py b/src/adbPullAs/__init__.py index d00b565..93d783e 100755 --- a/src/adbPullAs/__init__.py +++ b/src/adbPullAs/__init__.py @@ -19,12 +19,11 @@ import getopt import os +import pathlib import subprocess import sys from pathlib import PurePosixPath, PurePath -version = '1.0.1' ####################### buffer for in-place file modification, in case version STRING needs to grow - class FsTest: def __init__(self, package_name): @@ -168,8 +167,11 @@ def print_usage(output_to=sys.stdout): def print_version(): + here = pathlib.Path(__file__).parent.resolve() + version = (here / 'VERSION').read_text(encoding='utf-8') + print(os.path.basename(sys.argv[0]), '-', 'adb pull wrapper to pull package private files from Android device') - print('version: ', version) + print('version:', version) print() print('THIS WORKS ONLY ON DEBUG APPLICATIONS') print()