Browse Source

Merge pull request #350 from chumaumenze/feature/poetry

feat: use poetry for package management
pull/352/head
Richard Nemeth 3 years ago
committed by GitHub
parent
commit
b08137c4f9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/publish.yaml
  2. 25
      CONTRIBUTING.md
  3. 15
      Pipfile
  4. 107
      Pipfile.lock
  5. 5
      dev-requirements.txt
  6. 9
      docs-requirements.txt
  7. 1433
      poetry.lock
  8. 71
      pyproject.toml
  9. 3
      requirements.txt
  10. 2
      setup.cfg
  11. 58
      setup.py
  12. 2
      src/keycloak/keycloak_admin.py
  13. 42
      tox.ini

2
.github/workflows/publish.yaml

@ -21,7 +21,7 @@ jobs:
- name: Apply the tag version
run: |
version=${{ github.ref_name }}
sed -i 's/__version__ = .*/__version__ = "'${version:1}'"/' src/keycloak/_version.py
sed -Ei '/^version = /s|= "[0-9.]+"$|= "'${version:-1}'"|' pyproject.toml
- name: Run build
run: |
tox -e build

25
CONTRIBUTING.md

@ -10,11 +10,17 @@ The development environment is mainly up to the developer. Our recommendations a
virtual environment and install the necessary requirements. Example
```sh
python -m venv venv
source venv/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
# Install and upgrade pip & poetry
python -m pip install --upgrade pip poetry
# Create virtualenv
python -m poetry env use <PATH_TO_PYTHON_VERSION>
# install package dependencies including dev dependencies
python -m poetry install
# Activate virtualenv
python -m poetry shell
```
## Running checks and tests
@ -67,9 +73,12 @@ After cloning this repository, you must install the pre-commit hook for
conventional commits (this is included in the `dev-requirements.txt`)
```sh
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install pre-commit
# Create virtualenv
python -m poetry env use <PATH_TO_PYTHON_VERSION>
# Activate virtualenv
python -m poetry shell
pre-commit install --install-hooks -t pre-commit -t pre-push -t commit-msg
```

15
Pipfile

@ -1,15 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = ">=2.20.0"
httmock = ">=1.2.5"
python-jose = ">=1.4.0"
urllib3 = ">=1.26.5"
[dev-packages]
[requires]
python_version = "3.7"

107
Pipfile.lock

