From 9a56516211c324aa7c8be7eae5cfeed951c51ebe Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 21 Jan 2025 23:07:34 +0100 Subject: [PATCH] Transition to pyproject.toml --- .github/workflows/test.yaml | 5 +-- .pre-commit-config.yaml | 8 ---- README.md | 6 +-- dev-requirements.txt | 6 --- pyproject.toml | 84 +++++++++++++++++++++++++++++++++++++ setup.py | 60 -------------------------- 6 files changed, 88 insertions(+), 81 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3eaaf52..8990707 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -61,8 +61,7 @@ jobs: - name: Install Python dependencies run: | pip install --upgrade pip - pip install . - pip install -r dev-requirements.txt + pip install ".[test]" pip freeze - name: Install helm @@ -102,7 +101,7 @@ jobs: - name: Run tests run: | - pytest --verbose --color=yes --cov chartpress + pytest env: HELM2: ${{ matrix.helm2 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4af44b4..4e4d496 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,20 +22,12 @@ repos: rev: 24.10.0 hooks: - id: black - args: - - --target-version=py37 - - --target-version=py38 - - --target-version=py39 - - --target-version=py310 - - --target-version=py311 # Autoformat: Python code - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort - args: - - --profile=black # Autoformat: markdown, yaml - repo: https://github.com/pre-commit/mirrors-prettier diff --git a/README.md b/README.md index d7ecbb1..9e5cc8a 100644 --- a/README.md +++ b/README.md @@ -363,12 +363,10 @@ testing, see [tests/README.md](tests/README.md). ```bash # install chartpress locally -pip install -e . - -# install dev dependencies -pip install -r dev-requirements.txt +pip install -e ".[test]" # format and lint code +pip install pre-commit pre-commit run -a # run tests diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index aca07e7..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -bump2version -gitpython -pre-commit -pytest -pytest-cov -tbump diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1123795 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,84 @@ +# build-system +# - ref: https://peps.python.org/pep-0517/ +# +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + + +# project +# - ref 1: https://peps.python.org/pep-0621/ +# - ref 2: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +# +[project] +name = "chartpress" +version = "2.3.1.dev" +description = "ChartPress: render and publish helm charts and images" +authors = [ + { name = "Jupyter Development Team", email = "jupyter@googlegroups.com" }, +] +keywords = ["helm", "kubernetes"] +license = { text = "BSD-3-Clause" } +requires-python = ">=3.7" +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: BSD License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +dependencies = [ + "ruamel.yaml>=0.15.44", + # Bug in 5.0.0: https://github.com/docker/docker-py/pull/2844 + "docker>=3.2.0,!=5.0.0", +] + +[project.optional-dependencies] +test = [ + "gitpython", + "pytest", + "pytest-cov", + "tbump", +] + +[project.urls] +Documentation = "https://github.com/jupyterhub/chartpress#readme" +Source = "https://github.com/jupyterhub/chartpress" +Issues = "https://github.com/jupyterhub/chartpress/issues" + +[project.scripts] +chartpress = "chartpress:main" + + +# setuptools +# - ref: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration +# +[tool.setuptools] +py-modules = ["chartpress"] + + +# black is used for autoformatting Python code +# +# ref: https://black.readthedocs.io/en/stable/ +# +[tool.black] +skip-string-normalization = false + + +# isort is used for autoformatting Python code +# +# ref: https://pycqa.github.io/isort/ +# +[tool.isort] +profile = "black" + + +# pytest is used for running Python based tests +# +# ref: https://docs.pytest.org/en/stable/ +# +[tool.pytest.ini_options] +addopts = "--verbose --color=yes --durations=10 --cov=chartpress" +testpaths = ["tests"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 00045f9..0000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -import sys - -from setuptools import setup -from setuptools.command.bdist_egg import bdist_egg - - -class bdist_egg_disabled(bdist_egg): - """Disabled version of bdist_egg - - Prevents setup.py install from performing setuptools' default easy_install, - which it should never ever do. - """ - - def run(self): - sys.exit( - "Aborting implicit building of eggs." - "Use `pip install .` to install from source." - ) - - -cmdclass = { - "bdist_egg": bdist_egg if "bdist_egg" in sys.argv else bdist_egg_disabled, -} - -with open("README.md") as f: - readme = f.read() - -setup( - name="chartpress", - version="2.3.1.dev", - py_modules=["chartpress"], - cmdclass=cmdclass, - entry_points={ - "console_scripts": [ - "chartpress = chartpress:main", - ], - }, - description="ChartPress: render and publish helm charts and images", - long_description=readme, - long_description_content_type="text/markdown", - author="Jupyter Development Team", - author_email="jupyter@googlegroups.com", - url="https://github.com/jupyterhub/chartpress", - license="BSD", - platforms="Linux, Mac OS X", - keywords=["helm", "kubernetes"], - python_requires=">=3.7", - install_requires=[ - "ruamel.yaml>=0.15.44", - # Bug in 5.0.0: https://github.com/docker/docker-py/pull/2844 - "docker>=3.2.0,!=5.0.0", - ], - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - ], -)