Skip to content

Commit

Permalink
Update to support Python 3.11 and 3.12 (#440)
Browse files Browse the repository at this point in the history
* Updated dependency versions

Updated compatible dependency to support for python 3.11 and 3.12 requires changes in pygit2 version 1.141.1 and click version 8.*.*

The build will consider the python version and select the appropriate libraries.

Updated GitHub workflows
Updated azure-pipelines
Updated CHANGELOG.md

* Changes for Flake

Refactored code to resolve W604 flake8 warnings; updated flake8 config to ignore unnecessary errors E231 and E713

* Updated file to solve flake check

Updated file to solve flake check. Refactored code to resolve flake8 error E221

* Review comments update

Updated Changelog file and pinned the pygit2 version for python 3.10
  • Loading branch information
Rana-KV authored Jun 6, 2024
1 parent c28786a commit 852a5d9
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = E203, E266, E501, W503
ignore = E203, E231, E266, E501, E713, W503
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning][semver].
## [Unreleased]

### Added

- Support for Python 3.11 and 3.12 ([440])
- Fix generation of keys when they should be printed to the command line ([435])
- Made Updater faster through parallelization ([434])
- Fixes repeating error messages in taf repo create and manual entry of keys-description ([432])
Expand All @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning][semver].
- Clone target repositories to temp ([412, 418])
- Add architecture overview documentation ([405])

[440]: https://github.com/openlawlibrary/taf/pull/440
[435]: https://github.com/openlawlibrary/taf/pull/435
[434]: https://github.com/openlawlibrary/taf/pull/434
[432]: https://github.com/openlawlibrary/taf/pull/432
Expand Down
35 changes: 34 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,40 @@ strategy:
pythonVersion: "3.10"
platform: x86
winArch: "win32"

# py311
linux-ubuntu-22-04-py311:
imageName: "ubuntu-22.04"
pythonVersion: "3.11"
macOS-py311:
imageName: "macOS-11"
pythonVersion: "3.11"
windows-64bit-py311:
imageName: "windows-2022"
pythonVersion: "3.11"
platform: x64
winArch: "win64"
windows-32bit-py311:
imageName: "windows-2022"
pythonVersion: "3.11"
platform: x86
winArch: "win32"
# py312
linux-ubuntu-22-04-py312:
imageName: "ubuntu-22.04"
pythonVersion: "3.12"
macOS-py312:
imageName: "macOS-11"
pythonVersion: "3.12"
windows-64bit-py312:
imageName: "windows-2022"
pythonVersion: "3.12"
platform: x64
winArch: "win64"
windows-32bit-py312:
imageName: "windows-2022"
pythonVersion: "3.12"
platform: x86
winArch: "win32"
pool:
vmImage: $(imageName)

Expand Down
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from setuptools import find_packages, setup
from importlib.util import find_spec
import sys

PACKAGE_NAME = "taf"
VERSION = "0.29.3"
Expand Down Expand Up @@ -46,6 +47,12 @@ def finalize_options(self):

yubikey_require = ["yubikey-manager==4.0.*"]

# Determine the appropriate version of pygit2 based on the Python version
if sys.version_info > (3, 10):
pygit2_version = "pygit2==1.14.1"
elif sys.version_info >= (3, 7) and sys.version_info <= (3, 10):
pygit2_version = "pygit2==1.9.*"

kwargs = {
"name": PACKAGE_NAME,
"version": VERSION,
Expand All @@ -63,13 +70,13 @@ def finalize_options(self):
"zip_safe": False,
"install_requires": [
"cattrs>=23.1.2",
"click==7.*",
"click==8.*",
"colorama>=0.3.9",
"oll-tuf==0.20.0.dev2",
"cryptography==38.0.*",
"securesystemslib==0.25.*",
"loguru==0.6.*",
"pygit2==1.9.*",
pygit2_version,
"pyOpenSSL==22.1.*",
"logdecorator==2.*",
],
Expand Down Expand Up @@ -99,6 +106,8 @@ def finalize_options(self):
"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 :: Implementation :: CPython",
],
}
Expand Down
2 changes: 1 addition & 1 deletion taf/tools/yubikey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_roles(path):
for role, paths in roles_with_paths.items():
print(f"\n{role}")
for path in paths:
print(f"\n -{path}")
print(f"\n -{path}")
return get_roles


Expand Down
4 changes: 2 additions & 2 deletions taf/updater/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def clone_repository(config: RepositoryConfig):

if config.path and is_non_empty_directory(config.path):
raise UpdateFailedError(
f"Destination path {config.path} already exists and is not an empty directory. Run `taf repo update` to update it."
f"Destination path {config.path} already exists and is not an empty directory. Run 'taf repo update' to update it."
)

config.operation = OperationType.CLONE
Expand Down Expand Up @@ -269,7 +269,7 @@ def update_repository(config: RepositoryConfig):
auth_repo = GitRepository(path=config.path)
if not config.path.is_dir() or not auth_repo.is_git_repository:
raise UpdateFailedError(
f"{config.path} is not a Git repository. Run `taf repo clone` instead"
f"{config.path} is not a Git repository. Run 'taf repo clone' instead"
)

taf_logger.info(f"Updating repository {auth_repo.name}")
Expand Down
4 changes: 2 additions & 2 deletions taf/updater/updater_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ def clone_remote_and_run_tuf_updater(self):
def _validate_operation_type(self):
if self.operation == OperationType.CLONE and self.state.existing_repo:
raise UpdateFailedError(
f"Destination path {self.state.users_auth_repo.path} already exists and is not an empty directory. Run `taf repo update` to update it."
f"Destination path {self.state.users_auth_repo.path} already exists and is not an empty directory. Run 'taf repo update' to update it."
)
elif self.operation == OperationType.UPDATE and not self.state.existing_repo:
raise UpdateFailedError(
f"{self.state.users_auth_repo.path} is not a Git repository. Run `taf repo clone` instead"
f"{self.state.users_auth_repo.path} is not a Git repository. Run 'taf repo clone' instead"
)

@log_on_start(
Expand Down

0 comments on commit 852a5d9

Please sign in to comment.