Skip to content

Commit

Permalink
Switch to pyproject.toml (#35)
Browse files Browse the repository at this point in the history
* Move tests into tests/ directory
* gitignore
* Have the tests build a wheel as an artifact
* Switch to pyproject.toml and upgrade .github workflows

Closes #34
  • Loading branch information
simonw authored Nov 15, 2024
1 parent 1cd572a commit eeb7c48
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 49 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,56 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install '.[test]'
- name: Run tests
run: |
pytest
deploy:
python -m pytest
build:
runs-on: ubuntu-latest
needs: [test]
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install setuptools wheel build
- name: Build
run: |
python -m build
- name: Publish
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
environment: release
permissions:
id-token: write
steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-packages
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

15 changes: 12 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: |
pip install '.[test]'
Expand All @@ -30,4 +30,13 @@ jobs:
if: always()
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Build package to upload as artifact
run: |
pip install setuptools wheel build
python -m build
- name: Store the distribution packages
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: python-packages
path: dist/
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.venv
__pycache__/
*.py[cod]
*$py.class
venv
.eggs
.pytest_cache
*.egg-info
.DS_Store
dist
build
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[project]
name = "asgi-csrf"
version = "0.1"
description = "ASGI middleware for protecting against CSRF attacks"
readme = "README.md"
requires-python = ">=3.9"
authors = [{name = "Simon Willison"}]
license = {text = "Apache-2.0"}
classifiers = [
"License :: OSI Approved :: Apache Software License"
]
dependencies = [
"itsdangerous",
"python-multipart"
]

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project.urls]
Homepage = "https://github.com/simonw/asgi-csrf"
Changelog = "https://github.com/simonw/asgi-csrf/releases"
Issues = "https://github.com/simonw/asgi-csrf/issues"
CI = "https://github.com/simonw/asgi-csrf/actions"


[project.optional-dependencies]
test = [
"pytest",
"pytest-asyncio",
"httpx>=0.16",
"starlette",
"pytest-cov",
"asgi-lifespan",
]
36 changes: 0 additions & 36 deletions setup.py

This file was deleted.

File renamed without changes.

0 comments on commit eeb7c48

Please sign in to comment.