From 7509360d19df9240c4112d1a3df904ea46fa70fc Mon Sep 17 00:00:00 2001 From: Matthew Davis Date: Sun, 15 Dec 2019 16:59:50 +1100 Subject: [PATCH] make into pip installable package --- LICENSE => LICENSE.txt | 0 README.md | 10 +++++++--- bbp/__init__.py | 1 + wrapper.py => bbp/wrapper.py | 0 lambda_example.py | 2 +- s3_example.py | 2 +- setup.cfg | 3 +++ setup.py | 25 +++++++++++++++++++++++++ 8 files changed, 38 insertions(+), 5 deletions(-) rename LICENSE => LICENSE.txt (100%) create mode 100644 bbp/__init__.py rename wrapper.py => bbp/wrapper.py (100%) create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index fc17fc4..e44dea2 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,11 @@ for element in function(Bucket='my-bucket'): This library provides that function. -## Installation and usage +## Installation -Download `wrapper.py`, save it in the same directory as the file calling it. -(I'll eventually make it `pip` installable.) +`pip install bbp` + +## Usage Here's an example of how to use it for the [Lambda `ListFunctions` paginator](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Paginator.ListFunctions). @@ -72,4 +73,7 @@ for obj in paginator('s3', 'list_objects_v2', 'Contents', Bucket='mybucket'): * `Bucket='mybucket'` and any other `name=value` arguments are what get passed to [the paginator](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Paginator.ListObjectsV2). +## Packaging +This is my first ever package on PyPI. +I used [this guide](https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56) to learn how to do this. diff --git a/bbp/__init__.py b/bbp/__init__.py new file mode 100644 index 0000000..4be8140 --- /dev/null +++ b/bbp/__init__.py @@ -0,0 +1 @@ +from .wrapper import paginator diff --git a/wrapper.py b/bbp/wrapper.py similarity index 100% rename from wrapper.py rename to bbp/wrapper.py diff --git a/lambda_example.py b/lambda_example.py index 5b15a12..e17b2d1 100644 --- a/lambda_example.py +++ b/lambda_example.py @@ -1,4 +1,4 @@ -from wrapper import paginator +from bbp import paginator from pprint import pprint for lam in paginator('lambda', 'list_functions', 'Functions'): pprint(lam) # process a single resource diff --git a/s3_example.py b/s3_example.py index 32d7b89..80c219a 100644 --- a/s3_example.py +++ b/s3_example.py @@ -1,4 +1,4 @@ -from wrapper import paginator +from bbp import paginator from pprint import pprint bucket_name = 'reddit-amp-bot-code' for obj in paginator('s3', 'list_objects_v2', 'Contents', Bucket=bucket_name): diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3287428 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +# Inside of setup.cfg +[metadata] +description-file = README.md diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4ece3ab --- /dev/null +++ b/setup.py @@ -0,0 +1,25 @@ +from distutils.core import setup +setup( + name = 'bbp', # How you named your package folder (MyLib) + packages = ['bbp'], # Chose the same as "name" + version = '0.1', # Start with a small number and increase it with every change you make + license='GPLv3', + description = 'A wrapper for boto3 paginators to iterate per resource', + author = 'Matthew Davis', + author_email = 'bbp@mdavis.xyz', + url = 'https://github.com/mlda065/bbp', # Provide either the link to your github or to your website + download_url = 'https://github.com/mlda065/bbp/archive/v_01.tar.gz', + keywords = ['boto3', 'boto', 'AWS', 'Amazon', 'paginator', 'pagination', 'page', 'api', 'cloud'], + install_requires=['boto3'], + classifiers=[ + 'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Build Tools', + 'License :: OSI Approved :: GPLv3 License', + 'Programming Language :: Python :: 3', #Specify which pyhton versions that you want to support + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7' + ], +)