Skip to content

Commit aa7ab64

Browse files
authored
Merge pull request #124 from AzureAD/release-1.1.0
MSAL Extensions for Python, Release 1.1.0
2 parents a88fa67 + 69f9a8c commit aa7ab64

File tree

10 files changed

+63
-35
lines changed

10 files changed

+63
-35
lines changed

.github/workflows/python-package.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515

1616
runs-on: ${{ matrix.os }}
1717
strategy:
18+
fail-fast: false
1819
matrix:
19-
python-version: [3.7, 3.8, 3.9, 2.7]
20+
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12]
2021
os: [ubuntu-latest, windows-latest, macos-latest]
2122
include:
2223
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix
@@ -26,15 +27,19 @@ jobs:
2627
toxenv: "py38"
2728
- python-version: 3.9
2829
toxenv: "py39"
29-
- python-version: 2.7
30-
toxenv: "py27"
30+
- python-version: "3.10"
31+
toxenv: "py310"
32+
- python-version: 3.11
33+
toxenv: "py311"
34+
- python-version: 3.12
35+
toxenv: "py312"
3136
- python-version: 3.9
3237
os: ubuntu-latest
3338
lint: "true"
3439
steps:
35-
- uses: actions/checkout@v2
40+
- uses: actions/checkout@v4
3641
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v2
42+
uses: actions/setup-python@v4
3843
with:
3944
python-version: ${{ matrix.python-version }}
4045
- name: Install Linux dependencies for Python 2
@@ -81,26 +86,37 @@ jobs:
8186
8287
cd:
8388
needs: ci
84-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master')
89+
# Note: github.event.pull_request.draft == false WON'T WORK in "if" statement,
90+
# because the triggered event is a push, not a pull_request.
91+
# This means each commit will trigger a release on TestPyPI.
92+
# Those releases will only succeed when each push has a new version number: a1, a2, a3, etc.
93+
if: |
94+
github.event_name == 'push' &&
95+
(
96+
startsWith(github.ref, 'refs/tags') ||
97+
startsWith(github.ref, 'refs/heads/release-')
98+
)
8599
runs-on: ubuntu-latest
86100
steps:
87-
- uses: actions/checkout@v2
101+
- uses: actions/checkout@v4
88102
- name: Set up Python 3.9
89-
uses: actions/setup-python@v2
103+
uses: actions/setup-python@v4
90104
with:
91105
python-version: 3.9
92106
- name: Build a package for release
93107
run: |
94108
python -m pip install build --user
95109
python -m build --sdist --wheel --outdir dist/ .
96-
- name: Publish to TestPyPI
110+
- name: |
111+
Publish to TestPyPI when pushing to release-* branch.
112+
You better test with a1, a2, b1, b2 releases first.
97113
uses: pypa/[email protected]
98-
if: github.ref == 'refs/heads/master'
114+
if: startsWith(github.ref, 'refs/heads/release-')
99115
with:
100116
user: __token__
101117
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
102118
repository_url: https://test.pypi.org/legacy/
103-
- name: Publish to PyPI
119+
- name: Publish to PyPI when tagged
104120
if: startsWith(github.ref, 'refs/tags')
105121
uses: pypa/[email protected]
106122
with:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TODO: Can this Dockerfile use multi-stage build?
22
# Final size 690MB. (It would be 1.16 GB if started with python:3 as base)
3-
FROM python:3-slim
3+
FROM python:3.12-slim
44

55
# Install Generic PyGObject (sans GTK)
66
#The following somehow won't work:
@@ -22,7 +22,7 @@ RUN apt-get install -y \
2222
RUN pip install "pytest>=6,<7"
2323

2424
# Install MSAL Extensions. Upgrade the pinned version number to trigger a new image build.
25-
RUN pip install "msal-extensions==0.3"
25+
RUN pip install "msal-extensions==1.1"
2626