@ -1,107 +0,0 @@
{
"_meta": {
"hash": {
"sha256": "8c12705e89c665da92fc69ef0d312a9ca313703c839c15d18fcc833dcb87d7f7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.7"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"certifi": {
"hashes": [
"sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
"sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"
],
"version": "==2020.12.5"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"ecdsa": {
"hashes": [
"sha256:881fa5e12bb992972d3d1b3d4dfbe149ab76a89f13da02daa5ea1ec7dea6e747",
"sha256:cfc046a2ddd425adbd1a78b3c46f0d1325c657811c0f45ecc3a0a6236c1e50ff"
],
"version": "==0.16.1"
},
"future": {
"hashes": [
"sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"
],
"version": "==0.18.2"
},
"httmock": {
"hashes": [
"sha256:4696306d1ff835c3ca865fdef2684d7e130b4120cc00126f862ba4797b1602ac"
],
"index": "pypi",
"version": "==1.2.6"
},
"idna": {
"hashes": [
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
"sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
],
"version": "==2.7"
},
"pyasn1": {
"hashes": [
"sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d",
"sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"
],
"version": "==0.4.8"
},
"python-jose": {
"hashes": [
"sha256:29701d998fe560e52f17246c3213a882a4a39da7e42c7015bcc1f7823ceaff1c",
"sha256:ed7387f0f9af2ea0ddc441d83a6eb47a5909bd0c8a72ac3250e75afec2cc1371"
],
"index": "pypi",
"version": "==3.0.1"
},
"requests": {
"hashes": [
"sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1",
"sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a"
],
"index": "pypi",
"version": "==2.19.1"
},
"rsa": {
"hashes": [
"sha256:69805d6b69f56eb05b62daea3a7dbd7aa44324ad1306445e05da8060232d00f4",
"sha256:a8774e55b59fd9fc893b0d05e9bfc6f47081f46ff5b46f39ccf24631b7be356b"
],
"index": "pypi",
"version": "==4.7"
},
"six": {
"hashes": [
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
"version": "==1.15.0"
},
"urllib3": {
"hashes": [
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
"sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
],
"version": "==1.23"
}
},
"develop": {}
}

5
dev-requirements.txt

@ -1,5 +0,0 @@
tox
pytest
pytest-cov
wheel
pre-commit

9
docs-requirements.txt

@ -1,9 +0,0 @@
mock
alabaster
commonmark
recommonmark
sphinx
sphinx-rtd-theme
readthedocs-sphinx-ext
m2r2
sphinx-autoapi

1433
poetry.lock
File diff suppressed because it is too large
View File

71
pyproject.toml

@ -1,3 +1,74 @@
[tool.poetry]
name = "python-keycloak"
version = "0.0.0"
description = "python-keycloak is a Python package providing access to the Keycloak API."
license = "MIT"
readme = "README.md"
keywords = [ "keycloak", "openid", "oidc" ]
authors = [
"Marcos Pereira <marcospereira.mpj@gmail.com>",
"Richard Nemeth <ryshoooo@gmail.com>"
]
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
"Operating System :: MacOS",
"Operating System :: Unix",
"Operating System :: Microsoft :: Windows",
"Topic :: Utilities",
]
packages = [
{ include = "keycloak", from = "src/" },
{ include = "keycloak/**/*.py", from = "src/" },
]
[tool.poetry.urls]
Documentation = "https://python-keycloak.readthedocs.io/en/latest/"
"Issue tracker" = "https://github.com/marcospereirampj/python-keycloak/issues"
[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.20.0"
python-jose = "^3.3.0"
urllib3 = "^1.26.0"
mock = {version = "^4.0.3", optional = true}
alabaster = {version = "^0.7.12", optional = true}
commonmark = {version = "^0.9.1", optional = true}
recommonmark = {version = "^0.7.1", optional = true}
Sphinx = {version = "^5.0.2", optional = true}
sphinx-rtd-theme = {version = "^1.0.0", optional = true}
readthedocs-sphinx-ext = {version = "^2.1.8", optional = true}
m2r2 = {version = "^0.3.2", optional = true}
sphinx-autoapi = {version = "^1.8.4", optional = true}
[tool.poetry.dev-dependencies]
tox = "^3.25.0"
pytest = "^7.1.2"
pytest-cov = "^3.0.0"
wheel = "^0.37.1"
pre-commit = "^2.19.0"
isort = "^5.10.1"
black = "^22.3.0"
flake8 = "^3.5.0"
[tool.poetry.extras]
docs = [
"mock",
"alabaster",
"commonmark",
"recommonmark",
"sphinx",
"sphinx-rtd-theme",
"readthedocs-sphinx-ext",
"m2r2",
"sphinx-autoapi",
]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.black]
line-length = 99

3
requirements.txt

@ -1,3 +0,0 @@
requests>=2.20.0
python-jose>=1.4.0
urllib3>=1.26.0

2
setup.cfg

@ -1,2 +0,0 @@
[metadata]
description-file = README.md

58
setup.py

@ -1,58 +0,0 @@
# -*- coding: utf-8 -*-
import re
from setuptools import find_packages, setup
with open("README.md", "r") as fh:
long_description = fh.read()
with open("requirements.txt", "r") as fh:
reqs = fh.read().split("\n")
with open("dev-requirements.txt", "r") as fh:
dev_reqs = fh.read().split("\n")
with open("docs-requirements.txt", "r") as fh:
docs_reqs = fh.read().split("\n")
VERSIONFILE = "src/keycloak/_version.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
verstr = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
setup(
name="python-keycloak",
version=verstr,
url="https://github.com/marcospereirampj/python-keycloak",
license="The MIT License",
author="Marcos Pereira, Richard Nemeth",
author_email="marcospereira.mpj@gmail.com, ryshoooo@gmail.com",
keywords="keycloak openid oidc",
description="python-keycloak is a Python package providing access to the Keycloak API.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages("src"),
package_dir={"": "src"},
install_requires=reqs,
tests_require=dev_reqs,
extras_require={"docs": docs_reqs},
python_requires=">=3.7",
project_urls={
"Documentation": "https://python-keycloak.readthedocs.io/en/latest/",
"Issue tracker": "https://github.com/marcospereirampj/python-keycloak/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
"Operating System :: MacOS",
"Operating System :: Unix",
"Operating System :: Microsoft :: Windows",
"Topic :: Utilities",
],
)

2
src/keycloak/keycloak_admin.py

@ -2904,7 +2904,7 @@ class KeycloakAdmin:
"""
params_path = {"realm-name": self.realm_name, "id": client_id}
data_raw = self.raw_get(
urls_patterns.URL_ADMIN_CLIENT_AUTHZ_CLIENT_POLICY.format(**params_path),
urls_patterns.URL_ADMIN_CLIENT_AUTHZ_CLIENT_POLICY.format(**params_path)
)
return raise_error_from_response(data_raw, KeycloakGetError, expected_codes=[200])

42
tox.ini

@ -1,48 +1,44 @@
[tox]
isolated_build = true
envlist = check, apply-check, docs, tests, build
[testenv]
install_command = pip install {opts} {packages}
deps =
poetry>=1.1.13
commands_pre =
bash -c "python -m pip install -r <(poetry export --dev --extras=docs --without-hashes --no-interaction)"
whitelist_externals =
bash
[testenv:check]
deps =
black
isort
flake8
commands =
black --check --diff src/keycloak tests docs setup.py
isort -c --df src/keycloak tests docs setup.py
flake8 src/keycloak tests docs setup.py
black --check --diff src/keycloak tests docs
isort -c --df src/keycloak tests docs
flake8 src/keycloak tests docs
[testenv:apply-check]
deps =
black
isort
flake8
commands =
black -C src/keycloak tests docs setup.py
black src/keycloak tests docs setup.py
isort src/keycloak tests docs setup.py
black -C src/keycloak tests docs
black src/keycloak tests docs
isort src/keycloak tests docs
[testenv:docs]
deps =
.[docs]
commands =
python -m sphinx -T -E -W -b html -d _build/doctrees -D language=en ./docs/source _build/html
sphinx-build -T -E -W -b html -d _build/doctrees -D language=en ./docs/source _build/html
[testenv:tests]
setenv = file|tox.env
deps =
-rrequirements.txt
-rdev-requirements.txt
commands =
./test_keycloak_init.sh "pytest -vv --cov=keycloak --cov-report term-missing {posargs}"
[testenv:build]
deps =
-rdev-requirements.txt
commands_pre =
setenv =
POETRY_VIRTUALENVS_CREATE = false
commands =
python setup.py sdist bdist_wheel
poetry build --format sdist
poetry build --format wheel
[flake8]
max-line-length = 99
Loading…
Cancel
Save