From b7df86a54f03b99f3fa88444f3ab105d78dee90b Mon Sep 17 00:00:00 2001 From: DingGGu Date: Mon, 18 Sep 2023 14:38:07 +0900 Subject: [PATCH] Release --- .github/workflows/release.yml | 27 ++++++ Makefile | 24 ++--- Pipfile | 3 +- Pipfile.lock | 60 ++++++++++++- aurora_echo.py | 14 +++ aurora_echo.spec | 44 ++++++++++ aurora_echo/__init__.py | 39 --------- aurora_echo/boto_monkey.py | 160 ---------------------------------- eggsecute.py | 98 --------------------- setup.cfg | 6 -- setup.py | 20 ----- 11 files changed, 151 insertions(+), 344 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 aurora_echo.py create mode 100644 aurora_echo.spec delete mode 100644 aurora_echo/boto_monkey.py delete mode 100644 eggsecute.py delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..501ea6a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Package Aurora Echo + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Packaging + run: | + pip install pipenv + make release + + - uses: actions/upload-artifact@v2 + with: + name: aurora-echo + path: dist/* \ No newline at end of file diff --git a/Makefile b/Makefile index 1ceda6a..728053c 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,14 @@ -PYTHON_MAIN=aurora_echo/__init__.py -FINAL_EXECUTABLE=aurora-echo -BUILD_DIR=build -PYTHON_INTERPRETER=python3 +.PHONY: build -.PHONY: all clean build lint - -all: clean build +all: build clean: - @rm -rf *.pyc - @echo "Project .pyc's removed." - @rm -rf $(BUILD_DIR) - @echo "Build directory removed." build: - #rm -f $(BUILD_DIR)/$(FINAL_EXECUTABLE) pipenv install --deploy - python eggsecute.py $(PYTHON_MAIN) $(BUILD_DIR)/$(FINAL_EXECUTABLE) - chmod a+x $(BUILD_DIR)/$(FINAL_EXECUTABLE) - echo "Package created." + pipenv run pyinstaller --onefile aurora_echo.py -lint: - python setup.py flake8 +release: + pipenv install --deploy + pipenv run pyinstaller aurora_echo.spec + shasum -a 256 dist/aurora_echo | cut -d ' ' -f 1 > dist/aurora_echo-shasum-256.txt \ No newline at end of file diff --git a/Pipfile b/Pipfile index 2626306..75d2393 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ certifi = "*" click = "==6.6" [dev-packages] +pyinstaller = "*" [requires] -python_version = "3.9" +python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock index db238f5..27e1663 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "7c7f8e8d774851f404c6400a92d22ba042fde478894672f59ce514bb34e1ef06" + "sha256": "bbde20a5373e48aae33cc966cfcf1c8002832f56c2519b9be9d687733736fe87" }, "pipfile-spec": 6, "requires": { - "python_version": "3.9" + "python_version": "3.10" }, "sources": [ { @@ -22,6 +22,7 @@ "sha256:c9fad1b01a1d7e7bd51150b3175b4c32b79d699ce94708082611f59fde2e097a" ], "index": "pypi", + "markers": "python_version >= '3.7'", "version": "==1.28.49" }, "botocore": { @@ -30,6 +31,7 @@ "sha256:95e9716f27f67d4207f260ab0ea157603ca544d3b82c5f21728b1c732bec1817" ], "index": "pypi", + "markers": "python_version >= '3.7'", "version": "==1.31.49" }, "certifi": { @@ -38,6 +40,7 @@ "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9" ], "index": "pypi", + "markers": "python_version >= '3.6'", "version": "==2023.7.22" }, "click": { @@ -89,5 +92,56 @@ "version": "==1.26.16" } }, - "develop": {} + "develop": { + "altgraph": { + "hashes": [ + "sha256:ad33358114df7c9416cdb8fa1eaa5852166c505118717021c6a8c7c7abbd03dd", + "sha256:c8ac1ca6772207179ed8003ce7687757c04b0b71536f81e2ac5755c6226458fe" + ], + "version": "==0.17.3" + }, + "macholib": { + "hashes": [ + "sha256:44c40f2cd7d6726af8fa6fe22549178d3a4dfecc35a9cd15ea916d9c83a688e0", + "sha256:557bbfa1bb255c20e9abafe7ed6cd8046b48d9525db2f9b77d3122a63a2a8bf8" + ], + "markers": "sys_platform == 'darwin'", + "version": "==1.16.2" + }, + "pyinstaller": { + "hashes": [ + "sha256:16cbd66b59a37f4ee59373a003608d15df180a0d9eb1a29ff3bfbfae64b23d0f", + "sha256:27cd64e7cc6b74c5b1066cbf47d75f940b71356166031deb9778a2579bb874c6", + "sha256:2c2fe9c52cb4577a3ac39626b84cf16cf30c2792f785502661286184f162ae0d", + "sha256:421cd24f26144f19b66d3868b49ed673176765f92fa9f7914cd2158d25b6d17e", + "sha256:65133ed89467edb2862036b35d7c5ebd381670412e1e4361215e289c786dd4e6", + "sha256:7d51734423685ab2a4324ab2981d9781b203dcae42839161a9ee98bfeaabdade", + "sha256:8f6dd0e797ae7efdd79226f78f35eb6a4981db16c13325e962a83395c0ec7420", + "sha256:aadafb6f213549a5906829bb252e586e2cf72a7fbdb5731810695e6516f0ab30", + "sha256:b2e1c7f5cceb5e9800927ddd51acf9cc78fbaa9e79e822c48b0ee52d9ce3c892", + "sha256:c63ef6133eefe36c4b2f4daf4cfea3d6412ece2ca218f77aaf967e52a95ac9b8", + "sha256:c8e5d3489c3a7cc5f8401c2d1f48a70e588f9967e391c3b06ddac1f685f8d5d2", + "sha256:ddcc2b36052a70052479a9e5da1af067b4496f43686ca3cdda99f8367d0627e4" + ], + "index": "pypi", + "markers": "python_version < '3.13' and python_version >= '3.7'", + "version": "==5.13.2" + }, + "pyinstaller-hooks-contrib": { + "hashes": [ + "sha256:318ccc316fb2b8c0bbdff2456b444bf1ce0e94cb3948a0f4dd48f6fc33d41c01", + "sha256:d091a52fbeed71cde0359aa9ad66288521a8441cfba163d9446606c5136c72a8" + ], + "markers": "python_version >= '3.7'", + "version": "==2023.8" + }, + "setuptools": { + "hashes": [ + "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87", + "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a" + ], + "markers": "python_version >= '3.8'", + "version": "==68.2.2" + } + } } diff --git a/aurora_echo.py b/aurora_echo.py new file mode 100644 index 0000000..5599249 --- /dev/null +++ b/aurora_echo.py @@ -0,0 +1,14 @@ +from aurora_echo import echo_clone, echo_new, echo_modify, echo_promote, echo_retire # noqa: F401 +from aurora_echo.entry import root + + +# Entry for setuptools +def main(): + """ + Bringing you yesterday's database today! + """ + root() + + +if __name__ == '__main__': + main() diff --git a/aurora_echo.spec b/aurora_echo.spec new file mode 100644 index 0000000..37d620d --- /dev/null +++ b/aurora_echo.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['aurora_echo.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='aurora_echo', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/aurora_echo/__init__.py b/aurora_echo/__init__.py index 7c062fe..e69de29 100644 --- a/aurora_echo/__init__.py +++ b/aurora_echo/__init__.py @@ -1,39 +0,0 @@ -## -# The MIT License (MIT) -# -# Copyright (c) 2016 BlackLocus -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -## -import aurora_echo.boto_monkey # noqa: F401 -from aurora_echo import echo_clone, echo_new, echo_modify, echo_promote, echo_retire # noqa: F401 -from aurora_echo.entry import root - - -# Entry for setuptools -def main(): - """ - Bringing you yesterday's database today! - """ - root() - - -# Entry for whatever else (IntelliJ) -if __name__ == '__main__': - main() diff --git a/aurora_echo/boto_monkey.py b/aurora_echo/boto_monkey.py deleted file mode 100644 index afbb15c..0000000 --- a/aurora_echo/boto_monkey.py +++ /dev/null @@ -1,160 +0,0 @@ -## -# Copyright 2016 Ray Holder -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -## - -import atexit -import json -import os -import tempfile -import zipfile - -import botocore.loaders - -from botocore.exceptions import DataNotFoundError -from collections import OrderedDict - -EGG = None -try: - egg_path = os.path.dirname(os.path.dirname(__file__)) - EGG = zipfile.ZipFile(egg_path, 'r') - EGG_DIRS = set([os.path.split(x)[0] for x in EGG.namelist() if '/' in x]) - EGG_API_PATHS = [x for x in EGG_DIRS if 'botocore/data/' in x] - EGG_API_PATHS.extend([x for x in EGG_DIRS if 'boto3/data/' in x]) -except Exception: - pass - - -class JSONFileLoader2(object): - """Loader JSON files. - - This class can load the default format of models, which is a JSON file. - - """ - - def exists(self, file_path: str): - """Checks if the file exists. - - :type file_path: str - :param file_path: The full path to the file to load without - the '.json' extension. - - :return: True if file path exists, False otherwise. - - """ - # TODO fix? seems inconsistent with .format usage pattern. Also cast as str? - return any(x.startswith("%s" % file_path) for x in EGG.namelist()) - - def load_file(self, file_path: str): - """Attempt to load the file path. - - :type file_path: str - :param file_path: The full path to the file to load without - the '.json' extension. - - :return: The loaded data if it exists, otherwise None. - - """ - # everything is inside the egg now, so load from there - full_path = file_path + '.json' - content = EGG.read(full_path).decode('UTF-8') - - return json.loads(content, object_pairs_hook=OrderedDict) - - -@botocore.loaders.instance_cache -def load_data(self, name): - """Load data given a data path. - This is a low level method that will search through the various - search paths until it's able to load a value. This is typically - only needed to load *non* model files (such as _endpoints and - _retry). If you need to load model files, you should prefer - ``load_service_model``. - :type name: str - :param name: The data path, i.e ``ec2/2015-03-01/service-2``. - :return: The loaded data. If no data could be found then - a DataNotFoundError is raised. - """ - # this is the hardcoded location for non-python things inside an egg - locations = ['botocore/data/', 'boto3/data/'] - for possible_path in locations: - file_path = possible_path + name - if self.file_loader.exists(file_path): - return self.file_loader.load_file(file_path) - - # We didn't find anything that matched on any path. - raise DataNotFoundError(data_path=name) - - -@botocore.loaders.instance_cache -def list_available_services(self, type_name: str): - """List all known services. - :type type_name: str - :param type_name: The type of the service (service-2, - paginators-1, waiters-2, etc). This is needed because - the list of available services depends on the service - type. For example, the latest API version available for - a resource-1.json file may not be the latest API version - available for a services-2.json file. - :return: A list of all services. The list of services will - be sorted. - """ - - # search for available services, pulled from the egg - services = set() - for api_path in EGG_API_PATHS: - api_version = api_path.replace('botocore/data/', '').replace('boto3/data/', '').split('/') - if len(api_version) == 2: - full_path = os.path.join(api_path, type_name) - if self.file_loader.exists(full_path): - services.add(api_version[0]) - - return sorted(services) - - -@botocore.loaders.instance_cache -def list_api_versions(self, service_name: str, type_name: str): - """List all API versions available for a particular service type - :type service_name: str - :param service_name: The name of the service - :type type_name: str - :param type_name: The type name for the service (i.e service-2, - paginators-1, etc.) - :rtype: list - :return: A list of API version strings in sorted order. - - """ - known_api_versions = set() - for api_path in EGG_API_PATHS: - if service_name in api_path.split('/'): - api_version = api_path.replace('botocore/data/', '').replace('boto3/data/', '').split('/') - if len(api_version) == 2: - full_path = os.path.join(api_path, type_name) - # Only add to the known_api_versions if the directory - # contains a service-2, paginators-1, etc. file corresponding - # to the type_name passed in. - if self.file_loader.exists(full_path): - known_api_versions.add(api_version[1]) - if not known_api_versions: - # raise Exception('service_name: {0}, type_name: {1}'.format(service_name, type_name)) - raise DataNotFoundError(data_path=service_name) - return sorted(known_api_versions) - - -# monkeypatch the original loaders to handle being inside of an eggsecutable -if EGG: - botocore.loaders.Loader.FILE_LOADER_CLASS = JSONFileLoader2 - botocore.loaders.Loader.load_data = load_data - botocore.loaders.Loader.list_available_services = list_available_services - botocore.loaders.Loader.list_api_versions = list_api_versions diff --git a/eggsecute.py b/eggsecute.py deleted file mode 100644 index faefe30..0000000 --- a/eggsecute.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python - -## Copyright 2016 Ray Holder -## -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. - -import os -import sys -import zipfile - - -def collect_single_module_file(module_name): - """Return a list of tuples of (absolute_file_path, zip_target_path) for a single module file, like six""" - loaded_module = __import__(module_name, globals(), locals(), [], 0) - module_file = loaded_module.__file__ - file_path = os.path.basename(module_file) - - return [(module_file, file_path)] - - -def collect_module_files(module_name, relative_path_in_module): - """Return a list of tuples of (absolute_file_path, zip_target_path)""" - loaded_module = __import__(module_name, globals(), locals(), [], 0) - module_path = os.path.dirname(loaded_module.__file__) - if len(relative_path_in_module) == 0: - # walk the whole module - data_path = module_path - else: - # only walk the relative path in the module - data_path = module_path + '/' + relative_path_in_module - - file_data = [] - for dirpath, dirnames, filenames in os.walk(data_path): - for filename in filenames: - file_path = dirpath + '/' + filename - target_path = module_name + dirpath.replace(module_path, '') + '/' + filename - file_data.append((file_path, target_path)) - return file_data - -def main(script_path, output_path): - if os.path.exists(output_path): - sys.stderr.write("output path '%s' exists; refusing to overwrite\n" % output_path) - return 1 - - # tack Python header onto a file, zip file parsers ignore everything up until PK magic string - outfile = open(output_path, 'w+b') - outfile.write(b"#!/usr/bin/env python3\n") - - # make sure we flush, since we'll be writing zip data right after this - outfile.flush() - - # create the zip file stream - outzip = zipfile.ZipFile(outfile, 'a', zipfile.ZIP_DEFLATED) - - # this is the first thing that Python finds to run, __main__ is special - outzip.write(script_path, "__main__.py") - - # hack to explicitly add everything - module_files = [] - module_files.extend(collect_module_files('aurora_echo', '')) - module_files.extend(collect_module_files('boto3', '')) - module_files.extend(collect_module_files('botocore', '')) - module_files.extend(collect_module_files('dateutil', '')) - module_files.extend(collect_module_files('jmespath', '')) - module_files.extend(collect_module_files('click', '')) - module_files.extend(collect_single_module_file('six')) - - # filter out everything but .py's - filtered_files = [x for x in module_files if x[1].endswith(".py") or x[1].endswith(".json") or x[1].endswith(".pem")] - - for source_path, relative_destination_path in set(filtered_files): - outzip.write(source_path, relative_destination_path) - outzip.close() - outfile.close() - - os.chmod(output_path, 0o755) - - return 0 - - -if __name__ == "__main__": - if len(sys.argv) != 3: - sys.stderr.write("eggsecute \n") - sys.exit(1) - script_path = sys.argv[1] - output_path = sys.argv[2] - - sys.exit(main(script_path, output_path)) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c08ed56..0000000 --- a/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[flake8] -format = pylint -ignore = E501 -max-line-length = 120 -output-file = pylint.out -tee = True diff --git a/setup.py b/setup.py deleted file mode 100644 index 5702750..0000000 --- a/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -from setuptools import setup, find_packages - -setup_requirements = [ - 'flake8==3.5.0' -] - -with open('requirements.txt') as file_requirements: - requirements = file_requirements.read().splitlines() - -setup( - name='aurora_echo', - version='2.0.1', - packages=find_packages(), - install_requires=requirements, - setup_requires=setup_requirements, - entry_points=''' - [console_scripts] - aurora_echo=aurora_echo:main - ''', -)