Script for uploading files to AWS S3 Bucket
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtpython -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txton newer systems, python is replaced by py if you already have python installed.
py -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txtIt'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).
- Do the initial installation above
- Install pyinstaller:
pip install pyinstaller - Run
pyinstaller {flags} --hidden-import=configparser upload-to-s3.py- Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
--onedirif 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.
python upload-to-s3.py --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY /path/to/upload-to-s3.exe --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY