diff --git a/Makefile b/Makefile index 46f2ca2c0..6a5dfdd95 100644 --- a/Makefile +++ b/Makefile @@ -122,18 +122,18 @@ build-client-python: patch -p1 /module/openfga_sdk/sync/open_fga_api.py /config/clients/python/patches/open_fga_api_sync.py.patch && \ patch -p1 /module/docs/OpenFgaApi.md /config/clients/python/patches/OpenFgaApi.md.patch'" - make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install --upgrade pip && \ - python -m pip install --upgrade setuptools wheel && \ - python -m pip install -r test-requirements.txt && \ - python -m ruff check --select I --fix . && \ - python -m ruff format . && \ - python setup.py sdist bdist_wheel'" + make run-in-docker sdk_language=python image=ghcr.io/astral-sh/uv:python${PYTHON_DOCKER_TAG}-alpine command="/bin/sh -c 'export UV_LINK_MODE=copy && \ + uv sync && \ + uv run ruff check --select I --fix . && \ + uv run ruff format . && \ + uv build'" .PHONY: test-client-python test-client-python: build-client-python - make run-in-docker sdk_language=python image=python:${PYTHON_DOCKER_TAG} command="/bin/sh -c 'python -m pip install -r test-requirements.txt && \ - pytest --cov-report term-missing --cov=openfga_sdk test/ && \ - ruff check .'" + make run-in-docker sdk_language=python image=ghcr.io/astral-sh/uv:python${PYTHON_DOCKER_TAG}-alpine command="/bin/sh -c 'export UV_LINK_MODE=copy && \ + uv sync && \ + uv run pytest --cov-report term-missing --cov=openfga_sdk test/ && \ + uv run ruff check .'" ### Java .PHONY: tag-client-java diff --git a/config/clients/python/.openapi-generator-ignore b/config/clients/python/.openapi-generator-ignore index 56a5dff45..e86b5f6cd 100644 --- a/config/clients/python/.openapi-generator-ignore +++ b/config/clients/python/.openapi-generator-ignore @@ -15,3 +15,6 @@ test/* .travis.yml tox.ini setup.cfg +setup.py +requirements.txt +test-requirements.txt \ No newline at end of file diff --git a/config/clients/python/config.overrides.json b/config/clients/python/config.overrides.json index 0dcd369be..dcde9763f 100644 --- a/config/clients/python/config.overrides.json +++ b/config/clients/python/config.overrides.json @@ -14,8 +14,9 @@ "supportsStreamedListObjects": "streamed_list_objects", "files": { ".snyk": {}, - "pyproject.toml": {}, - + "pyproject.toml.mustache": { + "destinationFilename": "pyproject.toml" + }, "api_sync.mustache": { "folder": "openfga_sdk/sync", "destinationFilename": "_sync.py", diff --git a/config/clients/python/template/pyproject.toml b/config/clients/python/template/pyproject.toml deleted file mode 100644 index ce9733171..000000000 --- a/config/clients/python/template/pyproject.toml +++ /dev/null @@ -1,86 +0,0 @@ -[tool.ruff] -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".git-rewrite", - ".hg", - ".ipynb_checkpoints", - ".mypy_cache", - ".nox", - ".pants.d", - ".pyenv", - ".pytest_cache", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "site-packages", - "venv", -] - -line-length = 88 -indent-width = 4 - -target-version = "py310" - -[tool.ruff.lint] -extend-select = [ - #"B", # flake8-bugbear - #"C4", # flake8-comprehensions - #"C9", # mccabe - "I", # isort - "PGH", # pygrep-hooks - #"RUF", # ruff - "UP", # pyupgrade - "W", # pycodestyle - "YTT", # flake8-2020 - #"TRY", # tryceratops - #"EM", # flake8-errmsg -] -ignore = [] - -fixable = ["ALL"] -unfixable = [] - -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -[tool.ruff.lint.isort] -lines-between-types = 1 -lines-after-imports = 2 - -[tool.ruff.format] -quote-style = "double" -indent-style = "space" -skip-magic-trailing-comma = false -line-ending = "auto" - -[tool.pytest.ini_options] -testpaths = [ - "test", - "integration", -] - -addopts = "--cov=openfga_sdk --cov-report term-missing --cov-report xml --cov-report html" - -asyncio_mode = "strict" -asyncio_default_fixture_loop_scope = "function" - -[tool.mypy] -python_version = "3.10" -packages = "openfga_sdk" -exclude = [ - "openfa_sdk/models", -] -#warn_return_any = "True" -#warn_unused_configs = "True" -#disallow_untyped_defs = "True" diff --git a/config/clients/python/template/pyproject.toml.mustache b/config/clients/python/template/pyproject.toml.mustache new file mode 100644 index 000000000..b40e00db9 --- /dev/null +++ b/config/clients/python/template/pyproject.toml.mustache @@ -0,0 +1,145 @@ +# +# {{#packageDescription}}{{{packageDescription}}}{{/packageDescription}} +# +# {{#version}}API version: {{{version}}}{{/version}} +# {{#websiteUrl}}Website: {{{websiteUrl}}}{{/websiteUrl}} +# {{#docsUrl}}Documentation: {{{docsUrl}}}{{/docsUrl}} +# {{#supportInfo}}Support: {{{supportInfo}}}{{/supportInfo}} +# {{#licenseId}}License: [{{{licenseId}}}](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/blob/main/LICENSE){{/licenseId}} +# + +[project] +name = "{{{projectName}}}" +version = "{{packageVersion}}" +description="{{appDescription}}" +authors = [ + { name = "{{author}} ({{websiteUrl}})", email = "{{infoEmail}}"} +] +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=[ + {{#packageTags}} + "{{.}}", + {{/packageTags}} +] +requires-python=">={{pythonMinimumRuntime}}" +{{#licenseId}}license="{{.}}" +{{/licenseId}} +dependencies = [ + "aiohttp>=3.9.3", + "python-dateutil>=2.9.0", + "opentelemetry-api>=1.25.0", + "urllib3>=1.26.19,<3" +] + +[project.urls] +Repository="https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.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", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +line-length = 88 +indent-width = 4 + +target-version = "py310" + +[tool.ruff.lint] +extend-select = [ + #"B", # flake8-bugbear + #"C4", # flake8-comprehensions + #"C9", # mccabe + "I", # isort + "PGH", # pygrep-hooks + #"RUF", # ruff + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 + #"TRY", # tryceratops + #"EM", # flake8-errmsg +] +ignore = [] + +fixable = ["ALL"] +unfixable = [] + +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.lint.isort] +lines-between-types = 1 +lines-after-imports = 2 + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" + +[tool.pytest.ini_options] +testpaths = [ + "test", + "integration", +] + +addopts = "--cov=openfga_sdk --cov-report term-missing --cov-report xml --cov-report html" + +asyncio_mode = "strict" +asyncio_default_fixture_loop_scope = "function" + +[tool.mypy] +python_version = "{{pythonMinimumRuntime}}" +packages = "openfga_sdk" +exclude = [ + "openfga_sdk/models", +] +#warn_return_any = "True" +#warn_unused_configs = "True" +#disallow_untyped_defs = "True" diff --git a/config/clients/python/template/requirements.mustache b/config/clients/python/template/requirements.mustache deleted file mode 100644 index 7fb167c19..000000000 --- a/config/clients/python/template/requirements.mustache +++ /dev/null @@ -1,6 +0,0 @@ -aiohttp >= 3.9.3, < 4 -python-dateutil >= 2.9.0, < 3 -setuptools >= 69.1.1 -build >= 1.2.1, < 2 -urllib3 >= 1.26.19, < 3 -opentelemetry-api >= 1.25.0, < 2 diff --git a/config/clients/python/template/setup.mustache b/config/clients/python/template/setup.mustache deleted file mode 100644 index 7a1c2ba8c..000000000 --- a/config/clients/python/template/setup.mustache +++ /dev/null @@ -1,53 +0,0 @@ -{{>partial_header}} - -import pathlib -import pkg_resources - -from setuptools import find_packages, setup - - -NAME = "{{{projectName}}}" -VERSION = "{{packageVersion}}" -REQUIRES = [] -{{#apiInfo}}{{#apis}}{{#-last}} - -with pathlib.Path("requirements.txt").open() as requirements_txt: - REQUIRES = [ - str(requirement) - for requirement in pkg_resources.parse_requirements(requirements_txt) - ] - -this_directory = pathlib.Path(__file__).parent -long_description = (this_directory / "README.md").read_text() - -setup( - name=NAME, - version=VERSION, - description="{{appDescription}}", - author="{{author}} ({{websiteUrl}})", - author_email="{{infoEmail}}", - url="https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}", - 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=[ - {{#packageTags}} - "{{.}}", - {{/packageTags}} - ], - install_requires=REQUIRES, - python_requires=">={{pythonMinimumRuntime}}", - packages=find_packages(exclude=["test"]), - include_package_data=True, - {{#licenseId}}license="{{.}}", - {{/licenseId}}long_description_content_type="text/markdown", - long_description=long_description, -) -{{/-last}} -{{/apis}} -{{/apiInfo}} diff --git a/config/clients/python/template/test-requirements.mustache b/config/clients/python/template/test-requirements.mustache deleted file mode 100644 index 84b05fc2d..000000000 --- a/config/clients/python/template/test-requirements.mustache +++ /dev/null @@ -1,8 +0,0 @@ --r requirements.txt - -griffe >= 0.41.2, < 2 -mock >= 5.1.0, < 6 -pytest-asyncio >= 0.25, < 2 -pytest-cov >= 5, < 7 -ruff >= 0.9, < 1 -mypy >= 1.14.1, < 2