baresquare-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. baresquare_sdk-0.1.0/.github/CODEOWNERS +3 -0
  2. baresquare_sdk-0.1.0/.github/pr-prefix-labeler.yml +11 -0
  3. baresquare_sdk-0.1.0/.github/release.yml +14 -0
  4. baresquare_sdk-0.1.0/.github/workflows/publish.yml +44 -0
  5. baresquare_sdk-0.1.0/.github/workflows/pull-request-checks.yml +45 -0
  6. baresquare_sdk-0.1.0/.github/workflows/test.yml +34 -0
  7. baresquare_sdk-0.1.0/.gitignore +44 -0
  8. baresquare_sdk-0.1.0/.python-version +1 -0
  9. baresquare_sdk-0.1.0/LICENSE +21 -0
  10. baresquare_sdk-0.1.0/PKG-INFO +160 -0
  11. baresquare_sdk-0.1.0/README.md +136 -0
  12. baresquare_sdk-0.1.0/baresquare_sdk/__init__.py +16 -0
  13. baresquare_sdk-0.1.0/baresquare_sdk/aws/__init__.py +21 -0
  14. baresquare_sdk-0.1.0/baresquare_sdk/aws/authentication.py +214 -0
  15. baresquare_sdk-0.1.0/baresquare_sdk/aws/s3.py +33 -0
  16. baresquare_sdk-0.1.0/baresquare_sdk/aws/ssm.py +70 -0
  17. baresquare_sdk-0.1.0/baresquare_sdk/core/__init__.py +14 -0
  18. baresquare_sdk-0.1.0/baresquare_sdk/core/exceptions.py +140 -0
  19. baresquare_sdk-0.1.0/baresquare_sdk/core/logger.py +147 -0
  20. baresquare_sdk-0.1.0/baresquare_sdk/core/middleware/__init__.py +7 -0
  21. baresquare_sdk-0.1.0/baresquare_sdk/core/middleware/compression.py +5 -0
  22. baresquare_sdk-0.1.0/baresquare_sdk/core/middleware/cors.py +13 -0
  23. baresquare_sdk-0.1.0/baresquare_sdk/core/middleware/request_info.py +27 -0
  24. baresquare_sdk-0.1.0/pyproject.toml +137 -0
  25. baresquare_sdk-0.1.0/scripts/publish_local.sh +67 -0
  26. baresquare_sdk-0.1.0/tests/test_aws/test_hello_aws.py +5 -0
  27. baresquare_sdk-0.1.0/tests/test_core/test_hello_core.py +10 -0