2727
# This setup is inspired from https://github.com/jaraco/keyring#using-keyring-on-headless-linux-systems-in-a-docker-container
2828
ENTRYPOINT ["dbus-run-session", "--"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ persistence.save(json.dumps(data))
8989
assert json.loads(persistence.load()) == data
9090
```
9191

92+
## Python version support policy
93+
94+
Python versions which are 6 months older than their
95+
[end-of-life cycle defined by Python Software Foundation (PSF)](https://devguide.python.org/versions/#versions)
96+
will not receive new feature updates from this library.
97+
9298

9399
## Community Help and Support
94100

msal_extensions/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Provides auxiliary functionality to the `msal` package."""
2-
__version__ = "1.0.0"
2+
__version__ = "1.1.0"
33

44
from .persistence import (
55
FilePersistence,

msal_extensions/cache_lock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import errno
55
import time
66
import logging
7-
from distutils.version import LooseVersion
87

98
import portalocker
9+
from packaging.version import Version
1010

1111

1212
logger = logging.getLogger(__name__)
@@ -21,7 +21,7 @@ def __init__(self, lockfile_path):
2121
self._lockpath = lockfile_path
2222
# Support for passing through arguments to the open syscall was added in v1.4.0
2323
open_kwargs = ({'buffering': 0}
24-
if LooseVersion(portalocker.__version__) >= LooseVersion("1.4.0") else {})
24+
if Version(portalocker.__version__) >= Version("1.4.0") else {})
2525
self._lock = portalocker.Lock(
2626
lockfile_path,
2727
mode='wb+',

msal_extensions/persistence.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def save(self, content):
210210
except OSError as exception:
211211
raise PersistenceEncryptionError(
212212
err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows
213-
message="Encryption failed: {}. Consider disable encryption.".format(exception),
213+
message="Encryption failed: {} Consider disable encryption.".format(exception),
214214
)
215215
with os.fdopen(_open(self._location), 'wb+') as handle:
216216
handle.write(data)
@@ -237,7 +237,7 @@ def load(self):
237237
except OSError as exception:
238238
raise PersistenceDecryptionError(
239239
err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows
240-
message="Decryption failed: {}. "
240+
message="Decryption failed: {} "
241241
"App developer may consider this guidance: "
242242
"https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/PersistenceDecryptionError" # pylint: disable=line-too-long
243243
.format(exception),
@@ -342,4 +342,3 @@ def get_location(self):
342342
# with a FilePersistence to achieve
343343
# https://github.com/AzureAD/microsoft-authentication-extensions-for-python/issues/12
344344
# But this idea is not pursued at this time.
345-

msal_extensions/windows.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def raw(self):
4646
"The computer must be trusted for delegation and "
4747
"the current user account must be configured to allow delegation. "
4848
"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",
49-
13: "The data is invalid",
49+
13: "The data is invalid.",
5050
}
5151

5252
# This code is modeled from a StackOverflow question, which can be found here:
@@ -91,7 +91,7 @@ def protect(self, message):
9191
_LOCAL_FREE(result.pbData)
9292

9393
err_code = _GET_LAST_ERROR()
94-
raise OSError(None, _err_description.get(err_code), None, err_code)
94+
raise OSError(None, _err_description.get(err_code, ''), None, err_code)
9595

9696
def unprotect(self, cipher_text):
9797
# type: (bytes) -> str
@@ -120,4 +120,4 @@ def unprotect(self, cipher_text):
120120
finally:
121121
_LOCAL_FREE(result.pbData)
122122
err_code = _GET_LAST_ERROR()
123-
raise OSError(None, _err_description.get(err_code), None, err_code)
123+
raise OSError(None, _err_description.get(err_code, ''), None, err_code)

setup.cfg

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files
22

33
[bdist_wheel]
4-
universal=1
4+
universal=0
55

66
[metadata]
7-
license = MIT
7+
license = MIT License
88
project_urls = Changelog = https://github.com/AzureAD/microsoft-authentication-extensions-for-python/releases
99
classifiers =
1010
License :: OSI Approved :: MIT License
1111
Development Status :: 5 - Production/Stable
12+
Programming Language :: Python :: 3 :: Only
13+
Programming Language :: Python :: 3
14+
Programming Language :: Python :: 3.7
15+
Programming Language :: Python :: 3.8
16+
Programming Language :: Python :: 3.9
17+
Programming Language :: Python :: 3.10
18+
Programming Language :: Python :: 3.11
19+
Programming Language :: Python :: 3.12
20+
1221
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.

setup.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@
2020
long_description=long_description,
2121
long_description_content_type="text/markdown",
2222
package_data={'': ['LICENSE']},
23+
python_requires=">=3.7",
2324
install_requires=[
2425
'msal>=0.4.1,<2.0.0',
2526

26-
# In order to implement these requirements:
27-
# Lowerbound = (1.6 if playform_system == 'Windows' else 1.0)
28-
# Upperbound < (3 if python_version >= '3.5' else 2)
29-
# The following 4 lines use the `and` syntax defined here:
30-
# https://www.python.org/dev/peps/pep-0508/#grammar
31-
"portalocker<3,>=1.0;python_version>='3.5' and platform_system!='Windows'",
32-
"portalocker<2,>=1.0;python_version=='2.7' and platform_system!='Windows'",
33-
"portalocker<3,>=1.6;python_version>='3.5' and platform_system=='Windows'",
34-
"portalocker<2,>=1.6;python_version=='2.7' and platform_system=='Windows'",
27+
"portalocker<3,>=1.0;platform_system!='Windows'",
28+
"portalocker<3,>=1.6;platform_system=='Windows'",
3529

36-
"pathlib2;python_version<'3.0'",
3730
## We choose to NOT define a hard dependency on this.
3831
# "pygobject>=3,<4;platform_system=='Linux'",
32+
33+
# Packaging package uses YY.N versioning so we have no upperbound to pin.
34+
# Neither do we need lowerbound because its `Version` API existed since its first release
35+
# https://github.com/pypa/packaging/blame/14.0/packaging/version.py
36+
'packaging',
3937
],
4038
tests_require=['pytest'],
4139
)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27,py35,py36,py37,py38
2+
envlist = py27,py35,py36,py37,py38,py39,py310,py311,py312
33

44
[testenv]
55
deps = pytest

0 commit comments

Comments
 (0)