diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index fd2d1c3..7dde101 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -7,20 +7,20 @@ on: jobs: deploy: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + - uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index e0dd502..1c7bc8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +__pycache__/ *.swp .DS_Store /env diff --git a/log_request_id/__init__.py b/log_request_id/__init__.py index d4c315b..0df983e 100644 --- a/log_request_id/__init__.py +++ b/log_request_id/__init__.py @@ -1,8 +1,5 @@ import threading -__version__ = "2.1.0" - - try: from asgiref.local import Local except ImportError: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d028bf9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.build_meta" + +[project] +name = "django-log-request-id" +version = "2.1.1" +description = "Django middleware and log filter to attach a unique ID to every log message generated as part of a request" +readme = "README.md" +license = "BSD-3-Clause" +license-files = ["LICENSE"] +authors = [ + { name = "DabApps", email = "hello@dabapps.com" }, +] +requires-python = ">=3.10" +dependencies = [ + "django>=1.8", +] + +[project.urls] +Homepage = "https://github.com/dabapps/django-log-request-id/" +Repository = "https://github.com/dabapps/django-log-request-id/" + +[tool.setuptools.packages.find] +include = ["log_request_id*"] diff --git a/setup.py b/setup.py deleted file mode 100755 index 4b1b89f..0000000 --- a/setup.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import print_function - -from setuptools import setup -import re -import os -import sys -import codecs - - - -name = 'django-log-request-id' -package = 'log_request_id' -description = 'Django middleware and log filter to attach a unique ID to every log message generated as part of a request' -url = 'https://github.com/dabapps/django-log-request-id/' -author = 'DabApps' -author_email = 'hello@dabapps.com' -license = 'BSD' -install_requires = ["django>=1.8"] - -with codecs.open('README.md', encoding='utf-8') as f: - readme = f.read() - - -def get_version(package): - """ - Return package version as listed in `__version__` in `init.py`. - """ - init_py = open(os.path.join(package, '__init__.py')).read() - return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group(1) - - -def get_packages(package): - """ - Return root package and all sub-packages. - """ - return [dirpath - for dirpath, dirnames, filenames in os.walk(package) - if os.path.exists(os.path.join(dirpath, '__init__.py'))] - - -def get_package_data(package): - """ - Return all files under the root package, that are not in a - package themselves. - """ - walk = [(dirpath.replace(package + os.sep, '', 1), filenames) - for dirpath, dirnames, filenames in os.walk(package) - if not os.path.exists(os.path.join(dirpath, '__init__.py'))] - - filepaths = [] - for base, filenames in walk: - filepaths.extend([os.path.join(base, filename) - for filename in filenames]) - return {package: filepaths} - - -setup( - name=name, - version=get_version(package), - url=url, - license=license, - description=description, - long_description=readme, - long_description_content_type='text/markdown', - author=author, - author_email=author_email, - packages=get_packages(package), - package_data=get_package_data(package), - install_requires=install_requires -)