Skip to content

Commit

Permalink
aws-lambda-builders requires setup.py when using git references (#7)
Browse files Browse the repository at this point in the history
When referencing a dependency using a git URL was-lambda-builder raises an error if there is no setup.py

aws/aws-lambda-builders#555
  • Loading branch information
ayongbannayan authored Jan 2, 2024
1 parent 9ddf6b0 commit cf2fc99
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
24 changes: 10 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,19 @@ exclude = [

[tool.black]
line-length = 120
exclude = '''
/(
\.git
| \.mypy_cache
| \.tox
| venv
| \.venv
| _build
| buck-out
| build
| dist
)/
extend-exclude = '''
(
^/setup.py
)
'''


[tool.bandit]
skips = ['B324']
exclude_dirs = [".venv", "tests", "dist"]
exclude_dirs = [".venv", "tests", "dist", "setup.py"]

[tool.ruff]
exclude = [".venv", "setup.py"]
target-version = "py311"
line-length = 120
select = [
Expand Down Expand Up @@ -129,7 +123,8 @@ source = ["src"]
omit = [
".venv/*",
"tests/*",
"src/skymantle_boto_buddy/__about__.py"
"src/skymantle_boto_buddy/__about__.py",
"setup.py"
]

[tool.coverage.report]
Expand All @@ -144,6 +139,7 @@ pythonpath = "src"
markers = []

[tool.hatch.build.targets.sdist]
support-legacy = true
exclude = [
"/.vscode",
"/.github",
Expand Down
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from setuptools import setup

setup(
name='skymantle-boto-buddy',
version='0.1.0',
description='A wrappper for boto3 to access common aws severless services.',
long_description='# Skymantle Boto Buddy\n\nA wrappper for boto3 to access common aws severless services primarily used for aws Lambda. The wrapper is dependent on using boto3 configuration using [environment variables](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#using-environment-variables) for setting credentials for accessing aws resources. It\'s also possible to provide a `boto3.Session` object for setting credentials.\n\nWhen used within the context of an aws lambda function, no creditials are required and instances of boto3 resource and clients are created during lambda initialization.\nThe library determines its running in the context of a lambda function but looking for the `AWS_LAMBDA_FUNCTION_NAME` environment variable.\n\nThe boto3 client and resource objects are cached but it is possible to also get uncached instances or cache can be disabled globally by setting the `BOTO_BUDDY_DISABLE_CACHE` environment variable. Supported values are `1`, `true`, `yes` and `on`.\n\nThe following project commands are supported:\n- `make setup` - Installs all dependencies ands creates virtual environment\n- `make unitTests` - runs unit tests\n- `make lintAndAnalysis` - Runs [ruff](https://github.com/astral-sh/ruff), [bandit](https://github.com/PyCQA/bandit) and [black](https://github.com/psf/black)\n- `make build` - Creates distribution\n\n## Installation\n\nCurrently the package isn\'t on pypi, however the GitHub repo can be referenced directly in a requirements file. For example:\n- `skymantle_boto_buddy @ git+https://github.com/skymantle-tech/skymantle-boto-buddy@main`\n\nUsing `skymantle_boto_buddy` will not include the boto3 dependency, useful when part of a lambda function and the lambda runtime version of boto3 or a layer is used. To include boto3 use `skymantle_boto_buddy[boto3]`.\n\n## Usage\n\nThe library provides the following functions.\n\n- Package\n - `get_boto3_client`\n - `get_boto3_resource`\n- DynamoDb\n - `get_dynamodb_resource`\n - `get_table`\n - `put_item_simplified`\n - `update_item_simplified`\n - `get_item`\n - `delete_item`\n - `query_no_paging`\n- S3\n - `get_s3_client`\n - `get_s3_resource`\n - `get_bucket`\n - `get_object_signed_url`\n - `put_object_signed_url`\n - `get_object`\n - `get_object_bytes`\n - `get_object_json`\n - `get_object_csv_reader`\n - `upload_fileobj`\n - `put_object`\n - `delete_object`\n - `delete_objects`\n - `copy`\n - `list_objects_v2`\n - `execute_sql_query_simplified`\n- SSM\n - `get_ssm_client`\n - `get_parameter`\n - `get_parameter_decrypted`\n- CloudFormation\n - `get_cloudformation_client`\n - `describe_stacks`\n - `get_stack_outputs`\n\n\n### Examples\n\n- running inside a lambda function or using environment variable creditional\n\n```python\nfrom skymantle_boto_buddy import dynamodb\n\ndynamodb.put_item_simplified("table_name", {"PK": "some_key", "Description": "Some description"})\n```\n\n- providing a Session and specifiying a profile named `developer`\n\n```python\nfrom boto3 import Session\nfrom skymantle_boto_buddy import dynamodb\n\nsession = Session(profile_name="developer")\ndynamodb.put_item_simplified("table_name", {"PK": "some_key", "Description": "Some description"}, session=session)\n```\n\n- Get a version of the s3 client that is not cached\n\n```python\nfrom boto3 import Session\nfrom skymantle_boto_buddy import EnableCache, s3\n\ns3_client = get_s3_client(enable_cache=EnableCache.NO)\n```\n\n- unit test a function with patching (also possible to use packages like [moto](https://github.com/getmoto/moto))\n\n```python\n# my_file.py\nfrom skymantle_boto_buddy import dynamodb\n\ndef some_function():\n # ...\n item = dynamodb.get_item("table_name", {"PK": "some_key"})\n \n return item\n\n\n# my_test.py\nfrom unittest.mock import MagicMock\nimport pytest\nfrom pytest_mock import MockerFixture\nimport my_file\n\n@pytest.fixture()\ndef mock_dynamodb(mocker: MockerFixture) -> MagicMock:\n mock = mocker.patch("my_file.dynamodb")\n return mock\n\ndef test_some_function(mock_dynamodb):\n mock_dynamodb.get_item.return_value = {"PK": "some_pk", "Name": "some value"}\n\n result = my_file.some_function()\n assert result == {"PK": "some_pk", "Name": "some value"}\n```',
author_email='Artin Yong-Bannayan <[email protected]>',
extras_require={
'boto': [
'boto3',
],
},
packages=[
'skymantle_boto_buddy',
],
package_dir={'': 'src'},
)

0 comments on commit cf2fc99

Please sign in to comment.