Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #204 support python 3.13 #205

Merged
merged 12 commits into from
Oct 23, 2024
2 changes: 1 addition & 1 deletion .github/workflows/testing-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python: ["3.9", "3.10", "3.11", "3.12"]
python: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [DEVELOPMENT]

### Changed
- Added Python 3.12 support (gh-204)
- Removed Python 3.8 support (gh-204)

## [5.0.1] 2024-08-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A Python API to sign into and query a 1Password account using the `op` command.

## Requirements

- Python >= 3.9
- Python >= 3.10
- 1Password command-line tool >= 2.26.0
- Versions >= 2.21.0, < 2.26.0 supported but deprecated
- Versions < 2.21.0 are unsupported and an exception will be raised
Expand Down
2 changes: 1 addition & 1 deletion _readme_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A Python API to sign into and query a 1Password account using the `op` command.

## Requirements

- Python >= 3.9
- Python >= 3.10
- 1Password command-line tool >= SUPPORTED_CLI_VERSION__
- Versions >= MINIMUM_CLI_VERSION__, < SUPPORTED_CLI_VERSION__ supported but deprecated
- Versions < MINIMUM_CLI_VERSION__ are unsupported and an exception will be raised
Expand Down
52 changes: 52 additions & 0 deletions dev-docs/updating-python-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Updating Python Support

This file documents how to add a new python version and/or remove an old one to automated testing and GitHub CI.

To add python 3.13 & remove python 3.9:


Files to update:

- tox.ini
- replace all cases of `39,310,311,312` with `310,311,312,313`
- setup.py
- update minimum python: `python_requires='>=3.10'`
- update `classifiers`:

```"Programming Language :: Python :: 3.13"```
- Docker:
- rename py39.Dockerfile to py313.Dockerfile
- replace '3.9' with '3.13' globally
- replace 'py39' with 'py313' globally
- `clean.sh`
- add `docker_py313` to `docker image rm` command
- it's okay to leave `docker_py39` to ensure it gets removed
- If there's a really old docker python image, e.g., `docker_py38`, go ahead and remove that
- `build.sh`
- copy 'docker buildx' command for python 3.12
- replace all `py312` with `py313`
- delete `docker buildx` command for python 3.9
- `run.sh`
- duplicate run command for `docker_py312`, replacing container name with `docker_py313`
- delete `docker run` command for python 3.9
- `run-individual.sh`
- duplicate `elif` clause for python 3.12, updating it to `docker_py312`
- delete `if-elif` clause for python 3.9
- update help message: `"Specify py310, py311, py312, or py313"`
- rennovate.json
- add dict for 3.13 dockerfile
- Note the name of the dockerfile, as well as `allowedVersions` key:
```
{
"matchPaths": ["docker_testing/docker/py313.Dockerfile"],
"matchPackageNames":["python"],
"allowedVersions": "3.13"
}
```
- remove dict for 3.9
- .github/workflows/testing-linting.yml
- update python version matrix: `["3.10", "3.11", "3.12", "3.13"]`
- _readme_template.md
- Update minimum python version under requirements
- README.md:
- run `scripts/update_readme.py` to apply changes to README.md
2 changes: 1 addition & 1 deletion docker_testing/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

echo "Building..."

docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py39.Dockerfile -t docker_py39 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py310.Dockerfile -t docker_py310 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py311.Dockerfile -t docker_py311 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py312.Dockerfile -t docker_py312 || exit
docker buildx build "$SCRIPT_DIR"/docker/ -f "$SCRIPT_DIR"/docker/py313.Dockerfile -t docker_py313 || exit

echo "...done"
echo ""
2 changes: 1 addition & 1 deletion docker_testing/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# this should not be an error
echo "Cleaning..."
echo "removing docker images"
docker image rm docker_py38 docker_py39 docker_py310 docker_py311 docker_py312
docker image rm docker_py39 docker_py310 docker_py311 docker_py312 docker_py313
echo "removing .tox-docker"
rm -rf .tox-docker
echo "...done"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.13

RUN useradd -ms /bin/bash unpriv

