From 2aed3bc0f921cb7e5ed388fa58c76a7b9eb7bf2f Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Wed, 20 Apr 2022 22:35:11 +0800 Subject: [PATCH 1/5] refine --- msal_extensions/persistence.py | 5 ++--- msal_extensions/windows.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/msal_extensions/persistence.py b/msal_extensions/persistence.py index 0740743..8056c30 100644 --- a/msal_extensions/persistence.py +++ b/msal_extensions/persistence.py @@ -210,7 +210,7 @@ def save(self, content): except OSError as exception: raise PersistenceEncryptionError( err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows - message="Encryption failed: {}. Consider disable encryption.".format(exception), + message="Encryption failed: {} Consider disable encryption.".format(exception), ) with os.fdopen(_open(self._location), 'wb+') as handle: handle.write(data) @@ -237,7 +237,7 @@ def load(self): except OSError as exception: raise PersistenceDecryptionError( err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows - message="Decryption failed: {}. " + message="Decryption failed: {} " "App developer may consider this guidance: " "https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/PersistenceDecryptionError" # pylint: disable=line-too-long .format(exception), @@ -342,4 +342,3 @@ def get_location(self): # with a FilePersistence to achieve # https://github.com/AzureAD/microsoft-authentication-extensions-for-python/issues/12 # But this idea is not pursued at this time. - diff --git a/msal_extensions/windows.py b/msal_extensions/windows.py index 03f2022..2d32a0a 100644 --- a/msal_extensions/windows.py +++ b/msal_extensions/windows.py @@ -46,7 +46,7 @@ def raw(self): "The computer must be trusted for delegation and " "the current user account must be configured to allow delegation. " "See also https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/enable-computer-and-user-accounts-to-be-trusted-for-delegation", - 13: "The data is invalid", + 13: "The data is invalid.", } # This code is modeled from a StackOverflow question, which can be found here: @@ -91,7 +91,7 @@ def protect(self, message): _LOCAL_FREE(result.pbData) err_code = _GET_LAST_ERROR() - raise OSError(None, _err_description.get(err_code), None, err_code) + raise OSError(None, _err_description.get(err_code, ''), None, err_code) def unprotect(self, cipher_text): # type: (bytes) -> str @@ -120,4 +120,4 @@ def unprotect(self, cipher_text): finally: _LOCAL_FREE(result.pbData) err_code = _GET_LAST_ERROR() - raise OSError(None, _err_description.get(err_code), None, err_code) + raise OSError(None, _err_description.get(err_code, ''), None, err_code) From d7f7623e3f90824896d397d6882b31fe351a975a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Tue, 14 Nov 2023 02:12:07 -0600 Subject: [PATCH 2/5] Remove use of distutils (#120) * Remove use of distutils * Use `fail-fast: false` * Explaining the lack of packaging versioning pin --------- Co-authored-by: Ray Luo --- .github/workflows/python-package.yml | 1 + msal_extensions/cache_lock.py | 4 ++-- setup.py | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7570e26..5cba06b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,6 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: python-version: [3.7, 3.8, 3.9, 2.7] os: [ubuntu-latest, windows-latest, macos-latest] diff --git a/msal_extensions/cache_lock.py b/msal_extensions/cache_lock.py index ebb2601..c6f95e2 100644 --- a/msal_extensions/cache_lock.py +++ b/msal_extensions/cache_lock.py @@ -4,9 +4,9 @@ import errno import time import logging -from distutils.version import LooseVersion import portalocker +from packaging.version import Version logger = logging.getLogger(__name__) @@ -21,7 +21,7 @@ def __init__(self, lockfile_path): self._lockpath = lockfile_path # Support for passing through arguments to the open syscall was added in v1.4.0 open_kwargs = ({'buffering': 0} - if LooseVersion(portalocker.__version__) >= LooseVersion("1.4.0") else {}) + if Version(portalocker.__version__) >= Version("1.4.0") else {}) self._lock = portalocker.Lock( lockfile_path, mode='wb+', diff --git a/setup.py b/setup.py index 1500a37..48966ac 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,11 @@ "pathlib2;python_version<'3.0'", ## We choose to NOT define a hard dependency on this. # "pygobject>=3,<4;platform_system=='Linux'", + + # Packaging package uses YY.N versioning so we have no upperbound to pin. + # Neither do we need lowerbound because its `Version` API existed since its first release + # https://github.com/pypa/packaging/blame/14.0/packaging/version.py + 'packaging', ], tests_require=['pytest'], ) From 144a139814323eb5e53ee5ef2ef4ad5323ef88f9 Mon Sep 17 00:00:00 2001 From: Ray Luo Date: Mon, 20 Nov 2023 11:23:45 -0800 Subject: [PATCH 3/5] Dropping Python 2.7 --- .github/workflows/python-package.yml | 4 +--- README.md | 6 ++++++ setup.cfg | 7 ++++++- setup.py | 13 +++---------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5cba06b..a0fe57f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9, 2.7] + python-version: [3.7, 3.8, 3.9] os: [ubuntu-latest, windows-latest, macos-latest] include: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix @@ -27,8 +27,6 @@ jobs: toxenv: "py38" - python-version: 3.9 toxenv: "py39" - - python-version: 2.7 - toxenv: "py27" - python-version: 3.9 os: ubuntu-latest lint: "true" diff --git a/README.md b/README.md index ca22652..86d86e2 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ persistence.save(json.dumps(data)) assert json.loads(persistence.load()) == data ``` +## Python version support policy + +Python versions which are 6 months older than their +[end-of-life cycle defined by Python Software Foundation (PSF)](https://devguide.python.org/versions/#versions) +will not receive new feature updates from this library. + ## Community Help and Support diff --git a/setup.cfg b/setup.cfg index ea368cd..9f98dc7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ # https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files [bdist_wheel] -universal=1 +universal=0 [metadata] license = MIT @@ -9,4 +9,9 @@ project_urls = Changelog = https://github.com/AzureAD/microsoft-authenticatio classifiers = License :: OSI Approved :: MIT License Development Status :: 5 - Production/Stable + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 description = Microsoft Authentication Library extensions (MSAL EX) provides a persistence API that can save your data on disk, encrypted on Windows, macOS and Linux. Concurrent data access will be coordinated by a file lock mechanism. diff --git a/setup.py b/setup.py index 48966ac..a873d88 100644 --- a/setup.py +++ b/setup.py @@ -20,20 +20,13 @@ long_description=long_description, long_description_content_type="text/markdown", package_data={'': ['LICENSE']}, + python_requires=">=3.7", install_requires=[ 'msal>=0.4.1,<2.0.0', - # In order to implement these requirements: - # Lowerbound = (1.6 if playform_system == 'Windows' else 1.0) - # Upperbound < (3 if python_version >= '3.5' else 2) - # The following 4 lines use the `and` syntax defined here: - # https://www.python.org/dev/peps/pep-0508/#grammar - "portalocker<3,>=1.0;python_version>='3.5' and platform_system!='Windows'", - "portalocker<2,>=1.0;python_version=='2.7' and platform_system!='Windows'", - "portalocker<3,>=1.6;python_version>='3.5' and platform_system=='Windows'", - "portalocker<2,>=1.6;python_version=='2.7' and platform_system=='Windows'", + "portalocker<3,>=1.0;platform_system!='Windows'", + "portalocker<3,>=1.6;platform_system=='Windows'", - "pathlib2;python_version<'3.0'", ## We choose to NOT define a hard dependency on this. # "pygobject>=3,<4;platform_system=='Linux'", From b15f292a8a0d85dc3406af240efbfc0961decb4a Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Wed, 6 Dec 2023 19:34:42 +1100 Subject: [PATCH 4/5] Update trove classifiers and build matrix for Python 3.10 (#115) * Update trove classifiers and build matrix * Test matrix covers Python 3.11 & 3.12 too * Update tox.ini --------- Co-authored-by: Ray Luo Co-authored-by: Ray Luo --- .github/workflows/python-package.yml | 16 +++++++++++----- setup.cfg | 6 +++++- tox.ini | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a0fe57f..8813e68 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12] os: [ubuntu-latest, windows-latest, macos-latest] include: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix @@ -27,13 +27,19 @@ jobs: toxenv: "py38" - python-version: 3.9 toxenv: "py39" + - python-version: "3.10" + toxenv: "py310" + - python-version: 3.11 + toxenv: "py311" + - python-version: 3.12 + toxenv: "py312" - python-version: 3.9 os: ubuntu-latest lint: "true" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install Linux dependencies for Python 2 @@ -83,9 +89,9 @@ jobs: if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.9 - name: Build a package for release diff --git a/setup.cfg b/setup.cfg index 9f98dc7..14e7aba 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,7 @@ universal=0 [metadata] -license = MIT +license = MIT License project_urls = Changelog = https://github.com/AzureAD/microsoft-authentication-extensions-for-python/releases classifiers = License :: OSI Approved :: MIT License @@ -14,4 +14,8 @@ classifiers = Programming Language :: Python :: 3.7 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 + description = Microsoft Authentication Library extensions (MSAL EX) provides a persistence API that can save your data on disk, encrypted on Windows, macOS and Linux. Concurrent data access will be coordinated by a file lock mechanism. diff --git a/tox.ini b/tox.ini index 8a538bc..29a2606 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py35,py36,py37,py38 +envlist = py27,py35,py36,py37,py38,py39,py310,py311,py312 [testenv] deps = pytest From 69f9a8c7cab013503e2c55be54cb5aa6344930f2 Mon Sep 17 00:00:00 2001 From: Ray Luo Date: Wed, 22 Nov 2023 18:07:17 -0800 Subject: [PATCH 5/5] Preparing MSAL Python EX 1.1.0 --- .github/workflows/python-package.yml | 19 +++++++++++++++---- Dockerfile | 4 ++-- msal_extensions/__init__.py | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 8813e68..2d7b92f 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -86,7 +86,16 @@ jobs: cd: needs: ci - if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') + # Note: github.event.pull_request.draft == false WON'T WORK in "if" statement, + # because the triggered event is a push, not a pull_request. + # This means each commit will trigger a release on TestPyPI. + # Those releases will only succeed when each push has a new version number: a1, a2, a3, etc. + if: | + github.event_name == 'push' && + ( + startsWith(github.ref, 'refs/tags') || + startsWith(github.ref, 'refs/heads/release-') + ) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -98,14 +107,16 @@ jobs: run: | python -m pip install build --user python -m build --sdist --wheel --outdir dist/ . - - name: Publish to TestPyPI + - name: | + Publish to TestPyPI when pushing to release-* branch. + You better test with a1, a2, b1, b2 releases first. uses: pypa/gh-action-pypi-publish@v1.4.2 - if: github.ref == 'refs/heads/master' + if: startsWith(github.ref, 'refs/heads/release-') with: user: __token__ password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - - name: Publish to PyPI + - name: Publish to PyPI when tagged if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@v1.4.2 with: diff --git a/Dockerfile b/Dockerfile index a56a2ea..8b506dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # TODO: Can this Dockerfile use multi-stage build? # Final size 690MB. (It would be 1.16 GB if started with python:3 as base) -FROM python:3-slim +FROM python:3.12-slim # Install Generic PyGObject (sans GTK) #The following somehow won't work: @@ -22,7 +22,7 @@ RUN apt-get install -y \ RUN pip install "pytest>=6,<7" # Install MSAL Extensions. Upgrade the pinned version number to trigger a new image build. -RUN pip install "msal-extensions==0.3" +RUN pip install "msal-extensions==1.1" # This setup is inspired from https://github.com/jaraco/keyring#using-keyring-on-headless-linux-systems-in-a-docker-container ENTRYPOINT ["dbus-run-session", "--"] diff --git a/msal_extensions/__init__.py b/msal_extensions/__init__.py index adfb0e0..31b07c1 100644 --- a/msal_extensions/__init__.py +++ b/msal_extensions/__init__.py @@ -1,5 +1,5 @@ """Provides auxiliary functionality to the `msal` package.""" -__version__ = "1.0.0" +__version__ = "1.1.0" from .persistence import ( FilePersistence,