Skip to content

Build with UV and Hatchling #186

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 1 commit 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
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
pypi_release:
name: Build with Poetry and Publish to PyPI
name: Build and Publish to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -16,9 +16,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install and configure Poetry
run: pip install poetry
- name: Publish package
run: poetry build
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
version: latest
enable-cache: true
- name: Build package
run: uv build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
31 changes: 10 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
name: Test

on:
- push
- pull_request
pull_request:
push:
branches:
- main

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
do_not_skip: '["pull_request"]'
cancel_others: 'true'
concurrent_skipping: same_content
ruff:
needs: pre_job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -44,15 +34,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
run: |
pip install poetry
poetry config virtualenvs.in-project true
- name: Install dependencies
run: poetry install
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
version: latest
enable-cache: true
- name: Run pytest
run: |
poetry run pytest -vvv -ra --cov=cryptojwt --cov-report=xml
uv run pytest -vvv -ra --cov=cryptojwt --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,4 @@ tests/pyoidc
tests/pyoidc.pub
tests/xtest_usage.py

# Poetry
poetry.lock
*.lock
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
all:

test:
poetry run pytest --ruff --ruff-format --cov
uv run pytest --ruff --ruff-format --cov

reformat:
poetry run ruff check --select I --fix src tests
poetry run ruff format src tests
uv run ruff check --select I --fix src tests
uv run ruff format src tests
52 changes: 31 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,51 @@
# PEP 518: https://www.python.org/dev/peps/pep-0518/

[tool.poetry]
[project]
name = "cryptojwt"
version = "1.9.4"
dynamic = ["version"]
description = "Python implementation of JWT, JWE, JWS and JWK"
authors = ["Roland Hedberg <[email protected]>"]
authors = [
{name="Roland Hedberg", email = "[email protected]"}
]
license = "Apache-2.0"
repository = "https://github.com/IdentityPython/JWTConnect-Python-CryptoJWT"
readme = "README.md"
packages = [
{ include = "cryptojwt", from = "src" }
]
requires-python = ">=3.9,<4.0"
dependencies = [
"cryptography>=3.4.6",
"requests>=2.25.1"
]

[tool.poetry.scripts]
[project.scripts]
jwkgen = "cryptojwt.tools.keygen:main"
jwkconv = "cryptojwt.tools.keyconv:main"
jwtpeek = "cryptojwt.tools.jwtpeek:main"

[tool.poetry.dependencies]
python = "^3.9"
cryptography = ">=3.4.6"
requests = "^2.25.1"
[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "uv-dynamic-versioning"

[tool.poetry.group.dev.dependencies]
alabaster = "^0.7.12"
pytest = "^8.2.1"
pytest-cov = "^4.0.0"
responses = "^0.13.0"
sphinx = "^3.5.2"
sphinx-autobuild = "^2021.3.14"
coverage = "^7"
ruff = ">=0.9.9"
pytest-ruff = "^0.3.2"
[tool.hatch.metadata]
allow-direct-references = true

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[dependency-groups]
dev = [
"alabaster>=0.7.12",
"pytest>=8.2.1",
"pytest-cov>=4.0.0",
"responses>=0.13.0",
"sphinx>=3.5.2",
"sphinx-autobuild>=2021.3.14",
"coverage>=7",
"ruff>=0.9.9",
"pytest-ruff>=0.3.2"
]

[tool.coverage.run]
branch = true
Expand Down
7 changes: 5 additions & 2 deletions src/cryptojwt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""JSON Web Token"""

import logging
from importlib.metadata import version
from importlib.metadata import version, PackageNotFoundError

from cryptojwt.jwe.jwe import JWE
from cryptojwt.jwk import JWK
Expand All @@ -13,7 +13,10 @@
from .exception import BadSyntax
from .utils import as_unicode, b64d, b64encode_item, split_token

__version__ = version("cryptojwt")
try:
__version__ = version("cryptojwt")
except PackageNotFoundError:
__version__ = "0.0.0"

Check warning on line 19 in src/cryptojwt/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/cryptojwt/__init__.py#L18-L19

Added lines #L18 - L19 were not covered by tests

__all__ = [
"JWE",
Expand Down
Loading