From e989f18f5d5576a47ffdc2033f1577a0b3961853 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Tue, 26 Nov 2024 20:25:29 -0800 Subject: [PATCH 1/3] update cheetah3 -> ct3 The former was renamed due to PyPI classifying the project as critical and requiring 2FA: https://github.com/CheetahTemplate3/cheetah3/commit/673259b2d139b4ea970b1c2da12607b7ac39cbec --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8d79b5d..4ff393e 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), install_requires=[ - 'cheetah3>=3.0.0,<4.0', + 'ct3>=3.0.0,<4.0', 'pyyaml>=5.0,!=5.4.0,!=5.4.1,!=6.0,<7.0', 'requests>=2.0.0,<3.0.0', 'blessings<2.0', From d7bbc58ee0b4f9f4cb55d51bcb17559b6f29de0f Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Tue, 26 Nov 2024 20:25:45 -0800 Subject: [PATCH 2/3] fix syntax warnings on 3.12+ As shown with `python3.12 -m compileall -f $(git ls-files '*.py')` --- charmtools/diff_match_patch.py | 2 +- tests/layers/mysql/hooks/common.py | 2 +- tests/layers/mysql/hooks/nrpe_relations.py | 2 +- tests/layers/mysql/scripts/charm_helpers_sync.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charmtools/diff_match_patch.py b/charmtools/diff_match_patch.py index 020408a..19b2f17 100644 --- a/charmtools/diff_match_patch.py +++ b/charmtools/diff_match_patch.py @@ -1815,7 +1815,7 @@ def patch_fromText(self, textline): return patches text = textline.split('\n') while len(text) != 0: - m = re.match("^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$", text[0]) + m = re.match(r"^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$", text[0]) if not m: raise ValueError("Invalid patch string: " + text[0]) patch = patch_obj() diff --git a/tests/layers/mysql/hooks/common.py b/tests/layers/mysql/hooks/common.py index 799663b..ecd444d 100755 --- a/tests/layers/mysql/hooks/common.py +++ b/tests/layers/mysql/hooks/common.py @@ -96,7 +96,7 @@ def migrate_to_mount(new_path): raise RuntimeError('Persistent storage contains old data. ' 'Please investigate and migrate data manually ' 'to: {}'.format(new_path)) - os.chmod(new_path, 0700) + os.chmod(new_path, 0o0700) if os.path.isdir('/etc/apparmor.d/local'): render('apparmor.j2', '/etc/apparmor.d/local/usr.sbin.mysqld', context={'path': os.path.join(new_path, '')}) diff --git a/tests/layers/mysql/hooks/nrpe_relations.py b/tests/layers/mysql/hooks/nrpe_relations.py index 4186f7e..16d4424 100755 --- a/tests/layers/mysql/hooks/nrpe_relations.py +++ b/tests/layers/mysql/hooks/nrpe_relations.py @@ -22,7 +22,7 @@ def nagios_password(): password = str(uuid.uuid4()) with open(PASSFILE, 'w') as f: f.write(password) - os.chmod(PASSFILE, 0600) + os.chmod(PASSFILE, 0o0600) else: with open(PASSFILE, 'r') as rpw: password = rpw.read() diff --git a/tests/layers/mysql/scripts/charm_helpers_sync.py b/tests/layers/mysql/scripts/charm_helpers_sync.py index 1697cc0..3f683cf 100755 --- a/tests/layers/mysql/scripts/charm_helpers_sync.py +++ b/tests/layers/mysql/scripts/charm_helpers_sync.py @@ -217,7 +217,7 @@ def sync_helpers(include, src, dest, options=None): checkout = clone_helpers(tmpd, config['branch']) sync_helpers(config['include'], checkout, config['destination'], options=sync_options) - except Exception, e: + except Exception as e: logging.error("Could not sync: %s" % e) raise e finally: From 2bca4fd307fafa4994946bbe11889b04a7915470 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Tue, 26 Nov 2024 20:46:27 -0800 Subject: [PATCH 3/3] migrate to pyproject.toml --- pyproject.toml | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 60 +---------------------------------------------- 2 files changed, 64 insertions(+), 59 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..28b0b60 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,63 @@ +[project] +name = "charm-tools" +description = "Tools for building and maintaining Juju charms" +readme = "README.rst" +maintainers = [{ name = "Cory Johns", email = "johnsca@gmail.com" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Programming Language :: Python", +] +dependencies = [ + "blessings<2.0", + "colander<1.9", + "ct3>=3.0.0,<4.0", + "dict2colander==0.2", + "jsonschema<4.18.0", + "jujubundlelib<0.6", + "keyring<24", + "otherstuf<=1.1.0", + "path<17", + "pathspec<0.11;python_version >= '3.7'", + "pathspec<=0.3.4;python_version < '3.7'", + "pip>=1.5.4", + "pyyaml>=5.0,!=5.4.0,!=5.4.1,!=6.0,<7.0", + "requests>=2.0.0,<3.0.0", + "requirements-parser<0.6", + "ruamel.yaml<0.16.0;python_version < '3.7'", + "ruamel.yaml<0.18;python_version >= '3.7'", + "secretstorage<3.4", + "vergit>=1.0.0,<2.0.0", + "virtualenv>=1.11.4,<21", +] +license = { text = "GPL v3" } +dynamic = ["version"] + +[project.urls] +Homepage = "https://github.com/juju/charm-tools" + +[project.scripts] +charm-build = "charmtools.build.builder:main" +charm-create = "charmtools.create:main" +charm-help = "charmtools.cli:usage" +charm-layers = "charmtools.build.builder:inspect" +charm-proof = "charmtools.proof:main" +charm-pull-source = "charmtools.pullsource:main" +charm-version = "charmtools.version:main" + +[project.entry-points."charmtools.templates"] +ansible = "charmtools.templates.ansible:AnsibleCharmTemplate" +bash = "charmtools.templates.bash:BashCharmTemplate" +chef = "charmtools.templates.chef:ChefCharmTemplate" +powershell = "charmtools.templates.powershell:PowerShellCharmTemplate" +python = "charmtools.templates.python_services:PythonServicesCharmTemplate" +python-basic = "charmtools.templates.python:PythonCharmTemplate" +reactive-bash = "charmtools.templates.reactive_bash:ReactiveBashCharmTemplate" +reactive-python = "charmtools.templates.reactive_python:ReactivePythonCharmTemplate" + +[tool.setuptools.packages.find] +exclude = ["*tests*"] + +[build-system] +requires = ["setuptools>=68"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 4ff393e..b367171 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ import subprocess import sys import json -from setuptools import setup, find_packages +from setuptools import setup curdir = os.path.dirname(__file__) @@ -37,63 +37,5 @@ setup( - name='charm-tools', version=version, - packages=find_packages( - exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - install_requires=[ - 'ct3>=3.0.0,<4.0', - 'pyyaml>=5.0,!=5.4.0,!=5.4.1,!=6.0,<7.0', - 'requests>=2.0.0,<3.0.0', - 'blessings<2.0', - 'ruamel.yaml<0.16.0;python_version < "3.7"', - 'pathspec<=0.3.4;python_version < "3.7"', - 'ruamel.yaml<0.18;python_version >= "3.7"', - 'pathspec<0.11;python_version >= "3.7"', - 'otherstuf<=1.1.0', - 'path<17', - 'pip>=1.5.4', - 'jujubundlelib<0.6', - 'virtualenv>=1.11.4,<21', - 'colander<1.9', - 'jsonschema<4.18.0', - 'keyring<24', - 'secretstorage<3.4', - 'dict2colander==0.2', - 'vergit>=1.0.0,<2.0.0', - 'requirements-parser<0.6', - ], - include_package_data=True, - maintainer='Cory Johns', - maintainer_email='johnsca@gmail.com', - description=('Tools for building and maintaining Juju charms'), - long_description=readme, - license='GPL v3', - url='https://github.com/juju/charm-tools', - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Programming Language :: Python", - ], - entry_points={ - 'console_scripts': [ - 'charm-build = charmtools.build.builder:main', - 'charm-create = charmtools.create:main', - 'charm-help = charmtools.cli:usage', - 'charm-layers = charmtools.build.builder:inspect', - 'charm-proof = charmtools.proof:main', - 'charm-pull-source = charmtools.pullsource:main', - 'charm-version = charmtools.version:main', - ], - 'charmtools.templates': [ - 'bash = charmtools.templates.bash:BashCharmTemplate', - 'reactive-python = charmtools.templates.reactive_python:ReactivePythonCharmTemplate', # noqa: E501 - 'reactive-bash = charmtools.templates.reactive_bash:ReactiveBashCharmTemplate', # noqa: E501 - 'python-basic = charmtools.templates.python:PythonCharmTemplate', - 'python = charmtools.templates.python_services:PythonServicesCharmTemplate', # noqa: E501 - 'ansible = charmtools.templates.ansible:AnsibleCharmTemplate', - 'chef = charmtools.templates.chef:ChefCharmTemplate', - 'powershell = charmtools.templates.powershell:PowerShellCharmTemplate', # noqa: E501 - ] - }, )