diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..12a376a --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,36 @@ +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + release: + types: + - published + +permissions: + contents: read + +jobs: + deploy_pypi: + name: Build and publish Python 🐍 distributions 📦 to PyPI + environment: production + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: "0" + - name: Set up Python3 + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 + with: + python-version: "3.x" + - name: Install Flit + run: | + python -m pip install flit + - name: Build a binary wheel and a source tarball + run: | + python -m flit build + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 8ef0a8c..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release -on: - - pull_request - - push - - release - - workflow_dispatch - -jobs: - deploy_pypi: - if: ${{ success() && (contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: "0" - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - name: Build Distribution Package - run: python setup.py sdist && python setup.py bdist_wheel - - name: Push Package to PyPi - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index 3ef2a69..85274c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ +.idea *.pyc *.swp -env/ build/ dist/ +env/ requests_magpie.egg-info/ -.idea diff --git a/AUTHORS b/AUTHORS index d992fd6..4cb38e3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1,3 @@ David Caron +Francis Charette-Migneault +Trevor James Smith diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..2553b91 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,21 @@ +Changelog +========= + +0.3.0 +----- + +- Dropped support for Python 3.6 and 3.7. +- Now using the `flit` backend for library packaging. +- Now using Trusted Publisher workflow for PyPI releases and Dependabot for dependency updates. +- Licensing notices have been updated to reflect the current year and maintainers. + +0.2.0 +----- + +- Add parameter to provide extra request keyword arguments as needed for performing the authentication request. +- Add parameter to cache result from authentication request to avoid performing the opeartion each time. + +0.1.1 +----- + +- Initial Release diff --git a/HISTORY.rst b/HISTORY.rst deleted file mode 100644 index 6c0487f..0000000 --- a/HISTORY.rst +++ /dev/null @@ -1,13 +0,0 @@ -History -======= - -0.2.0 ------ - -- Add parameter to provide extra request keyword arguments as needed for performing the authentication request. -- Add parameter to cache result from authentication request to avoid performing the opeartion each time. - -0.1.1 ------ - -- Initial Release diff --git a/LICENSE b/LICENSE index 0e2192e..cfb616d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ ISC License -Copyright (c) 2019 David Caron +Copyright (c) 2019-2024, David Caron, Francis Charette-Migneault, Trevor James Smith Permission to use, copy, modify and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c5c480f..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include requirements.txt -include README.rst -include LICENSE -include HISTORY.rst -include AUTHORS diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ae72509 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ +[build-system] +requires = ["flit>=3.9,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "requests-magpie" +description = "A Magpie authentication handler for python-requests" +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { file = "LICENSE" } +authors = [ + { name = "David Caron" } +] +maintainers = [ + { name = "Trevor James Smith", email = "smith.trevorj@ouranos.ca" }, + { name = "Francis Charette-Migneault", email = "francis.charette-migneault@crim.ca" } +] +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: ISC License (ISCL)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dynamic = ["version"] +dependencies = [ + "requests >=2.32.2" +] + +[project.optional-dependencies] +dev = ["pytest"] + +[project.urls] +"Homepage" = "https://github.com/Ouranosinc/requests-magpie" +"Issue tracker" = "https://github.com/Ouranosinc/requests-magpie/issues" +"About Ouranos" = "https://www.ouranos.ca/en/" + +[tool.flit.sdist] +include = [ + "AUTHORS", + "CHANGELOG", + "LICENSE", + "README.rst", + "tests/*.py", +] +exclude = [ + ".*", +] \ No newline at end of file diff --git a/requests_magpie.py b/requests_magpie.py index 4e83a88..969d2e4 100644 --- a/requests_magpie.py +++ b/requests_magpie.py @@ -1,6 +1,6 @@ # ISC License # -# Copyright (c) 2019 David Caron +# Copyright (c) 2019-2024, David Caron, Francis Charette-Migneault, Trevor James Smith # # Permission to use, copy, modify and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -17,8 +17,8 @@ requests Magpie authentication library ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Requests is an HTTP library, written in Python, for human beings. This library -adds optional Magpie authentication support. Basic GET usage: +Requests is an HTTP library, written in Python, for human beings. +This library adds optional Magpie authentication support. Basic GET usage: >>> import requests >>> from requests_magpie import MagpieAuth @@ -34,7 +34,7 @@ from requests.cookies import merge_cookies from requests.exceptions import RequestException -__version__ = '0.2.0' +__version__ = '0.3.0' class MagpieAuthenticationError(RequestException): diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 5a9091f..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest>=4.0.0 -zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 98d8768..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests>=2.32.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 94956cb..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[wheel] -universal = 0 diff --git a/setup.py b/setup.py deleted file mode 100644 index af92624..0000000 --- a/setup.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 -import os -import re -from setuptools import setup - -path = os.path.dirname(__file__) -desc_fd = os.path.join(path, 'README.rst') -hist_fd = os.path.join(path, 'HISTORY.rst') - -long_desc = '' -short_desc = 'A Magpie authentication handler for python-requests' - -if os.path.isfile(desc_fd): - with open(desc_fd) as fd: - long_desc = fd.read() - -if os.path.isfile(hist_fd): - with open(hist_fd) as fd: - long_desc = '\n\n'.join([long_desc, fd.read()]) - - -def get_version(): - """ - Simple function to extract the current version using regular expressions. - """ - reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]') - with open('requests_magpie.py') as fd: - matches = list(filter(lambda x: x, map(reg.match, fd))) - - if not matches: - raise RuntimeError( - 'Could not find the version information for requests_magpie' - ) - - return matches[0].group(1) - - -setup( - name='requests-magpie', - description=short_desc, - long_description=long_desc, - author='David Caron', - author_email='david.caron@crim.ca', - url='https://github.com/ouranosinc/requests-magpie', - py_modules=['requests_magpie'], - license='ISC', - version=get_version(), - install_requires=[ - 'requests>=1.1.0', - ], - extras_require={ - }, - tests_require=['mock'], - classifiers=[ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: ISC License (ISCL)", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Topic :: Software Development :: Libraries :: Python Modules", - ], -) diff --git a/tests/__init__.py b/tests/conftest.py similarity index 100% rename from tests/__init__.py rename to tests/conftest.py