Expand All @@ -14,6 +14,6 @@ ENV TESTDIR=/usr/src/testdir
# PYVER_FACTOR gets passed to:
# tox run -f $PYVER_FACTOR
# so e.g., all py311-{something,something-else} envs get run
ENV PYVER_FACTOR=py39
ENV PYVER_FACTOR=py313
COPY test.sh /test.sh
CMD [ "/test.sh" ]
12 changes: 6 additions & 6 deletions docker_testing/run-individual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ trap handle_sig INT

container=""

if [ "$1" = "py39" ];
then
container="docker_py39"
shift
elif [ "$1" = "py310" ];
if [ "$1" = "py310" ];
then
container="docker_py310"
shift
Expand All @@ -35,11 +31,15 @@ elif [ "$1" = "py312" ];
then
container="docker_py312"
shift
elif [ "$1" = "py313" ];
then
container="docker_py313"
shift
fi

if [ -z "$container" ];
then
quit "Specify py39, py310, py311, or py312" 1
quit "Specify py310, py311, py312, or py313" 1
fi


Expand Down
4 changes: 2 additions & 2 deletions docker_testing/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ trap handle_sig INT
ret=0

echo "Running docker tests..."
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py39 /test.sh "$@"
ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py310 /test.sh "$@"
ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py311 /test.sh "$@"
ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py312 /test.sh "$@"
ret="$(($?+ret))"
docker run --rm -it -v "$(pwd):/usr/src/testdir" docker_py313 /test.sh "$@"
ret="$(($?+ret))"

echo "...done"
echo ""
Expand Down
2 changes: 1 addition & 1 deletion pyonepassword/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "pyonepassword"
__version__ = "5.0.1"
__version__ = "5.1.0.dev0"
__summary__ = "A python API to query a 1Password account using the 'op' command-line tool"

"""
Expand Down
10 changes: 5 additions & 5 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
],
"baseBranches": ["development"],
"packageRules": [
{
"matchPaths": ["docker_testing/docker/py39.Dockerfile"],
"matchPackageNames":["python"],
"allowedVersions": "3.9"
},
{
"matchPaths": ["docker_testing/docker/py310.Dockerfile"],
"matchPackageNames":["python"],
Expand All @@ -24,6 +19,11 @@
"matchPaths": ["docker_testing/docker/py312.Dockerfile"],
"matchPackageNames":["python"],
"allowedVersions": "3.12"
},
{
"matchPaths": ["docker_testing/docker/py313.Dockerfile"],
"matchPackageNames":["python"],
"allowedVersions": "3.13"
}
]
}
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run(self):
long_description_content_type="text/markdown",
url="https://github.com/zcutlip/pyonepassword",
packages=packages,
python_requires='>=3.9',
python_requires='>=3.10',
install_requires=[
"python-singleton-metaclasses"
],
Expand All @@ -96,10 +96,10 @@ def run(self):
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"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",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
Expand Down
6 changes: 5 additions & 1 deletion tests/test_svc_acct_support/test_svc_acct_primary_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ def test_svc_account_primary_api_docstrings():
-----------------------
"""
# regex where '.' will match newlines
# NOTE:
# python < 3.13 includes indentation space in docstrings
# python >= 3.13 strips leading indentation
# the `\s*` accounts for this discrepency
svc_account_string_re = re.compile(
r"Service Account Support.\s+-----------------------", re.DOTALL)
r"Service Account Support.\s*-----------------------", re.DOTALL)

# get all class and instance methods
op_vars = vars(OP)
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{39,310,311,312}-{pytest,mypy}
envlist = py{310,311,312,313}-{pytest,mypy}
discover = {env:CUSTOM_PYTHON}


Expand All @@ -14,7 +14,7 @@ commands =
{posargs}


[testenv:py{39,310,311,312}-mypy]
[testenv:py{310,311,312,313}-mypy]
# It's important to run mypy across all supported python versions
# so we don't introduce type hints incompatible with older python versions
# e.g., TypeAlias not available for pythton < 3.10
Expand Down