From eec492057ac4a07bdda8485fcb70617ecdb38bc7 Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Tue, 8 Oct 2024 08:39:38 -0500 Subject: [PATCH 01/10] Add support for Python 3.13 * Drop support for Python 3.8 Close #218 Close #225 Close #233 Close #234 --- .github/workflows/cicd.yml | 6 +++--- CONTRIBUTING.md | 2 +- Makefile | 16 ++++++++-------- docs/readme/header.rst | 4 ++-- pyproject.toml | 4 ++-- tox.ini | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index dddf3830..f2dd87b5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -68,7 +68,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - 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@v3 @@ -192,7 +192,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - 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@v3 @@ -260,7 +260,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - 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@v3 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 245581e0..869e0278 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ Submit a [GitHub Issue](https://github.com/techservicesillinois/awscli-login/iss ### Prerequisites -- Python 3.8 or higher +- Python 3.9 or higher - [GNU Make](https://www.gnu.org/software/make/) ### Installation diff --git a/Makefile b/Makefile index e34d9ffc..c4ed6adb 100644 --- a/Makefile +++ b/Makefile @@ -83,20 +83,20 @@ tox: .python-version $(RELEASE) | cache tox --installpkg dist/$(WHEEL) .python-version: - pyenv install -s 3.8.16 - pyenv install -s 3.9.16 - pyenv install -s 3.10.9 - pyenv install -s 3.11.1 - pyenv install -s 3.12.0 - pyenv local 3.8.16 3.9.16 3.10.9 3.11.1 3.12.0 + pyenv install -s 3.9.20 + pyenv install -s 3.10.15 + pyenv install -s 3.11.10 + pyenv install -s 3.12.7 + pyenv install -s 3.13.0rc3 + pyenv local 3.9.20 3.10.15 3.11.10 3.12.7 3.13.0rc3 # Run tests on multiple versions of Python (Windows only) win-tox: .win-tox $(RELEASE) | cache tox --installpkg dist/$(WHEEL) .win-tox: - pyenv install 3.8.7 3.9.1 - python scripts/windows_bat.py 3.8.7 3.9.1 + pyenv install 3.9.1 + python scripts/windows_bat.py 3.9.1 touch $@ # Run tests against wheel installed in virtualenv diff --git a/docs/readme/header.rst b/docs/readme/header.rst index 3ed55149..87f73b0d 100644 --- a/docs/readme/header.rst +++ b/docs/readme/header.rst @@ -4,9 +4,9 @@ application is fully supported under Linux, macOS, and Windows. This product is supported by the Cybersecurity Development team at the University of Illinois, on a best-effort basis. The expected End-of-Life -and End-of-Support date of this version is October 2028, the same as +and End-of-Support date of this version is October 2029, the same as its primary dependencies: the AWS CLI and -`Python V3.12 `_. +`Python V3.13 `_. .. |--| unicode:: U+2013 .. en dash .. contents:: Jump to: diff --git a/pyproject.toml b/pyproject.toml index d90110fb..ed6b903c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,13 +25,13 @@ classifiers = [ 'Intended Audience :: System Administrators', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', - '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', + 'Programming Language :: Python :: 3.13', ] -requires-python = ">=3.8" +requires-python = ">=3.9" [project.urls] Homepage = "https://github.com/techservicesillinois/awscli-login" diff --git a/tox.ini b/tox.ini index e2bb7dd0..a020bc59 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38,py39,py310,py311,py312 +envlist = py39,py310,py311,py312,py313 [testenv] # getpass.getuser fails on Windows if these envs are not passed in From 092c38ec04f63e0d13549e6b403866b421ef57ad Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Fri, 7 Feb 2025 11:01:49 -0600 Subject: [PATCH 02/10] Fix secure_touch on Windows Python 3.13 secure_touch should be a noop on Windows. Closes #234 --- src/awscli_login/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/awscli_login/util.py b/src/awscli_login/util.py index 6fcbf02d..ebd9afb4 100644 --- a/src/awscli_login/util.py +++ b/src/awscli_login/util.py @@ -134,7 +134,9 @@ def secure_touch(path): path - A path to a file. """ fd = os.open(path, os.O_CREAT | os.O_RDONLY, mode=0o600) - if hasattr(os, "fchmod"): + # Python 3.13 on Windows supports fchmod. It is kind of broken + # and not useful here (See issue #234). + if hasattr(os, "fchmod") and os.name == 'posix': os.fchmod(fd, 0o600) os.close(fd) From f3f09cdb61baa91807b9ffc2d3a17913c274930c Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Fri, 7 Feb 2025 14:45:16 -0600 Subject: [PATCH 03/10] Fix which on Python 3.12 and up Close #233 --- src/awscli_login/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/awscli_login/util.py b/src/awscli_login/util.py index ebd9afb4..64bf24b0 100644 --- a/src/awscli_login/util.py +++ b/src/awscli_login/util.py @@ -297,7 +297,12 @@ def raise_if_credential_process_not_set( args = proc.split() cmd = args[0] - if not (which(cmd) and cmd.endswith("aws-login")): + # On Windows Python 3.12 and 3.13, which() returns None if + # cmd is not in the system path even if it is a full path to + # an executable file. Adding an additional os.access check + # resolves the issue (See issue #234). + if not ((which(cmd) or os.access(cmd, os.F_OK | os.X_OK)) and + cmd.endswith("aws-login")): raise CredentialProcessMisconfigured(profile) try: if not (args[args.index("--profile") + 1] == profile): From 95b69fea3aa524310fe756eba54af57a19939a08 Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Fri, 7 Feb 2025 10:10:08 -0600 Subject: [PATCH 04/10] DEBUG WIN PY313 --- .github/workflows/cicd.yml | 12 ++++++------ src/integration_tests/tests/login.bats | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index f2dd87b5..3e3d5f90 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -67,8 +67,8 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9","3.10","3.11","3.12","3.13"] + os: [windows-latest] + python-version: ["3.13"] steps: - uses: actions/checkout@v3 @@ -191,8 +191,8 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9","3.10","3.11","3.12","3.13"] + os: [windows-latest] + python-version: ["3.13"] steps: - uses: actions/checkout@v3 @@ -259,8 +259,8 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9","3.10","3.11","3.12","3.13"] + os: [windows-latest] + python-version: ["3.13"] steps: - uses: actions/checkout@v3 diff --git a/src/integration_tests/tests/login.bats b/src/integration_tests/tests/login.bats index 57502858..021316ba 100644 --- a/src/integration_tests/tests/login.bats +++ b/src/integration_tests/tests/login.bats @@ -24,7 +24,7 @@ load 'common' EOF assert_equal "$(<$AWS_SHARED_CREDENTIALS_FILE)" "$CREDS_AWS_FILE" - run aws login --load-http-traffic cassettes/login.yaml --password foo <<< 0 + run aws login --verbose --verbose --verbose --load-http-traffic cassettes/login.yaml --password foo <<< 0 assert_success assert_output <<- EOF Please choose the role you would like to assume:$CR From 8bbb18b92c99fa3748ae09daea36675b04cd3d7c Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Fri, 7 Feb 2025 15:19:43 -0600 Subject: [PATCH 05/10] Revert "DEBUG WIN PY313" This reverts commit 5d446b9e344b8df742b8b7d0a5acc298f8597f2a. --- .github/workflows/cicd.yml | 12 ++++++------ src/integration_tests/tests/login.bats | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 3e3d5f90..f2dd87b5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -67,8 +67,8 @@ jobs: strategy: matrix: - os: [windows-latest] - python-version: ["3.13"] + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9","3.10","3.11","3.12","3.13"] steps: - uses: actions/checkout@v3 @@ -191,8 +191,8 @@ jobs: strategy: matrix: - os: [windows-latest] - python-version: ["3.13"] + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9","3.10","3.11","3.12","3.13"] steps: - uses: actions/checkout@v3 @@ -259,8 +259,8 @@ jobs: strategy: matrix: - os: [windows-latest] - python-version: ["3.13"] + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.9","3.10","3.11","3.12","3.13"] steps: - uses: actions/checkout@v3 diff --git a/src/integration_tests/tests/login.bats b/src/integration_tests/tests/login.bats index 021316ba..57502858 100644 --- a/src/integration_tests/tests/login.bats +++ b/src/integration_tests/tests/login.bats @@ -24,7 +24,7 @@ load 'common' EOF assert_equal "$(<$AWS_SHARED_CREDENTIALS_FILE)" "$CREDS_AWS_FILE" - run aws login --verbose --verbose --verbose --load-http-traffic cassettes/login.yaml --password foo <<< 0 + run aws login --load-http-traffic cassettes/login.yaml --password foo <<< 0 assert_success assert_output <<- EOF Please choose the role you would like to assume:$CR From ce12cbe383a05a7753113a9360c8f79e941c960c Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Tue, 11 Feb 2025 11:44:50 -0600 Subject: [PATCH 06/10] FIXUP --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c4ed6adb..6bcd5d9e 100644 --- a/Makefile +++ b/Makefile @@ -83,12 +83,12 @@ tox: .python-version $(RELEASE) | cache tox --installpkg dist/$(WHEEL) .python-version: - pyenv install -s 3.9.20 - pyenv install -s 3.10.15 - pyenv install -s 3.11.10 - pyenv install -s 3.12.7 - pyenv install -s 3.13.0rc3 - pyenv local 3.9.20 3.10.15 3.11.10 3.12.7 3.13.0rc3 + pyenv install -s 3.9.21 + pyenv install -s 3.10.16 + pyenv install -s 3.11.11 + pyenv install -s 3.12.9 + pyenv install -s 3.13.2 + pyenv local 3.9.21 3.10.16 3.11.11 3.12.9 3.13.2 # Run tests on multiple versions of Python (Windows only) win-tox: .win-tox $(RELEASE) | cache From acc70c91147f2dc634624a4cecf65bc611c1c536 Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Tue, 11 Feb 2025 13:25:32 -0600 Subject: [PATCH 07/10] FIXUP --- src/awscli_login/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/awscli_login/util.py b/src/awscli_login/util.py index 64bf24b0..9454d6f8 100644 --- a/src/awscli_login/util.py +++ b/src/awscli_login/util.py @@ -300,7 +300,7 @@ def raise_if_credential_process_not_set( # On Windows Python 3.12 and 3.13, which() returns None if # cmd is not in the system path even if it is a full path to # an executable file. Adding an additional os.access check - # resolves the issue (See issue #234). + # resolves the issue (See issue #233). if not ((which(cmd) or os.access(cmd, os.F_OK | os.X_OK)) and cmd.endswith("aws-login")): raise CredentialProcessMisconfigured(profile) From 9c3dec09d59ebd2262ec841085c8cb3180ad51fe Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Thu, 13 Feb 2025 12:00:35 -0600 Subject: [PATCH 08/10] Revert "Fix which on Python 3.12 and up" This reverts commit f3f09cdb61baa91807b9ffc2d3a17913c274930c. --- src/awscli_login/util.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/awscli_login/util.py b/src/awscli_login/util.py index 9454d6f8..ebd9afb4 100644 --- a/src/awscli_login/util.py +++ b/src/awscli_login/util.py @@ -297,12 +297,7 @@ def raise_if_credential_process_not_set( args = proc.split() cmd = args[0] - # On Windows Python 3.12 and 3.13, which() returns None if - # cmd is not in the system path even if it is a full path to - # an executable file. Adding an additional os.access check - # resolves the issue (See issue #233). - if not ((which(cmd) or os.access(cmd, os.F_OK | os.X_OK)) and - cmd.endswith("aws-login")): + if not (which(cmd) and cmd.endswith("aws-login")): raise CredentialProcessMisconfigured(profile) try: if not (args[args.index("--profile") + 1] == profile): From 3f08c7890c9d145da06185bc0a7da8527ae4c8ac Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Thu, 13 Feb 2025 12:14:21 -0600 Subject: [PATCH 09/10] Fix test_credential_process_valid * The unit test test_credential_process_valid fails on Windows Python 3.12 and 3.13 due to changes in the which function Close #233 --- src/tests/test_util.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/tests/test_util.py b/src/tests/test_util.py index 21d68ef1..bc681c67 100755 --- a/src/tests/test_util.py +++ b/src/tests/test_util.py @@ -267,14 +267,24 @@ def test_credential_process_invalid(self): def test_credential_process_valid(self): """Ensure does not raise exception""" self.profile = 'default' - path = self.write("aws-login", "") + # On Windows Python 3.12 and 3.13, which() returns None if + # cmd does not end in executable extension: *.EXE or *.BAT. + # (See issue #233). + if os.name == 'nt': + path = self.write("aws-login.bat", "") + else: + path = self.write("aws-login", "") # Windows Python versions 3.6, 3.7, and 3.8 require # that files created in a temporary directory are # writable otherwise cleanup will fail on deletion (#133) os.chmod(path, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) - self.aws_credentials = f"""[default] - credential_process = {path} --profile default - """ + # On Windows, Python 3.11 fails if the extension *.bat + # is included here... This is normally what happens in + # real life, but if a user sets it by hand and includes + # the extension they are SOL. + self.aws_credentials = "[default]\ncredential_process = " \ + f"{path[0:-4] if os.name == 'nt' else path}" \ + " --profile default" session = Session() raise_if_credential_process_not_set(session, self.profile) From 44ba80a177f14a4375de767b6037f50a32f3fb46 Mon Sep 17 00:00:00 2001 From: "David D. Riddle" Date: Thu, 13 Feb 2025 13:20:54 -0600 Subject: [PATCH 10/10] DROP ME -- DEBUG CODE --- src/awscli_login/util.py | 7 +++++++ src/tests/test_util.py | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/awscli_login/util.py b/src/awscli_login/util.py index ebd9afb4..46fe54c0 100644 --- a/src/awscli_login/util.py +++ b/src/awscli_login/util.py @@ -297,6 +297,13 @@ def raise_if_credential_process_not_set( args = proc.split() cmd = args[0] + print( + "\n\n--------------------------------------------------\n" + f"cmd: {cmd}\n" + f"which(cmd): {which(cmd)}\n" + "--------------------------------------------------\n\n" + ) + if not (which(cmd) and cmd.endswith("aws-login")): raise CredentialProcessMisconfigured(profile) try: diff --git a/src/tests/test_util.py b/src/tests/test_util.py index bc681c67..7589d529 100755 --- a/src/tests/test_util.py +++ b/src/tests/test_util.py @@ -286,6 +286,12 @@ def test_credential_process_valid(self): f"{path[0:-4] if os.name == 'nt' else path}" \ " --profile default" session = Session() + print( + "\n\n--------------------------------------------------\n" + f"PATH: {path}\n" + f"~/.aws/credentials: {self.aws_credentials}\n" + "--------------------------------------------------\n\n" + ) raise_if_credential_process_not_set(session, self.profile)