mirror of
https://github.com/tappollo/rtg-datauploader.git
synced 2026-01-12 22:34:53 +08:00
2.1 KiB
2.1 KiB
RTG-Datauploader
Script for uploading files to AWS S3 Bucket
Prerequisites
Installation
Linux
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Windows
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
on newer systems, python is replaced by py if you already have python installed.
py -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
Making an executable
It's tricky installing the requirements for each machine and running it. for scenarios where we just want to run it, we'll use pyinstaller. This library creates an executable on the platform you're using (e.g. Windows to windows, MacOS to MacOs).
Windows
- Do the initial installation above
- Install pyinstaller:
pip install pyinstaller - Run
pyinstaller {flags} upload-to-s3.py- Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
--onefolderif you want the resulting executable to be under a folder with the executable inside. Dependencies it needs are not bundled inside theexecutablefile.--onefileif you want everything bundled into the resultingexecutablefile
- for python 3.10 or if the result of command shows
ImportError: No module named _bootlocale: include the following flag--exclude-module _bootlocale
- Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
- Upon completion, the resulting executable should be inside a
distfolder generated by pyinstaller.
Usage
Non executable
python upload-to-s3.py --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY
Executable (windows)
upload-to-s3.exe --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY