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

Ensure package can be built and tested with Python 3.11 #97

Merged
merged 5 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
strategy:
matrix:
# only use one version for the lint step
# pylint is broken with 3.11, see
# https://github.com/PyCQA/pylint/issues/6535
python-version: ["3.10"]
env:
MYSQL_VERSION: mysql-8.0
Expand Down Expand Up @@ -89,24 +91,27 @@ jobs:
- mysql-version: "8.0.26"
percona-version: "8.0.28-20-1.focal"
python-version: "3.9"
- mysql-version: "8.0.27"
percona-version: "8.0.27-19-1.focal"
python-version: "3.7"
- mysql-version: "8.0.27"
percona-version: "8.0.27-19-1.focal"
python-version: "3.8"
- mysql-version: "8.0.27"
percona-version: "8.0.27-19-1.focal"
python-version: "3.9"
- mysql-version: "8.0.27"
percona-version: "8.0.27-19-1.focal"
python-version: "3.10"
- mysql-version: "8.0.27"
percona-version: "8.0.27-19-1.focal"
python-version: "3.11"
- mysql-version: "8.0.27"
percona-version: "8.0.28-21-1.focal"
python-version: "3.9"
- mysql-version: "8.0.27"
percona-version: "8.0.28-21-1.focal"
python-version: "3.11"
- mysql-version: "8.0.28"
percona-version: "8.0.28-21-1.focal"
python-version: "3.9"
- mysql-version: "8.0.28"
percona-version: "8.0.28-21-1.focal"
python-version: "3.11"

steps:
- id: checkout-code
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ __pycache__/
Dockerfile.myhoard-test-temp
.vscode/
myhoard/version.py
.hypothesis/
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.7.4
rev: v3.0.0a5
hooks:
- id: pylint
args: [--disable=E0401]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.960
rev: v0.982
hooks:
- id: mypy
args: [--ignore-missing-imports]
Expand Down
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,35 +802,28 @@ And have all test run, or just
Setting `PYTHON_VERSION` is optional, but make sure you're using the same interpreter that was employed during setup, otherwise
you may encounter runtime errors.

```


License
=======
# License

MyHoard is licensed under the Apache License, Version 2.0. Full license text
is available in the ``LICENSE`` file and at
http://www.apache.org/licenses/LICENSE-2.0.txt


Contact
=======
# Contact

Bug reports and patches are very welcome, please post them as GitHub issues
and pull requests at https://github.com/aiven/myhoard. Any possible
vulnerabilities or other serious issues should be reported directly to the
maintainers <[email protected]>.

Trademarks
==========
# Trademarks

MySQL is a registered trademark of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Telegraf® is a trademark [registered / owned] by InfluxData, which is not affiliated with, and does not endorse, this product.

Percona Xtrabackup is a trademark and property of its respective owners. All product and service names used in this website are for identification purposes only and do not imply endorsement.

Credits
=======
# Credits

MyHoard was created by, and is maintained by, [Aiven](https://aiven.io) cloud
data hub developers.
Expand Down
2 changes: 1 addition & 1 deletion myhoard.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Requires: percona-xtrabackup-80 >= 8.0
Requires: python3-aiohttp
Requires: python3-cryptography >= 0.8
Requires: python3-PyMySQL >= 0.9.2
Requires: python3-rohmu >= 1.0.2
Requires: python3-rohmu >= 1.0.7
Requires: systemd

%undefine _missing_build_ids_terminate_build
Expand Down
2 changes: 1 addition & 1 deletion myhoard/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def switch_to_observe_mode(self):
return
elif self.mode in {self.Mode.active, self.Mode.promote}:
# Master (or almost master) cannot become a standby
raise ValueError(f"Switch from {self.mode} to observe mode is not allowed")
raise ValueError(f"Switch from {self.mode.value} to observe mode is not allowed")
aris-aiven marked this conversation as resolved.
Show resolved Hide resolved
elif self.mode == self.Mode.restore:
self._fail_if_restore_is_not_complete()
self._fail_if_not_read_only()
Expand Down
2 changes: 1 addition & 1 deletion myhoard/restore_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ def _patch_gtid_executed(self, binlog):
)

cursor.execute(
("UPDATE mysql.gtid_executed SET interval_end = %s " " WHERE source_uuid = %s AND interval_start = %s"),
("UPDATE mysql.gtid_executed SET interval_end = %s WHERE source_uuid = %s AND interval_start = %s"),
(gtid_range["end"], gtid_range["server_uuid"], existing_range["interval_start"]),
)
cursor.execute("COMMIT")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ httplib2
paramiko
PyMySQL >= 0.9.2
PySocks
rohmu == 1.0.4
rohmu == 1.0.7
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.6",
"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",
"Topic :: Database :: Database Engines/Servers",
"Topic :: Software Development :: Libraries",
],
Expand Down
67 changes: 41 additions & 26 deletions version.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
# Copyright (c) 2019 Aiven, Helsinki, Finland. https://aiven.io/
aris-aiven marked this conversation as resolved.
Show resolved Hide resolved
import imp
from __future__ import annotations

import importlib.util
import os
import subprocess
import sys

PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))


def save_version(new_ver, old_ver, version_file):
if not new_ver:
def save_version(new_version: str | None, old_version: str | None, version_file_path: str) -> bool:
if not new_version:
return False
version_file = os.path.join(os.path.dirname(__file__), version_file)
if not old_ver or new_ver != old_ver:
with open(version_file, "w") as fp:
fp.write("__version__ = '{}'\n".format(new_ver))
if not old_version or new_version != old_version:
with open(version_file_path, "w") as fp:
fp.write(f'__version__ = "{new_version}"\n')
return True


def get_project_version(version_file):
version_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), version_file)
def get_project_version(version_file_relpath: str) -> str:
version_file_abspath = os.path.join(PROJECT_DIR, version_file_relpath)
file_version = None
try:
module = imp.load_source("verfile", version_file)
file_ver = module.__version__
module_spec = importlib.util.spec_from_file_location("verfile", location=version_file_abspath)
if module_spec:
module = importlib.util.module_from_spec(module_spec)
if module_spec.loader:
module_spec.loader.exec_module(module)
file_version = module.__version__
else:
print(f"Could not load module spec from version file location: {version_file_abspath!r}")
except IOError:
file_ver = None
print(f"Could not load version module from spec (file location: {version_file_abspath!r})")

os.chdir(os.path.dirname(__file__) or ".")
try:
git_out = subprocess.check_output(["git", "describe", "--always"], stderr=getattr(subprocess, "DEVNULL", None))
except (OSError, subprocess.CalledProcessError):
pass
else:
git_ver = git_out.splitlines()[0].strip().decode("utf-8")
if "." not in git_ver:
git_ver = "0.0.1-0-unknown-{}".format(git_ver)
if save_version(git_ver, file_ver, version_file):
return git_ver

short_ver = subprocess.run(["git", "describe", "--abbrev=0"], check=True, text=True, capture_output=True).stderr
if save_version(short_ver, file_ver, version_file):
return short_ver
git_version = git_out.splitlines()[0].strip().decode("utf-8")
if "." not in git_version:
git_version = f"0.0.1-0-unknown-{git_version}"
if save_version(git_version, file_version, version_file_abspath):
print(f"Version resolved from git: {git_version}")
return git_version

if not file_ver:
raise Exception("version not available from git or from file {!r}".format(version_file))
short_version = subprocess.run(["git", "describe", "--abbrev=0"], check=True, text=True, capture_output=True).stderr
if save_version(short_version, file_version, version_file_abspath):
print(f"Short version resolved from git abbrev: {short_version}")
return short_version

return file_ver
if not file_version:
raise Exception(f"version not available from git or from file {version_file_abspath!r}")
else:
print(f"Version resolved from file: {file_version}")
return file_version


if __name__ == "__main__":
import sys

if len(sys.argv) < 2:
print("Usage: python3 version.py <filename>")
sys.exit(1)
get_project_version(sys.argv[1])