Skip to content

Modernize packaging #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,25 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- name: Set up uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
with:
version: "0.7.7"
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"

- name: Install dependencies
run: |
pip install -r test-requirements.txt --upgrade pip
pip install "urllib3==${{ matrix.urllib3-version }}"
uv sync
uv pip install "urllib3==${{ matrix.urllib3-version }}"

- if: matrix.python-version == '3.10' && matrix.urllib3-version == '1.26.19'
name: Run `ruff`
run: ruff check
run: uv run ruff check

- name: Run tests and collect coverage
run: pytest --cov-fail-under 60 --cov openfga_sdk
run: uv run pytest --cov-fail-under 60 --cov openfga_sdk

- if: matrix.python-version == '3.10' && matrix.urllib3-version == '1.26.19'
name: Upload coverage to Codecov
Expand All @@ -69,23 +67,19 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
- name: Set up uv and Python
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
with:
version: "0.7.7"
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"

- name: Install dependencies
run: pip install -r test-requirements.txt --upgrade pip
run: uv sync

- name: Build package
run: |
pip install setuptools wheel
python setup.py sdist bdist_wheel
run: uv build

- name: Publish package
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,7 @@ List the users who have a certain relation to a particular type.
```python
from openfga_sdk import OpenFgaClient
from openfga_sdk.models.fga_object import FgaObject
from openfga_sdk.client.models import ClientTuple
from openfga_sdk.client.models.list_users_request import ClientListUsersRequest
from openfga_sdk.client.models import ClientListUsersRequest, ClientTuple

configuration = ClientConfiguration(
api_url=FGA_API_URL,
Expand Down
4 changes: 1 addition & 3 deletions docs/OpenFgaApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,10 @@ async with openfga_sdk.ApiClient(configuration) as api_client:
api_instance = openfga_sdk.OpenFgaApi(api_client)
page_size = 56 # int | (optional)
continuation_token = 'continuation_token_example' # str | (optional)
name = 'name_example' # str | The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated (optional)

try:
# List all stores
api_response = await api_instance.api_instance.list_stores(page_size=page_size, continuation_token=continuation_token, name=name)
api_response = await api_instance.api_instance.list_stores(page_size=page_size, continuation_token=continuation_token)
pprint(api_response)
except ApiException as e:
print("Exception when calling OpenFgaApi->list_stores: %s\n" % e)
Expand All @@ -661,7 +660,6 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**page_size** | **int**| | [optional]
**continuation_token** | **str**| | [optional]
**name** | **str**| The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated | [optional]

### Return type

Expand Down
8 changes: 1 addition & 7 deletions openfga_sdk/api/open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,6 @@ async def list_stores(self, **kwargs):
:type page_size: int, optional
:param continuation_token:(optional)
:type continuation_token: str, optional
:param name: The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated(optional)
:type name: str, optional
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
Expand Down Expand Up @@ -1286,8 +1284,6 @@ async def list_stores_with_http_info(self, **kwargs):
:type page_size: int, optional
:param continuation_token:(optional)
:type continuation_token: str, optional
:param name: The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated(optional)
:type name: str, optional
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
Expand Down Expand Up @@ -1315,7 +1311,7 @@ async def list_stores_with_http_info(self, **kwargs):

local_var_params = locals()

all_params = ["page_size", "continuation_token", "name"]
all_params = ["page_size", "continuation_token"]
all_params.extend(
[
"async_req",
Expand Down Expand Up @@ -1351,8 +1347,6 @@ async def list_stores_with_http_info(self, **kwargs):
query_params.append(
("continuation_token", local_var_params["continuation_token"])
)
if local_var_params.get("name") is not None:
query_params.append(("name", local_var_params["name"]))

header_params = dict(local_var_params.get("_headers", {}))

Expand Down
8 changes: 1 addition & 7 deletions openfga_sdk/sync/open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,6 @@ def list_stores(self, **kwargs):
:type page_size: int, optional
:param continuation_token:(optional)
:type continuation_token: str, optional
:param name: The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated(optional)
:type name: str, optional
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
Expand Down Expand Up @@ -1284,8 +1282,6 @@ def list_stores_with_http_info(self, **kwargs):
:type page_size: int, optional
:param continuation_token:(optional)
:type continuation_token: str, optional
:param name: The name parameter instructs the API to only include results that match that name.Multiple results may be returned. Only exact matches will be returned; substring matches and regexes will not be evaluated(optional)
:type name: str, optional
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
Expand Down Expand Up @@ -1313,7 +1309,7 @@ def list_stores_with_http_info(self, **kwargs):

local_var_params = locals()

all_params = ["page_size", "continuation_token", "name"]
all_params = ["page_size", "continuation_token"]
all_params.extend(
[
"async_req",
Expand Down Expand Up @@ -1349,8 +1345,6 @@ def list_stores_with_http_info(self, **kwargs):
query_params.append(
("continuation_token", local_var_params["continuation_token"])
)
if local_var_params.get("name") is not None:
query_params.append(("name", local_var_params["name"]))

header_params = dict(local_var_params.get("_headers", {}))

Expand Down
63 changes: 62 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
#
# Python SDK for OpenFGA
#
# API version: 1.x
# Website: https://openfga.dev
# Documentation: https://openfga.dev/docs
# Support: https://openfga.dev/community
# License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
#

[project]
name = "openfga-sdk"
version = "0.9.5"
description="A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar."
authors = [
{ name = "OpenFGA (https://openfga.dev)", email = "[email protected]"}
]
readme = "README.md"
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
keywords=[
"openfga",
"authorization",
"fga",
"fine-grained-authorization",
"rebac",
"zanzibar",
]
requires-python=">=3.10"
license="Apache-2.0"
dependencies = [
"aiohttp>=3.9.3",
"python-dateutil>=2.9.0",
"opentelemetry-api>=1.25.0",
"urllib3>=1.26.19,<3"
]

[project.urls]
Repository="https://github.com/openfga/python-sdk.git"

[dependency-groups]
dev = [
"griffe>=0.41.2",
"mock>=5.1.0",
"pytest-asyncio>=0.25",
"pytest-cov>=5",
"ruff>=0.9",
"mypy>=1.14.1",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"


[tool.ruff]
exclude = [
".bzr",
Expand Down Expand Up @@ -79,7 +140,7 @@ asyncio_default_fixture_loop_scope = "function"
python_version = "3.10"
packages = "openfga_sdk"
exclude = [
"openfa_sdk/models",
"openfga_sdk/models",
]
#warn_return_any = "True"
#warn_unused_configs = "True"
Expand Down
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

64 changes: 0 additions & 64 deletions setup.py

This file was deleted.

8 changes: 0 additions & 8 deletions test-requirements.txt

This file was deleted.

Loading