diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 952474a..383cf51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 @@ -27,8 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements.dev.txt + pip install -e .[dev] - id: validate-style run: make validate-style diff --git a/Makefile b/Makefile index 6364bb0..caf84e4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,3 @@ -short_ver = 0.0.1 -long_ver = $(shell git describe --long 2>/dev/null || echo $(short_ver)-0-unknown-g`git describe --always`) - all: PYTHON ?= python3 @@ -12,24 +9,6 @@ clean: $(RM) -r *.egg-info/ build/ dist/ rpm/ $(RM) ../rpm_s3_mirror_* test-*.xml -rpm: - git archive --output=rpm_s3_mirror-rpm-src.tar --prefix=rpm_s3_mirror/ HEAD - rpmbuild -bb rpm_s3_mirror.spec \ - --define '_topdir $(PWD)/rpm' \ - --define '_sourcedir $(CURDIR)' \ - --define 'major_version $(short_ver)' \ - --define 'minor_version $(subst -,.,$(subst $(short_ver)-,,$(long_ver)))' - $(RM) rpm_s3_mirror-rpm-src.tar - -build-dep-fed: - sudo dnf -y install --best --allowerasing \ - python3-black \ - python3-defusedxml \ - python3-requests \ - python3-dateutil \ - python3-botocore \ - python3-lxml - test: copyright lint unittest reformat: diff --git a/pyproject.toml b/pyproject.toml index dbf2df6..57a29c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,58 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "rpm_s3_mirror" +authors = [ + { name="Aiven", email="support@aiven.io" }, +] +description = "Tool for syncing RPM repositories with S3" +readme = "README.md" +requires-python = ">=3.7" +classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: Apache Software License", + "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", + "Natural Language :: English", +] +license = { text = "Apache License 2.0" } +dynamic = ["version"] +dependencies = [ + "defusedxml>=0.7.1,<1", + "requests>=2.27.1,<3", + "python-dateutil>=2.8.1,<3", + "botocore>=1.23.50,<2", + "lxml>=4.6.5,<5", +] + +[project.optional-dependencies] +dev = [ + "black>=22.8.0,<23", + "click>=8.0.1,<9", +] + +[project.urls] +"Homepage" = "https://github.com/aiven/rpm-s3-mirror" +"Bug Tracker" = "https://github.com/aiven/rpm-s3-mirror/issues" + +[project.scripts] +rpm_s3_mirror = "rpm_s3_mirror.__main__:main" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "rpm_s3_mirror/version.py" + + # NOTE: you have to use single-quoted strings in TOML for regular expressions. # It's the equivalent of r-strings in Python. Multiline strings are treated as # verbose regular expressions by Black. Use [ ] to denote a significant space diff --git a/requirements.dev.txt b/requirements.dev.txt deleted file mode 100644 index 5e6f0f9..0000000 --- a/requirements.dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Lock black to the same major version used in downstream build environments -black==21.6b0 -# To prevent black from breaking (https://github.com/psf/black/issues/2964, https://github.com/psf/black/pull/2966) -click<8.1.0 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a196c9d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -defusedxml -requests -python-dateutil -botocore -lxml diff --git a/setup.py b/setup.py index d764474..edadfa0 100644 --- a/setup.py +++ b/setup.py @@ -1,36 +1,9 @@ # Copyright (c) 2020 Aiven, Helsinki, Finland. https://aiven.io/ -from setuptools import setup -import version +# a setup.py shim which is required for an editable install +# see pyproject.toml for build configuration +# https://peps.python.org/pep-0518 +import setuptools -version = version.get_project_version("rpm_s3_mirror/version.py") - -setup( - name="rpm_s3_mirror", - packages=["rpm_s3_mirror"], - version=version, - description="Tool for syncing RPM repositories with S3", - license="Apache 2.0", - author="Aiven", - author_email="willcoe@aiven.io", - url="https://github.com/aiven/rpm-s3-mirror", - install_requires=[ - "defusedxml", - "requests", - "python-dateutil", - "botocore", - "lxml", - ], - entry_points={ - "console_scripts": [ - "rpm_s3_mirror = rpm_s3_mirror.__main__:main", - ], - }, - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: System Administrators", - "Programming Language :: Python :: 3.7", - "Natural Language :: English", - ], -) +if __name__ == "__main__": + setuptools.setup() diff --git a/version.py b/version.py deleted file mode 100644 index d58aa8c..0000000 --- a/version.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2019 Aiven, Helsinki, Finland. https://aiven.io/ -import imp -import os -import subprocess - - -def save_version(new_ver, old_ver, version_file): - if not new_ver: - 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)) - return True - - -def get_project_version(version_file): - version_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), version_file) - try: - module = imp.load_source("verfile", version_file) - file_ver = module.__version__ - except IOError: - file_ver = None - - 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").replace("-g", ".g") - 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 - - makefile = os.path.join(os.path.dirname(__file__), "Makefile") - if os.path.exists(makefile): - with open(makefile, "r") as fp: - lines = fp.readlines() - short_ver = [line.split("=", 1)[1].strip() for line in lines if line.startswith("short_ver")][0] - if save_version(short_ver, file_ver, version_file): - return short_ver - - if not file_ver: - raise Exception("version not available from git or from file {!r}".format(version_file)) - - return file_ver - - -if __name__ == "__main__": - import sys - get_project_version(sys.argv[1]) -