@@ -0,0 +1,3 @@
1
+ # These owners will be the default owners for everything
2
+ # in the repo, unless a later match takes precedence
3
+ * @lucas-bsq
@@ -0,0 +1,11 @@
1
+ "[feat]": "feat"
2
+ "[fix]": "fix"
3
+ "[docs]": "docs"
4
+ "[style]": "style"
5
+ "[refactor]": "refactor"
6
+ "[perf]": "perf"
7
+ "[test]": "test"
8
+ "[build]": "build"
9
+ "[ci]": "ci"
10
+ "[chore]": "chore"
11
+ "[revert]": "revert"
@@ -0,0 +1,14 @@
1
+ changelog:
2
+ categories:
3
+ - title: Features
4
+ labels:
5
+ - feat
6
+ - title: Fixes
7
+ labels:
8
+ - fix
9
+ - title: Documentation
10
+ labels:
11
+ - docs
12
+ - title: Other
13
+ labels:
14
+ - '*'
@@ -0,0 +1,44 @@
1
+ name: Build and Publish Python Packages to PyPI
2
+
3
+ on:
4
+ # Publish when tags are pushed
5
+ push:
6
+ tags:
7
+ - 'v*'
8
+
9
+ jobs:
10
+ build-and-publish:
11
+ name: Build and Publish
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: '3.12'
22
+
23
+ - name: Install build dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install build twine
27
+
28
+ - name: Build and publish core package
29
+ env:
30
+ TWINE_USERNAME: __token__
31
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
32
+ run: |
33
+ cd core
34
+ python -m build
35
+ python -m twine upload dist/*
36
+
37
+ - name: Build and publish AWS package
38
+ env:
39
+ TWINE_USERNAME: __token__
40
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
41
+ run: |
42
+ cd aws
43
+ python -m build
44
+ python -m twine upload dist/*
@@ -0,0 +1,45 @@
1
+ name: "Semantic Pull Request and automatic labeling"
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, edited, reopened]
6
+
7
+ jobs:
8
+ main:
9
+ name: Validate PR title and label the PR
10
+ runs-on: ubuntu-22.04
11
+ steps:
12
+ - name: Validate PR title
13
+ uses: BareSquare/action-semantic-pull-request@main
14
+ env:
15
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16
+ with:
17
+ # https://github.com/commitizen/conventional-commit-types/blob/master/index.json
18
+ types: |
19
+ [feat]
20
+ [fix]
21
+ [docs]
22
+ [style]
23
+ [refactor]
24
+ [perf]
25
+ [test]
26
+ [build]
27
+ [ci]
28
+ [chore]
29
+ [revert]
30
+ scopes: |
31
+ PL-\d+
32
+ ADHOC
33
+ requireScope: true
34
+ subjectPattern: ^[A-Z].*$
35
+ subjectPatternError: |
36
+ The subject "{subject}" found in the pull request title "{title}"
37
+ didn't match the configured pattern. Please ensure that the subject
38
+ starts with an uppercase character.
39
+ headerPattern: '^(\[\w*\]) (?:([\w\$\.\-\* ]*))?\: (.*)$'
40
+ headerPatternCorrespondence: type, scope, subject
41
+
42
+ - name: Label the PR
43
+ uses: BareSquare/pr-prefix-labeler@master
44
+ env:
45
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,34 @@
1
+ name: Tests
2
+
3
+ on:
4
+ # Run tests on pull requests
5
+ pull_request:
6
+ branches: [ main ]
7
+
8
+ jobs:
9
+ test-and-lint:
10
+ name: Feature branch tests
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version-file: '.python-version'
21
+
22
+ - name: Install package in editable mode with dev dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ python -m pip install -e ".[linting,testing,aws]"
26
+
27
+ - name: Run linting
28
+ run: |
29
+ ruff format --check src tests
30
+ ruff check src tests
31
+
32
+ - name: Run tests
33
+ run: |
34
+ pytest
@@ -0,0 +1,44 @@
1
+ # Editors
2
+ .vscode/
3
+ .idea/
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # Distribution / packaging
11
+ dist/
12
+ build/
13
+ *.egg-info/
14
+ *.egg
15
+ wheel_extract
16
+
17
+ # Unit test / coverage reports
18
+ htmlcov/
19
+ .tox/
20
+ .coverage
21
+ .coverage.*
22
+ .cache
23
+ coverage.xml
24
+ *.cover
25
+ .pytest_cache/
26
+
27
+ # Virtual environments
28
+ venv/
29
+ env/
30
+ ENV/
31
+ .env/
32
+ .venv/
33
+
34
+ # Jupyter Notebook
35
+ .ipynb_checkpoints
36
+
37
+ # mypy
38
+ .mypy_cache/
39
+
40
+ # ruff
41
+ .ruff_cache/
42
+
43
+ # Logs
44
+ *.log
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Baresquare
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: baresquare-sdk
3
+ Version: 0.1.0
4
+ Summary: Baresquare SDK for Python
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: fastapi>=0.115.12
9
+ Provides-Extra: aws
10
+ Requires-Dist: boto3>=1.38.21; extra == 'aws'
11
+ Requires-Dist: pyjwt[crypto]==2.10.1; extra == 'aws'
12
+ Requires-Dist: requests==2.32.3; extra == 'aws'
13
+ Provides-Extra: dev
14
+ Requires-Dist: boto3>=1.38.21; extra == 'dev'
15
+ Requires-Dist: pyjwt[crypto]==2.10.1; extra == 'dev'
16
+ Requires-Dist: pytest==8.3.5; extra == 'dev'
17
+ Requires-Dist: requests==2.32.3; extra == 'dev'
18
+ Requires-Dist: ruff==0.11.9; extra == 'dev'
19
+ Provides-Extra: linting
20
+ Requires-Dist: ruff==0.11.9; extra == 'linting'
21
+ Provides-Extra: testing
22
+ Requires-Dist: pytest==8.3.5; extra == 'testing'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Baresquare Python Libraries
26
+
27
+ > [!CAUTION]
28
+ > This code is published publicly in PyPI - make sure you do not include proprietary information.
29
+
30
+ This monorepo hosts Baresquare's Python packages, all published to PyPI.
31
+
32
+ ## Packages
33
+
34
+ The repository currently contains the following packages:
35
+
36
+ - **baresquare_core_py**: Core utilities shared across Baresquare services
37
+ - **baresquare_aws_py**: AWS-specific utilities that build upon core
38
+
39
+ ## Development Guidelines
40
+
41
+ ### Versioning
42
+
43
+ - All packages share the same version number
44
+ - Version is defined in each package's `__init__.py` file (`__version__ = "x.y.z"`)
45
+ - Git tags must match the version in `__init__.py` files (format: `vx.y.z`)
46
+ - CI will validate version consistency before publishing
47
+
48
+ ### Package Configuration
49
+
50
+ - A single `pyproject.toml` file is used for all packages
51
+ - Package-specific settings are handled in the CI process
52
+ - Dependencies between packages are defined in `pyproject.toml` under `[project.optional-dependencies]`
53
+
54
+ ### Development Setup
55
+
56
+ To set up the packages for development:
57
+
58
+ ```shell
59
+ # Install in development mode with all dependencies
60
+ pip install -e ".[testing]"
61
+
62
+ # Run tests
63
+ pytest
64
+ ```
65
+
66
+ > [!WARNING]
67
+ > When introducing a new `.py` file, make sure to add it in the appropriate `__init__.py` file, otherwise it will not be
68
+ > makde available in the published package.
69
+
70
+ ### Linting
71
+
72
+ For each directory:
73
+ - Show linting issues: `ruff check . --preview`
74
+ - Fix linting issues: `ruff . --fix --preview`
75
+
76
+ ### Testing
77
+
78
+ Install packages
79
+
80
+ ```shell
81
+ # First in the core directory
82
+ cd core
83
+ pip install -e .
84
+
85
+ # Then in the aws directory
86
+ cd ../aws
87
+ pip install -e .[testing]
88
+ ```
89
+
90
+ Then run `pytest` in each directory
91
+
92
+ ## Publishing
93
+
94
+ > [!TIP]
95
+ > Before publishing properly, check the build locally (see instructions below).
96
+
97
+ ### With GitHub Action
98
+
99
+ **It is recommended to publish a new version by creating a GitHub release, as this creates release notes in the relevant
100
+ GitHub page.**
101
+
102
+ Packages are published to PyPI through GitHub Actions when a new tag is pushed:
103
+
104
+ 1. Update the `version` field in all `pyproject.toml` files (should be the same everywhere)
105
+ 1. If there is optional dependency array `publishing`, update the core package version there too (e.g. in `pyproject.toml` of the AWS package)
106
+ 1. Commit changes
107
+ 1. Create and push a tag matching the version (assuming version to be published is 0.1.0):
108
+ - via command line: `git tag v0.1.0 && git push origin v0.1.0`
109
+ - via GitHub UI: Go to "Releases" → "Draft a new release" → "Choose a tag" → Enter "v0.1.0" → "Create new tag"
110
+
111
+ CI will validate versions, build packages, and publish to PyPI
112
+
113
+ ### Manually
114
+
115
+ You can also use `scripts/publish_local.sh`:
116
+
117
+ 1. Set environment variables:
118
+ ```shell
119
+ export TWINE_USERNAME=__token__
120
+ export TWINE_PASSWORD=XXX
121
+ ```
122
+ 1. If there is optional dependency array `publishing`, update the core package version there too (e.g. in `pyproject.toml` of the AWS package)
123
+ 1. Check `pyproject.toml` files of non-core packages - they may reference the version of `baresquare-core-py`
124
+ 1. Create a tag locally matching the version
125
+ 1. Run `scripts/publish_local.sh`
126
+
127
+ ### Check the build
128
+
129
+ When introducing a new file, ensure the file will be made available in the published package.
130
+
131
+ ```shell
132
+ cd core
133
+ python -m build
134
+ mkdir -p wheel_extract
135
+ # Extract the wheel (it's just a zip file) - make sure to change the version accordingly
136
+ unzip dist/baresquare_core_py-0.1.0-py3-none-any.whl -d wheel_extract
137
+ # View the contents
138
+ ls -la wheel_extract
139
+ # Specifically check for your Python files
140
+ find wheel_extract -name "*.py"
141
+ ```
142
+
143
+ then check the file exists in the output.
144
+
145
+ These instructions are for the `core` package - adjust accordingly for other packages.
146
+
147
+ ## Installation
148
+
149
+
150
+ ```shell
151
+ # Install core package
152
+ pip install baresquare_core_py
153
+
154
+ # Install AWS package (which includes core)
155
+ pip install baresquare_aws_py
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT License
@@ -0,0 +1,136 @@
1
+ # Baresquare Python Libraries
2
+
3
+ > [!CAUTION]
4
+ > This code is published publicly in PyPI - make sure you do not include proprietary information.
5
+
6
+ This monorepo hosts Baresquare's Python packages, all published to PyPI.
7
+
8
+ ## Packages
9
+
10
+ The repository currently contains the following packages:
11
+
12
+ - **baresquare_core_py**: Core utilities shared across Baresquare services
13
+ - **baresquare_aws_py**: AWS-specific utilities that build upon core
14
+
15
+ ## Development Guidelines
16
+
17
+ ### Versioning
18
+
19
+ - All packages share the same version number
20
+ - Version is defined in each package's `__init__.py` file (`__version__ = "x.y.z"`)
21
+ - Git tags must match the version in `__init__.py` files (format: `vx.y.z`)
22
+ - CI will validate version consistency before publishing
23
+
24
+ ### Package Configuration
25
+
26
+ - A single `pyproject.toml` file is used for all packages
27
+ - Package-specific settings are handled in the CI process
28
+ - Dependencies between packages are defined in `pyproject.toml` under `[project.optional-dependencies]`
29
+
30
+ ### Development Setup
31
+
32
+ To set up the packages for development:
33
+
34
+ ```shell
35
+ # Install in development mode with all dependencies
36
+ pip install -e ".[testing]"
37
+
38
+ # Run tests
39
+ pytest
40
+ ```
41
+
42
+ > [!WARNING]
43
+ > When introducing a new `.py` file, make sure to add it in the appropriate `__init__.py` file, otherwise it will not be
44
+ > makde available in the published package.
45
+
46
+ ### Linting
47
+
48
+ For each directory:
49
+ - Show linting issues: `ruff check . --preview`
50
+ - Fix linting issues: `ruff . --fix --preview`
51
+
52
+ ### Testing
53
+
54
+ Install packages
55
+
56
+ ```shell
57
+ # First in the core directory
58
+ cd core
59
+ pip install -e .
60
+
61
+ # Then in the aws directory
62
+ cd ../aws
63
+ pip install -e .[testing]
64
+ ```
65
+
66
+ Then run `pytest` in each directory
67
+
68
+ ## Publishing
69
+
70
+ > [!TIP]
71
+ > Before publishing properly, check the build locally (see instructions below).
72
+
73
+ ### With GitHub Action
74
+
75
+ **It is recommended to publish a new version by creating a GitHub release, as this creates release notes in the relevant
76
+ GitHub page.**
77
+
78
+ Packages are published to PyPI through GitHub Actions when a new tag is pushed:
79
+
80
+ 1. Update the `version` field in all `pyproject.toml` files (should be the same everywhere)
81
+ 1. If there is optional dependency array `publishing`, update the core package version there too (e.g. in `pyproject.toml` of the AWS package)
82
+ 1. Commit changes
83
+ 1. Create and push a tag matching the version (assuming version to be published is 0.1.0):
84
+ - via command line: `git tag v0.1.0 && git push origin v0.1.0`
85
+ - via GitHub UI: Go to "Releases" → "Draft a new release" → "Choose a tag" → Enter "v0.1.0" → "Create new tag"
86
+
87
+ CI will validate versions, build packages, and publish to PyPI
88
+
89
+ ### Manually
90
+
91
+ You can also use `scripts/publish_local.sh`:
92
+
93
+ 1. Set environment variables:
94
+ ```shell
95
+ export TWINE_USERNAME=__token__
96
+ export TWINE_PASSWORD=XXX
97
+ ```
98
+ 1. If there is optional dependency array `publishing`, update the core package version there too (e.g. in `pyproject.toml` of the AWS package)
99
+ 1. Check `pyproject.toml` files of non-core packages - they may reference the version of `baresquare-core-py`
100
+ 1. Create a tag locally matching the version
101
+ 1. Run `scripts/publish_local.sh`
102
+
103
+ ### Check the build
104
+
105
+ When introducing a new file, ensure the file will be made available in the published package.
106
+
107
+ ```shell
108
+ cd core
109
+ python -m build
110
+ mkdir -p wheel_extract
111
+ # Extract the wheel (it's just a zip file) - make sure to change the version accordingly
112
+ unzip dist/baresquare_core_py-0.1.0-py3-none-any.whl -d wheel_extract
113
+ # View the contents
114
+ ls -la wheel_extract
115
+ # Specifically check for your Python files
116
+ find wheel_extract -name "*.py"
117
+ ```
118
+
119
+ then check the file exists in the output.
120
+
121
+ These instructions are for the `core` package - adjust accordingly for other packages.
122
+
123
+ ## Installation
124
+
125
+
126
+ ```shell
127
+ # Install core package
128
+ pip install baresquare_core_py
129
+
130
+ # Install AWS package (which includes core)
131
+ pip install baresquare_aws_py
132
+ ```
133
+
134
+ ## License
135
+
136
+ MIT License
@@ -0,0 +1,16 @@
1
+ """Baresquare SDK for Python.
2
+
3
+ This package provides core utilities and AWS integrations for Baresquare services.
4
+ """
5
+
6
+ # Make submodules available for import
7
+ from . import core
8
+
9
+ # Only import aws if dependencies are available
10
+ try:
11
+ from . import aws
12
+ except ImportError:
13
+ # AWS dependencies not installed
14
+ aws = None
15
+
16
+ __all__ = ["core", "aws"]
@@ -0,0 +1,21 @@
1
+ """Baresquare AWS Python utilities.
2
+
3
+ This package provides AWS-specific utilities for Baresquare services.
4
+ """
5
+
6
+ try:
7
+ # Check if AWS dependencies are available
8
+ import boto3 # noqa: F401
9
+
10
+ from . import authentication
11
+ from . import s3
12
+ from . import ssm
13
+
14
+ from ..core.logger import setup_logger
15
+
16
+ logger = setup_logger()
17
+
18
+ __all__ = ["authentication", "s3", "ssm", "logger"]
19
+
20
+ except ImportError as e:
21
+ raise ImportError("AWS dependencies not found. Install with: pip install baresquare-sdk[aws]") from e