diff --git a/.releaserc.json b/.releaserc.json index d05ce0c..94e24cd 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -16,7 +16,7 @@ "@semantic-release/git", { "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", - "assets": ["CHANGELOG.md", "setup.py", "setup.cfg"] + "assets": ["CHANGELOG.md", "pyproject.toml"] } ] ] diff --git a/package.json b/package.json new file mode 100644 index 0000000..16bdf0f --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "@semantic-release/changelog": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "semantic-release": "^22.0.5", + "semantic-release-pypi": "^5.1.0" + } +} diff --git a/pyproject.toml b/pyproject.toml index 6b313bc..7e3a6f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,45 @@ +[project] +name = "casbin_async_sqlalchemy_adapter" +version = "1.12.0" +authors = [ + {name = "Casbin", email = "admin@casbin.org"} +] +description = "Asynchronous SQLAlchemy Adapter for PyCasbin" +readme = "README.md" +keywords = [ + "asynccasbin", + "SQLAlchemy", + "casbin-adapter", + "rbac", + "access control", + "abac", + "acl", + "permission" +] +dynamic = ["dependencies"] +requires-python = ">=3.7" +license = {text = "Apache-2.0"} +classifiers = [ + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent" +] + +[project.urls] +Home-page = "https://github.com/officialpycasbin/async-sqlalchemy-adapter" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +exclude = ["tests"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + [tool.black] -line-length = 150 +line-length = 150 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b4c180c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[metadata] -version = 1.12.0 - diff --git a/setup.py b/setup.py deleted file mode 100644 index 520b30d..0000000 --- a/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2023 The casbin Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from os import path - -from setuptools import setup, find_packages - -desc_file = "README.md" - -with open(desc_file, "r") as fh: - long_description = fh.read() - -here = path.abspath(path.dirname(__file__)) -# get the dependencies and installs -with open(path.join(here, "requirements.txt"), encoding="utf-8") as f: - all_reqs = f.read().split("\n") - -install_requires = [x.strip() for x in all_reqs if "git+" not in x] - -setup( - name="casbin_async_sqlalchemy_adapter", - author="Casbin", - author_email="admin@casbin.org", - description="Asynchronous SQLAlchemy Adapter for PyCasbin", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/officialpycasbin/async-sqlalchemy-adapter", - keywords=[ - "asynccasbin", - "SQLAlchemy", - "casbin-adapter", - "rbac", - "access control", - "abac", - "acl", - "permission", - ], - packages=find_packages(), - install_requires=install_requires, - python_requires=">=3.7", - license="Apache 2.0", - classifiers=[ - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], - data_files=[desc_file], -) diff --git a/tests/test_adapter.py b/tests/test_adapter.py index 316404c..72e2f09 100644 --- a/tests/test_adapter.py +++ b/tests/test_adapter.py @@ -404,25 +404,15 @@ async def test_add_policies_bulk_internal_session(self): ] await adapter.add_policies("p", "p", rules) - async_session = async_sessionmaker( - engine, expire_on_commit=False, class_=AsyncSession - ) + async_session = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession) async with async_session() as s: # count inserted rows from sqlalchemy import select, func - cnt = await s.execute( - select(func.count()) - .select_from(CasbinRule) - .where(CasbinRule.ptype == "p") - ) + cnt = await s.execute(select(func.count()).select_from(CasbinRule).where(CasbinRule.ptype == "p")) assert cnt.scalar_one() == len(rules) - rows = ( - (await s.execute(select(CasbinRule).order_by(CasbinRule.id))) - .scalars() - .all() - ) + rows = (await s.execute(select(CasbinRule).order_by(CasbinRule.id))).scalars().all() tuples = [(r.v0, r.v1, r.v2) for r in rows] for r in rules: assert r in tuples