diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 89095817..64c8aafa 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -16,32 +16,22 @@ jobs: python-version: ["3.8", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - name: Install uv + uses: astral-sh/setup-uv@v5 with: + enable-cache: true python-version: ${{ matrix.python-version }} - - name: Cache pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-test.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Setup java uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '11' + java-version: '8' - name: Install dependencies - run: | - pip install -U pip setuptools - pip install . - - if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi + run: | + uv sync - name: Cache binary versions id: cache-versions @@ -59,6 +49,7 @@ jobs: - name: Download versions if: steps.cache-versions.outputs.cache-hit != 'true' run: | + source ${{ env.VIRTUAL_ENV }}/bin/activate normalized=$(echo ${{ inputs.reloc_version }} | tr ':' '_') if [ ! -f ~/.ccm/scylla-repository/unstable/master/$normalized ]; then ./ccm create temp -n 1 --scylla --version unstable/master:${{ inputs.reloc_version }} @@ -69,7 +60,7 @@ jobs: - name: Test with pytest run: | - python -m pytest ./tests -x + uv run python -m pytest ./tests -x - name: Copy logs/results if: contains(github.event.pull_request.labels.*.name, 'PR-upload-log') diff --git a/.gitignore b/.gitignore index c29d413e..93ca2562 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ tests/test_results .vscode/ .envrc -ccmlib/tests/ \ No newline at end of file +ccmlib/tests/ + +uv.lock \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..e4fba218 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/README.md b/README.md index 9aad3eee..dc259fa9 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Requirements ------------ - A working python installation (tested to work with python 3.12). -- `pip install -e .` to install the required dependencies. +- [UV](https://docs.astral.sh/uv) - Java if cassandra is used or older scylla < 6.0 (which version depends on the version of Cassandra you plan to use. If unsure, use Java 8 as it is known to work with current versions of Cassandra). @@ -80,9 +80,11 @@ Known issues Installation ------------ -ccm uses python setuptools (with distutils fallback) so from the source directory run: +ccm uses UV with setuptools as a build system (with distutils fallback) so from the source directory run: - sudo ./setup.py install + uv python install + uv venv .venv-ccm + uv sync ccm is available on the [Python Package Index][pip]: diff --git a/ccm b/ccm index 076baa2a..6adac75f 100755 --- a/ccm +++ b/ccm @@ -40,35 +40,39 @@ def print_global_usage(): exit(1) -common.check_win_requirements() +def main(): + common.check_win_requirements() -if len(sys.argv) <= 1: - print("Missing arguments") - print_global_usage() - -arg1 = sys.argv[1].lower() - -if arg1 in cluster_cmds.cluster_cmds(): - kind = 'cluster' - cmd = arg1 - cmd_args = sys.argv[2:] -else: - if len(sys.argv) <= 2: + if len(sys.argv) <= 1: print("Missing arguments") print_global_usage() - kind = 'node' - node = arg1 - cmd = sys.argv[2] - cmd_args = [node] + sys.argv[3:] - -cmd = get_command(kind, cmd) -if not cmd: - print("Unknown node or command: {0}".format(arg1)) - exit(1) -parser = cmd.get_parser() + arg1 = sys.argv[1].lower() + + if arg1 in cluster_cmds.cluster_cmds(): + kind = 'cluster' + cmd = arg1 + cmd_args = sys.argv[2:] + else: + if len(sys.argv) <= 2: + print("Missing arguments") + print_global_usage() + kind = 'node' + node = arg1 + cmd = sys.argv[2] + cmd_args = [node] + sys.argv[3:] + + cmd = get_command(kind, cmd) + if not cmd: + print("Unknown node or command: {0}".format(arg1)) + exit(1) + + parser = cmd.get_parser() + + (options, args) = parser.parse_args(cmd_args) + cmd.validate(parser, options, args) -(options, args) = parser.parse_args(cmd_args) -cmd.validate(parser, options, args) + cmd.run() -cmd.run() +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..7be89c4a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[project] +name = "ccm" +version = "0.1.0" +license = { file = "license.txt"} +description = "Cassandra Cluster Manager" +authors = [ + {name = "Sylvain Lebresne", email = "sylvain@datastax.com"} +] +maintainers = [ + {name="ScyllaDB Contributors"} +] +readme = "README.md" +requires-python = ">=3.8" +dependencies = [ + "ruamel-yaml", + "psutil", + "requests", + "packaging", + "boto3", + "tqdm", + "urllib3 < 2", +] +[project.urls] +Repository = "https://github.com/scylladb/scylla-ccm" +Issues = "https://github.com/scylladb/scylla-ccm/issues" + +[project.scripts] +ccm = "ccm:main" + +[dependency-groups] +dev = [ + "pytest", + "awscli" +] +[tool.setuptools] +packages = ["ccmlib", "ccmlib.cmds", "ccmlib.utils"] + +[tool.pytest.ini_options] +python_classes = ["*Test", "Test*"] +python_files = ["test_*", "*_test"] +python_functions = ["test_*", "*_test"] +testpaths = "tests" +norecursedirs = [".*", "ssl", "*.egg-info", "ccmlib", "docs"] +log_cli = true +log_cli_level = "ERROR" +log_level = "DEBUG" +log_format = "%(asctime)s %(levelname)-8s %(message)s" +log_date_format = "%Y-%m-%d %H:%M:%S" +log_file = "tests/test_results/ccm.log" +markers = [ + "docker: Run tests with docker image", + "reloc: Run tests with relocatable packages", + "cassandra: Run tests with cassandra binaries", + "repo_tests: Run test for testing get versions" +] +filterwarnings = ["error", "ignore::ResourceWarning"] + +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 43b43827..00000000 --- a/pytest.ini +++ /dev/null @@ -1,21 +0,0 @@ -[pytest] -python_classes = *Test Test* -python_files = test_* *_test -python_functions = test_* *_test -testpaths = tests -norecursedirs = .* ssl *.egg-info ccmlib docs -log_cli=true -log_cli_level = ERROR -log_level = DEBUG -log_format = %(asctime)s %(levelname)-8s %(message)s -log_date_format = %Y-%m-%d %H:%M:%S -log_file= tests/test_results/ccm.log -markers = - docker: Run tests with docker image - reloc: Run tests with relocatable packages - cassandra: Run tests with cassandra binaries - repo_tests: Run test for testing get versions - -filterwarnings = - error - ignore::ResourceWarning diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 1b3d9bbe..00000000 --- a/requirements-test.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest -awscli \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100755 index 94372e82..00000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -from os.path import abspath, join, dirname -from platform import system -from shutil import copyfile - -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - -ccmscript = 'ccm' -if system() == "Windows": - copyfile('ccm', 'ccm.py') - ccmscript = 'ccm.py' - -setup( - name='ccm', - version='2.0.5', - description='Cassandra Cluster Manager', - long_description=open(abspath(join(dirname(__file__), 'README.md'))).read(), - author='Sylvain Lebresne', - author_email='sylvain@datastax.com', - url='https://github.com/pcmanus/ccm', - packages=['ccmlib', 'ccmlib.cmds', 'ccmlib.utils'], - scripts=[ccmscript], - install_requires=['ruamel.yaml', 'psutil', 'requests', 'packaging', 'boto3', 'tqdm', 'urllib3<2'], - tests_require=['pytest'], - classifiers=[ - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9' - 'Programming Language :: Python :: 3.11' - 'Programming Language :: Python :: 3.12' - ], - include_package_data=True, -)