From d2212f54e0b2aa6845d85d7405172e0a67fb2462 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Tue, 10 Sep 2024 19:49:35 +0200 Subject: [PATCH 01/16] Replace setup.py with pyproject.toml This commit will break copr builds for now. Also removes support for automatically generating man pages, since it is broken. --- dg | 8 ----- bin/dg => distgen/__main__.py | 0 pyproject.toml | 42 ++++++++++++++++++++++++ setup.cfg | 2 +- setup.py | 61 ----------------------------------- 5 files changed, 43 insertions(+), 70 deletions(-) delete mode 100755 dg rename bin/dg => distgen/__main__.py (100%) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/dg b/dg deleted file mode 100755 index 79eaa6e..0000000 --- a/dg +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -proj_cli_dir="$(dirname "$(readlink -f "$0")")" - -export PYTHON=${PYTHON:-`which python3`} -export PYTHONPATH="$proj_cli_dir${PYTHONPATH+:$PYTHONPATH}" - -$PYTHON $proj_cli_dir/bin/dg "$@" diff --git a/bin/dg b/distgen/__main__.py similarity index 100% rename from bin/dg rename to distgen/__main__.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8b268ce --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[build-system] +# requires = ["argparse-manpage[setuptools]"] +# build-backend = "setuptools.build_meta" +requires = ["setuptools>=58.5.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "distgen" +version = "1.19" +dependencies = [ + "distro", + "jinja2", + "pyyaml", + "setuptools" +] +requires-python = ">=3.0" +authors = [ + {name = "Pavel Raiskup", email = "praiskup@redhat.com"}, +] +maintainers = [ + {name = "Ales Nezbeda", email = "anezbeda@redhat.com"} +] +description = "Templating system/generator for distributions" +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)" +] + +# [tool.setuptools.cmdclass] +# build_py = "build_manpages.build_py" +# install = "build_manpages.install" +# build_manpages = "build_manpages.build_manpages" + +[project.scripts] +dg = "distgen.__main__:main" + +[tool.setuptools.packages.find] +where = ["."] +include = ['distgen*'] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 2b13372..c237029 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [build_manpages] manpages = - man/dg.1:object=parser:pyfile=distgen/cli_parser.py + man/dg.1:object=parser:pyfile=distgen/__main__.py [flake8] ignore= diff --git a/setup.py b/setup.py deleted file mode 100644 index 7d9408e..0000000 --- a/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys - -from setuptools import setup -from distgen.version import dg_version -from os import listdir, path, getcwd - -project = "distgen" -datadir = "share" -pkgdatadir = datadir + "/" + project -tpldir = pkgdatadir + "/templates" -distconfdir = pkgdatadir + "/distconf" - -from setuptools.command.build_py import build_py -from setuptools.command.install import install - -try: - sys.path = [path.join(getcwd(), 'build_manpages')] + sys.path - from build_manpages.build_manpages import ( - build_manpages, get_build_py_cmd, get_install_cmd) -except: - print("=======================================") - print("Use 'git submodule update --init' first") - print("=======================================") - raise - - -def get_requirements(): - with open('requirements.txt') as f: - return f.read().splitlines() - -def get_long_description(): - with open('README.md') as f: - return "\n".join(l for l in f.read().splitlines() if not l.startswith('[![')) - -setup( - name='distgen', - version=dg_version, - description='Templating system/generator for distributions', - long_description=get_long_description(), - long_description_content_type='text/markdown', - author='Pavel Raiskup (see AUTHORS)', - author_email='praiskup@redhat.com', - maintainer='Bohuslav Kabrda', - maintainer_email='bkabrda@redhat.com', - license='GPLv2+', - url='https://github.com/devexp-db/distgen', - platforms=['any'], - packages=['distgen'], - # this is bit impractical, but I see no better way to include subdirs properly - package_data={'distgen': - ['distconf/*.yaml', 'distconf/**/*.yaml', - 'templates/*.tpl', 'templates/**/*.tpl', 'templates/**/**/*.tpl'] - }, - scripts=['bin/dg'], - install_requires=get_requirements(), - cmdclass={ - 'build_manpages': build_manpages, - 'build_py': get_build_py_cmd(build_py), - 'install': get_install_cmd(install), - }, -) From 9ffb96dbb372926e59a610bf645714d161ac9a69 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Wed, 11 Sep 2024 17:19:29 +0200 Subject: [PATCH 02/16] Add support for automatic manpage generation --- distgen/cli_parser.py | 32 ++++++++++++++++++-------------- pyproject.toml | 21 +++++++++++++-------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/distgen/cli_parser.py b/distgen/cli_parser.py index d83c214..7cc4738 100644 --- a/distgen/cli_parser.py +++ b/distgen/cli_parser.py @@ -1,27 +1,31 @@ -""" -Separated argument parser. This makes the manual page generator happy because -we don't need any other dependencies installed at build-time. See #149. -""" - from argparse import ArgumentParser, RawDescriptionHelpFormatter -from distgen.version import dg_version +from importlib.metadata import version, PackageNotFoundError + +try: + version = version("distgen") +except PackageNotFoundError: + # package is not installed, due to this file being used by manpage generator + # we have to check for this, we do not need valid version during manpage + # generation, but it will crash + version = 0 + pass -DESCRIPTION = """\ +description = \ + """ Generate script using predefined metadata about distribution and templates. As an example of 'dg' usage, to generate _Dockerfile_ for Fedora 21 64-bit system, you may use command(s): - $ cd project/directory - $ dg --spec docker-data.yaml \\ - --template docker.tpl -""" +$ cd project/directory +$ dg --spec docker-data.yaml \\ +--template docker.tpl + """ parser = ArgumentParser( - prog='dg', - description=DESCRIPTION, + description=description, formatter_class=RawDescriptionHelpFormatter, ) @@ -31,7 +35,7 @@ parser.add_argument( '--version', action='version', - version=f"dg (distgen) {dg_version}", + version="dg (distgen) {0}".format(version) ) parser.add_argument( diff --git a/pyproject.toml b/pyproject.toml index 8b268ce..c5a74f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [build-system] -# requires = ["argparse-manpage[setuptools]"] -# build-backend = "setuptools.build_meta" -requires = ["setuptools>=58.5.0"] +requires = ["argparse-manpage[setuptools]"] build-backend = "setuptools.build_meta" +# requires = ["setuptools>=58.5.0"] +# build-backend = "setuptools.build_meta" [project] name = "distgen" @@ -29,14 +29,19 @@ classifiers = [ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)" ] -# [tool.setuptools.cmdclass] -# build_py = "build_manpages.build_py" -# install = "build_manpages.install" -# build_manpages = "build_manpages.build_manpages" +[tool.setuptools.cmdclass] +build_py = "build_manpages.build_py" +install = "build_manpages.install" +build_manpages = "build_manpages.build_manpages" [project.scripts] dg = "distgen.__main__:main" [tool.setuptools.packages.find] where = ["."] -include = ['distgen*'] \ No newline at end of file +include = ['distgen*', 'man*'] + +[tool.build_manpages] +manpages = [ + "man/dg.1:object=parser:pyfile=distgen/cli_parser.py", +] \ No newline at end of file From f20745b503678880dffb80fe75a2a87263bc7501 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Wed, 11 Sep 2024 17:20:52 +0200 Subject: [PATCH 03/16] Cleanup, use version from pyproject.toml in all other places --- .readthedocs.yaml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 11 ----------- config.yaml | 15 --------------- distgen/version.py | 1 - docs/conf.py | 12 +++++------- setup.cfg | 7 ++----- 6 files changed, 42 insertions(+), 39 deletions(-) create mode 100644 .readthedocs.yaml delete mode 100644 Dockerfile delete mode 100644 config.yaml delete mode 100644 distgen/version.py diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..124910a --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.12" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +# python: +# install: +# - requirements: docs/requirements.txt \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3388207..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM fedora:26 -LABEL maintainer="bkabrda@redhat.com" - -RUN mkdir -p /var/dgdir -WORKDIR /var/dgdir - -RUN dnf install python3-pip && dnf clean all -COPY . /tmp/distgen -RUN cd /tmp/distgen && pip3 install . - -ENTRYPOINT ["/usr/bin/dg"] diff --git a/config.yaml b/config.yaml deleted file mode 100644 index 3ddb7a5..0000000 --- a/config.yaml +++ /dev/null @@ -1,15 +0,0 @@ -default: - commands: - pkginstall: - pkgs: - - postgresql-server - pkgreinstall: - pkgs: - - glibc-common - -distros: - fedora: - 20: - pkginstall: - rhel: - diff --git a/distgen/version.py b/distgen/version.py deleted file mode 100644 index 595d2eb..0000000 --- a/distgen/version.py +++ /dev/null @@ -1 +0,0 @@ -dg_version = "1.18" diff --git a/docs/conf.py b/docs/conf.py index 9fc7c0c..19f40fe 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,9 +18,10 @@ # import os import sys -sys.path.insert(0, os.path.abspath('..')) -from distgen.version import dg_version +from importlib.metadata import version as get_version + +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ @@ -56,9 +57,9 @@ # built documents. # # The short X.Y version. -version = dg_version +version = get_version("distgen") # The full version, including alpha/beta/rc tags. -release = dg_version +release = get_version("distgen") # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -169,6 +170,3 @@ author, 'distgen', 'One line description of project.', 'Miscellaneous'), ] - - - diff --git a/setup.cfg b/setup.cfg index c237029..acd96a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,6 @@ -[build_manpages] -manpages = - man/dg.1:object=parser:pyfile=distgen/__main__.py - [flake8] ignore= # E402 module level import not at top of file - E402 + E402, + C0116 max-complexity=15 From c7a294b23d4d481b866ea058698a562f624f9fa4 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Thu, 12 Sep 2024 15:43:06 +0200 Subject: [PATCH 04/16] Packaging preparations Change copr scripts and templated spec file --- .github/workflows/copr/copr-build-setup | 4 +-- .github/workflows/copr/copr-custom-script | 1 + .github/workflows/pypi-publish.yml | 11 +++--- AUTHORS | 5 +-- README.md | 3 +- distgen/cli_parser.py | 1 + pyproject.toml | 2 +- requirements.txt | 3 +- rpm/Makefile | 8 ++--- rpm/distgen.spec.dg | 43 ++++++----------------- 10 files changed, 33 insertions(+), 48 deletions(-) diff --git a/.github/workflows/copr/copr-build-setup b/.github/workflows/copr/copr-build-setup index b5b0510..610a8fb 100755 --- a/.github/workflows/copr/copr-build-setup +++ b/.github/workflows/copr/copr-build-setup @@ -11,10 +11,10 @@ PROJECT_PR=praiskup/distgen build_deps=( git - distgen make python3 - python3-setuptools + python3-pip + python3-build ) for PROJECT in $PROJECT_PR $PROJECT_PUSH; do diff --git a/.github/workflows/copr/copr-custom-script b/.github/workflows/copr/copr-custom-script index b5298bc..a076f5b 100644 --- a/.github/workflows/copr/copr-custom-script +++ b/.github/workflows/copr/copr-custom-script @@ -42,5 +42,6 @@ else RELEASE="PR${3}_${date}_git$short_commit" fi +python3 -m pip install . --user cd rpm make RELEASE="$RELEASE" diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 49d6c9b..064000e 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -19,16 +19,19 @@ jobs: id-token: write # for trusted publishing steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" - name: Build a source tarball and a binary wheel # https://pypa-build.readthedocs.io run: | - python -m pip install -r requirements.txt - python setup.py sdist + python3 -m pip install build --user + python3 -m build - name: Publish 📦 to PyPI # https://github.com/pypa/gh-action-pypi-publish diff --git a/AUTHORS b/AUTHORS index ef3be05..83e4649 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ -Main contributors (alphabetical) +Main contributors -------------------------------- Pavel Raiskup (original author) -Slávek Kabrda (current maintainer) +Ales Nezbeda (current maintainer) +Slávek Kabrda Tomáš Tomeček diff --git a/README.md b/README.md index 38004eb..98b23ef 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Distribution oriented templating system ======================================= -[![Build Status](https://travis-ci.org/devexp-db/distgen.svg?branch=master)](https://travis-ci.org/devexp-db/distgen) +[![Copr package](https://copr.fedorainfracloud.org/coprs/praiskup/distgen/package/distgen/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/praiskup/distgen/) +[![Fedora package](https://img.shields.io/fedora/v/distgen)](https://packages.fedoraproject.org/pkgs/distgen/distgen/) [![Coverage Status](https://coveralls.io/repos/github/devexp-db/distgen/badge.svg)](https://coveralls.io/github/devexp-db/distgen) [![Documentation Status](https://readthedocs.org/projects/distgen/badge/?version=latest)](https://distgen.readthedocs.io) diff --git a/distgen/cli_parser.py b/distgen/cli_parser.py index 7cc4738..e99c72d 100644 --- a/distgen/cli_parser.py +++ b/distgen/cli_parser.py @@ -25,6 +25,7 @@ """ parser = ArgumentParser( + prog='dg', description=description, formatter_class=RawDescriptionHelpFormatter, ) diff --git a/pyproject.toml b/pyproject.toml index c5a74f7..7f7b7cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dg = "distgen.__main__:main" [tool.setuptools.packages.find] where = ["."] -include = ['distgen*', 'man*'] +include = ['distgen*'] [tool.build_manpages] manpages = [ diff --git a/requirements.txt b/requirements.txt index a318f8f..cb59127 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ distro jinja2 pyyaml -setuptools \ No newline at end of file +setuptools +build \ No newline at end of file diff --git a/rpm/Makefile b/rpm/Makefile index f50e6c4..38fc5bf 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -1,6 +1,6 @@ PROJECT = distgen PYTHON := python3 -VERSION := $(shell cd .. ; $(PYTHON) setup.py --version) +VERSION := $(shell python3 -m distgen --version | grep -o '[0-9]*\.[0-9]*') RELEASE := 1 git_rev = \ @@ -23,16 +23,14 @@ spec = $(PROJECT).spec all: $(spec) $(tarball) $(spec): $(PROJECT).spec.dg - PYTHON="$(PYTHON)" \ - ../dg --template $< \ + $(PYTHON) -m distgen --template $< \ --distro fedora-rawhide-x86_64 \ --macro "VERSION $(VERSION)" \ --macro "RELEASE $(RELEASE)" \ --output $@ $(tarball): - rm -rf $(tarball) - cd .. && $(PYTHON) setup.py sdist --dist-dir rpm + python -m build -o . .. srpm: $(spec) $(tarball) rm -rf *.src.rpm diff --git a/rpm/distgen.spec.dg b/rpm/distgen.spec.dg index 73a8ea3..d899258 100644 --- a/rpm/distgen.spec.dg +++ b/rpm/distgen.spec.dg @@ -1,17 +1,5 @@ # vim: ft=spec -%global pybin %{?fedora:%{__python3}}%{!?fedora:%{__python2}} -%global pylib %{?fedora:%{python3_sitelib}}%{!?fedora:%{python2_sitelib}} -%global pypkg %{?fedora:python3}%{!?fedora:python} -%global meh_pypkg %{?fedora:%{pypkg}-} - -%if 0%{?rhel} >= 8 -%global pybin %__python3 -%global pylib %python3_sitelib -%global pypkg python3 -%global meh_pypkg python3- -%endif - Name: distgen Summary: Templating system/generator for distributions @@ -25,17 +13,9 @@ Requires: %{pypkg}-jinja2 Requires: %{pypkg}-distro Requires: %{meh_pypkg}PyYAML -BuildRequires: make -BuildRequires: %{pypkg}-devel -BuildRequires: %{pypkg}-distro -BuildRequires: %{pypkg}-jinja2 -BuildRequires: %{meh_pypkg}pytest -%if 0%{?rhel} && 0%{?rhel} < 8 -BuildRequires: %{pypkg}-mock -BuildRequires: %{pypkg}-pytest-catchlog -%endif -BuildRequires: %{meh_pypkg}PyYAML -BuildRequires: %{pypkg}-setuptools +BuildRequires: python3-devel +BuildRequires: pyproject-rpm-macros +BuildRequires: python3-pytest Source0: https://pypi.org/packages/source/d/%name/%name-%version.tar.gz @@ -47,29 +27,28 @@ file and preexisting distribution metadata generate output file. %prep %autosetup -p1 +%generate_buildrequires +%pyproject_buildrequires -x pytest,pytest-catchlog,pytest-cov,coverage,flake8 + %build -%{pybin} setup.py build +%pyproject_wheel %install -%{pybin} setup.py install --root=%{buildroot} -mkdir -p %{buildroot}%{_datadir}/distgen -mv %{buildroot}%{pylib}/distgen/{distconf,templates} %{buildroot}%{_datadir}/distgen +%pyproject_install +%pyproject_save_files distgen %check -make PYTHON=%{pybin} check +%pytest tests/unittests/ -%files +%files -f %{pyproject_files} %license LICENSE %doc AUTHORS NEWS %doc docs/ %{_bindir}/dg -%{pylib}/distgen -%{pylib}/%{name}-*.egg-info -%{_datadir}/%{name} %{_mandir}/man1/* From 3763cdb903ea42e0decbf8da7c46414700ac8e92 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Thu, 12 Sep 2024 17:00:42 +0200 Subject: [PATCH 05/16] Fixup MANIFEST.in file to include templates --- MANIFEST.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 73b97fe..1f9f03b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include AUTHORS -include dg include requirements.txt include LICENSE include Makefile @@ -11,3 +10,5 @@ include docs/Makefile recursive-include build_manpages *.py recursive-include tests *.exp *.py *.tpl *.yaml .gitkeep distros container_opt dg-opts recursive-include tests/unittests/fixtures * +recursive-include distgen/distconf * +recursive-include distgen/templates * \ No newline at end of file From 1d5cb0c5ab7454a6d7082d9469ada6c703d5ad6c Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Thu, 12 Sep 2024 17:23:48 +0200 Subject: [PATCH 06/16] Fix distgen template spec file --- rpm/distgen.spec.dg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rpm/distgen.spec.dg b/rpm/distgen.spec.dg index d899258..7f0aba0 100644 --- a/rpm/distgen.spec.dg +++ b/rpm/distgen.spec.dg @@ -9,10 +9,6 @@ License: GPLv2+ URL: https://github.com/devexp-db/distgen BuildArch: noarch -Requires: %{pypkg}-jinja2 -Requires: %{pypkg}-distro -Requires: %{meh_pypkg}PyYAML - BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: python3-pytest From f9b68266f2086628397ad87031e495b4745f8fa7 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Thu, 12 Sep 2024 17:36:39 +0200 Subject: [PATCH 07/16] Bump major version, add all authors and cleanup of unused script --- .github/workflows/copr/script | 32 -------------------------------- pyproject.toml | 5 ++++- 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100755 .github/workflows/copr/script diff --git a/.github/workflows/copr/script b/.github/workflows/copr/script deleted file mode 100755 index 7c12e2a..0000000 --- a/.github/workflows/copr/script +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/bash - -# Used by .travis.yml. - -set -e -if test -n "$COPR_BUILD"; then - curl -o copr-build https://raw.githubusercontent.com/praiskup/copr-ci-tooling/main/copr-travis-submit - export COPR_PR_WEBHOOK="https://copr.fedorainfracloud.org/webhooks/custom/18597/341df2dc-df8d-4d15-bded-cdd23ffdd077/distgen/" - exec bash copr-build -fi - -set -x - -test -n "$TRAVIS_PYTHON_VERSION" -case $TRAVIS_PYTHON_VERSION in - *-dev) TRAVIS_PYTHON_VERSION=${TRAVIS_PYTHON_VERSION%%-dev} ;; -esac -export PYTHON="python$TRAVIS_PYTHON_VERSION" - -make check \ - PYTHON="$PYTHON" \ - COVERAGE=true - -make test-sdist-check \ - PYTHON="$PYTHON" - -make test-git-archive-check \ - PYTHON="$PYTHON" - -make test-lint - -"$PYTHON" setup.py install --root "$PWD/i" diff --git a/pyproject.toml b/pyproject.toml index 7f7b7cb..57e1676 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "distgen" -version = "1.19" +version = "2.0" dependencies = [ "distro", "jinja2", @@ -16,6 +16,9 @@ dependencies = [ requires-python = ">=3.0" authors = [ {name = "Pavel Raiskup", email = "praiskup@redhat.com"}, + {name = "Slávek Kabrda", email = "bkabrda@redhat.com"}, + {name = "Tomáš Tomeček", email = "ttomecek@redhat.com"}, + {name = "Ales Nezbeda", email = "anezbeda@redhat.com"}, ] maintainers = [ {name = "Ales Nezbeda", email = "anezbeda@redhat.com"} From 9f900ae4be57bdfbc4aca67b5cc497612436c133 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Thu, 12 Sep 2024 18:44:10 +0200 Subject: [PATCH 08/16] Fix Makefile to use `PYTHON` variable in RPM build --- rpm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpm/Makefile b/rpm/Makefile index 38fc5bf..8f841f8 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -30,7 +30,7 @@ $(spec): $(PROJECT).spec.dg --output $@ $(tarball): - python -m build -o . .. + $(PYTHON) -m build -o . .. srpm: $(spec) $(tarball) rm -rf *.src.rpm From a86c30a18fe1645f70cb669da067f4bf5a786856 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Fri, 13 Sep 2024 11:50:05 +0200 Subject: [PATCH 09/16] Replace authors by whole Red Hat team and keep specific maintainer only --- AUTHORS | 6 ------ pyproject.toml | 5 +---- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 83e4649..0000000 --- a/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -Main contributors --------------------------------- -Pavel Raiskup (original author) -Ales Nezbeda (current maintainer) -Slávek Kabrda -Tomáš Tomeček diff --git a/pyproject.toml b/pyproject.toml index 57e1676..dad2176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,7 @@ dependencies = [ ] requires-python = ">=3.0" authors = [ - {name = "Pavel Raiskup", email = "praiskup@redhat.com"}, - {name = "Slávek Kabrda", email = "bkabrda@redhat.com"}, - {name = "Tomáš Tomeček", email = "ttomecek@redhat.com"}, - {name = "Ales Nezbeda", email = "anezbeda@redhat.com"}, + {name = "Red Hat Databases team"}, ] maintainers = [ {name = "Ales Nezbeda", email = "anezbeda@redhat.com"} From 4dffb5898dde146255eef95cee9e21e7e09b4317 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Fri, 13 Sep 2024 11:50:42 +0200 Subject: [PATCH 10/16] Remove support for different python version from RPM Makefile --- rpm/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rpm/Makefile b/rpm/Makefile index 8f841f8..5eda13f 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -1,5 +1,4 @@ PROJECT = distgen -PYTHON := python3 VERSION := $(shell python3 -m distgen --version | grep -o '[0-9]*\.[0-9]*') RELEASE := 1 @@ -23,14 +22,14 @@ spec = $(PROJECT).spec all: $(spec) $(tarball) $(spec): $(PROJECT).spec.dg - $(PYTHON) -m distgen --template $< \ + python3 -m distgen --template $< \ --distro fedora-rawhide-x86_64 \ --macro "VERSION $(VERSION)" \ --macro "RELEASE $(RELEASE)" \ --output $@ $(tarball): - $(PYTHON) -m build -o . .. + python3 -m build -o . .. srpm: $(spec) $(tarball) rm -rf *.src.rpm From 55a2899047e86460876a4b0dbc9f11f59946a661 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Fri, 13 Sep 2024 14:17:31 +0200 Subject: [PATCH 11/16] Fix few simple linting errors --- distgen/__main__.py | 2 ++ distgen/cli_parser.py | 13 +++++++------ pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/distgen/__main__.py b/distgen/__main__.py index 2124c5a..fc1e5c2 100755 --- a/distgen/__main__.py +++ b/distgen/__main__.py @@ -1,5 +1,7 @@ #!/bin/python +"""Main entrypoint for distgen. This module handles CLI interface""" + from __future__ import print_function import os diff --git a/distgen/cli_parser.py b/distgen/cli_parser.py index e99c72d..676f1ac 100644 --- a/distgen/cli_parser.py +++ b/distgen/cli_parser.py @@ -1,17 +1,18 @@ +"""Module providing an ArgumentParser object to be used by CLI interface.""" + from argparse import ArgumentParser, RawDescriptionHelpFormatter from importlib.metadata import version, PackageNotFoundError try: - version = version("distgen") + VERSION = version("distgen") except PackageNotFoundError: # package is not installed, due to this file being used by manpage generator # we have to check for this, we do not need valid version during manpage # generation, but it will crash - version = 0 - pass + VERSION = 0 -description = \ +DESCRIPTION = \ """ Generate script using predefined metadata about distribution and templates. @@ -26,7 +27,7 @@ parser = ArgumentParser( prog='dg', - description=description, + description=DESCRIPTION, formatter_class=RawDescriptionHelpFormatter, ) @@ -36,7 +37,7 @@ parser.add_argument( '--version', action='version', - version="dg (distgen) {0}".format(version) + version=f"dg (distgen) {VERSION}" ) parser.add_argument( diff --git a/pyproject.toml b/pyproject.toml index dad2176..28652c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,4 +44,4 @@ include = ['distgen*'] [tool.build_manpages] manpages = [ "man/dg.1:object=parser:pyfile=distgen/cli_parser.py", -] \ No newline at end of file +] From acad2633a2f6a4e819ebae8cb42b4e06e71f8005 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Fri, 13 Sep 2024 14:21:14 +0200 Subject: [PATCH 12/16] Add changelog entry Also inform about module API change - removed version file --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 79c6c10..f4caa0b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,13 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +New in 2.0: + +* Complete rewrite of buildsystem to use pyproject.toml +* This removes version file from distgen package + - Use `version()` from `importlib.metadata` instead + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + New in 1.18: * Added support for Fedora 40, 41, 42 From d5108045c93138e5e0228754219a40f55859ddce Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Fri, 13 Sep 2024 16:25:44 +0200 Subject: [PATCH 13/16] Remove AUTHOR file from RPM template --- rpm/distgen.spec.dg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpm/distgen.spec.dg b/rpm/distgen.spec.dg index 7f0aba0..aeb8640 100644 --- a/rpm/distgen.spec.dg +++ b/rpm/distgen.spec.dg @@ -42,7 +42,7 @@ file and preexisting distribution metadata generate output file. %files -f %{pyproject_files} %license LICENSE -%doc AUTHORS NEWS +%doc NEWS %doc docs/ %{_bindir}/dg %{_mandir}/man1/* From 8b7488f36d4707c110e406095a72809ce7e35d98 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Tue, 17 Sep 2024 12:35:34 +0200 Subject: [PATCH 14/16] Fix builds on EPELs due to outdated components Some of the new functionalities that are present in Fedora and are needed for distgen to build using the refreshed build system are not present in EPEL. This means that we have to rollback some changes to allow build on EPEL. This shouldn't impact functionality of the application, but keeping it in the main repository would create mess in the codebase. For that reason the rollbacks are handled by patches in spec file. --- ...-on-EPEL8-due-to-outdated-components.patch | 182 ++++++++++++++++++ ...-on-EPEL9-due-to-outdated-components.patch | 100 ++++++++++ rpm/distgen.spec.dg | 68 ++++++- 3 files changed, 341 insertions(+), 9 deletions(-) create mode 100644 rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch create mode 100644 rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch diff --git a/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch b/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch new file mode 100644 index 0000000..764eff3 --- /dev/null +++ b/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch @@ -0,0 +1,182 @@ +From b4b3faaad0c1d7a3665b0a0709342267f2dc63e7 Mon Sep 17 00:00:00 2001 +From: Ales Nezbeda +Date: Tue, 17 Sep 2024 09:17:24 +0200 +Subject: [PATCH] Fix builds on EPEL8 due to outdated components + +Some of the new functionalities that are present in Fedora and are +needed for distgen to build using the refreshed build system are not +present in EPEL8. + +This means that we have to rollback some changes to allow build on +EPEL8. This shouldn't impact functionality of the application, but +keeping it in the main repository would create mess in the codebase. +It can also be unpredictable how will setuptools work with different +config files, so it's better to just use one config. +--- + distgen/cli_parser.py | 2 +- + pyproject.toml | 47 ------------------------------------------- + setup.cfg | 42 +++++++++++++++++++++++++++++++++++++- + setup.py | 31 ++++++++++++++++++++++++++++ + 4 files changed, 73 insertions(+), 49 deletions(-) + delete mode 100644 pyproject.toml + create mode 100644 setup.py + +diff --git a/distgen/cli_parser.py b/distgen/cli_parser.py +index 676f1ac..3040239 100644 +--- a/distgen/cli_parser.py ++++ b/distgen/cli_parser.py +@@ -2,7 +2,7 @@ + + from argparse import ArgumentParser, RawDescriptionHelpFormatter + +-from importlib.metadata import version, PackageNotFoundError ++from importlib_metadata import version, PackageNotFoundError + + try: + VERSION = version("distgen") +diff --git a/pyproject.toml b/pyproject.toml +deleted file mode 100644 +index 28652c5..0000000 +--- a/pyproject.toml ++++ /dev/null +@@ -1,47 +0,0 @@ +-[build-system] +-requires = ["argparse-manpage[setuptools]"] +-build-backend = "setuptools.build_meta" +-# requires = ["setuptools>=58.5.0"] +-# build-backend = "setuptools.build_meta" +- +-[project] +-name = "distgen" +-version = "2.0" +-dependencies = [ +- "distro", +- "jinja2", +- "pyyaml", +- "setuptools" +-] +-requires-python = ">=3.0" +-authors = [ +- {name = "Red Hat Databases team"}, +-] +-maintainers = [ +- {name = "Ales Nezbeda", email = "anezbeda@redhat.com"} +-] +-description = "Templating system/generator for distributions" +-readme = "README.md" +-license = {file = "LICENSE"} +-classifiers = [ +- "Development Status :: 5 - Production/Stable", +- "Programming Language :: Python :: 3", +- "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)" +-] +- +-[tool.setuptools.cmdclass] +-build_py = "build_manpages.build_py" +-install = "build_manpages.install" +-build_manpages = "build_manpages.build_manpages" +- +-[project.scripts] +-dg = "distgen.__main__:main" +- +-[tool.setuptools.packages.find] +-where = ["."] +-include = ['distgen*'] +- +-[tool.build_manpages] +-manpages = [ +- "man/dg.1:object=parser:pyfile=distgen/cli_parser.py", +-] +diff --git a/setup.cfg b/setup.cfg +index acd96a0..12ff987 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -1,8 +1,49 @@ ++[metadata] ++name = distgen ++version = 2.0 ++author = Red Hat Databases team ++description = Templating system/generator for distributions ++long_description = file: README.md ++license = GPLv2+ ++classifiers = ++ Development Status :: 5 - Production/Stable ++ Programming Language :: Python :: 3 ++ License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) ++ ++[options] ++include_package_data = True ++packages = find: ++python_requires = >=3.0 ++install_requires = ++ importlib-metadata ++ distro ++ jinja2 ++ pyyaml ++ setuptools ++ ++[options.package_data] ++distgen = distconf/*.yaml, distconf/**/*.yaml, templates/*.tpl, templates/**/*.tpl, templates/**/**/*.tpl ++ ++[options.packages.find] ++exclude = ++ rpm* ++ man* ++ build_manpages* ++ ++[options.entry_points] ++console_scripts = ++ dg = distgen.__main__:main ++ ++[build_manpages] ++manpages = ++ man/dg.1:object=parser:pyfile=distgen/cli_parser.py ++ + [flake8] +-ignore = +- E402, +- C0116 +-max-complexity = 15 ++ignore= ++ # E402 module level import not at top of file ++ E402, ++ C0116 ++max-complexity=15 + + [egg_info] + tag_build = +diff --git a/setup.py b/setup.py +new file mode 100644 +index 0000000..fe58d0a +--- /dev/null ++++ b/setup.py +@@ -0,0 +1,26 @@ ++import sys ++ ++from os import path, getcwd ++from setuptools import setup ++ ++from setuptools.command.build_py import build_py ++from setuptools.command.install import install ++ ++project = "distgen" ++datadir = "share" ++pkgdatadir = datadir + "/" + project ++tpldir = pkgdatadir + "/templates" ++distconfdir = pkgdatadir + "/distconf" ++ ++sys.path = [path.join(getcwd(), 'build_manpages')] + sys.path ++from build_manpages.build_manpages import ( ++ build_manpages, get_build_py_cmd, get_install_cmd) ++ ++setup( ++ cmdclass={ ++ 'build_manpages': build_manpages, ++ 'build_py': get_build_py_cmd(build_py), ++ 'install': get_install_cmd(install), ++ }, ++) ++ +-- +2.46.0 + diff --git a/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch b/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch new file mode 100644 index 0000000..f581cf9 --- /dev/null +++ b/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch @@ -0,0 +1,100 @@ +From 59ad66a9f1d94e8fc6ef0cf34293ca7cd8ced590 Mon Sep 17 00:00:00 2001 +From: Ales Nezbeda +Date: Tue, 17 Sep 2024 09:17:24 +0200 +Subject: [PATCH] Fix builds on EPEL9 due to outdated components + +Some of the new functionalities that are present in Fedora and are +needed for distgen to build using the refreshed build system are not +present in EPEL9. + +This means that we have to rollback some changes to allow build on +EPEL9. This shouldn't impact functionality of the application, but +keeping it in the main repository would create mess in the codebase. +It can also be unpredictable how will setuptools work with different +config files, so it's better to just use one config. +--- + setup.cfg | 36 ++++++++++++++++++++++++++++++++++++ + setup.py | 22 ++++++++++++++++++++++ + 2 files changed, 58 insertions(+) + create mode 100644 setup.py + +diff --git a/setup.cfg b/setup.cfg +index acd96a0..3151c89 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -1,8 +1,45 @@ ++[metadata] ++name = distgen ++version = 2.0 ++author = Red Hat Databases team ++description = Templating system/generator for distributions ++long_description = file: README.md ++license = GPLv2+ ++classifiers = ++ Development Status :: 5 - Production/Stable ++ Programming Language :: Python :: 3 ++ License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) ++ ++[options] ++setup_requires = ++ argparse-manpage[setuptools] ++include_package_data = True ++packages = find: ++python_requires = >=3.0 ++ ++[options.package_data] ++distgen = distconf/*.yaml, distconf/**/*.yaml, templates/*.tpl, templates/**/*.tpl, templates/**/**/*.tpl ++ ++[options.packages.find] ++exclude = ++ rpm* ++ man* ++ build_manpages* ++ ++[options.entry_points] ++console_scripts = ++ dg = distgen.__main__:main ++ ++[build_manpages] ++manpages = ++ man/dg.1:object=parser:pyfile=distgen/cli_parser.py ++ + [flake8] +-ignore = +- E402, +- C0116 +-max-complexity = 15 ++ignore= ++ # E402 module level import not at top of file ++ E402, ++ C0116 ++max-complexity=15 + + [egg_info] + tag_build = +diff --git a/setup.py b/setup.py +new file mode 100644 +index 0000000..ac2b9de +--- /dev/null ++++ b/setup.py +@@ -0,0 +1,17 @@ ++from setuptools import setup ++ ++from setuptools.command.build_py import build_py ++from setuptools.command.install import install ++ ++from build_manpages.build_manpages import build_manpages ++from build_manpages import get_build_py_cmd ++from build_manpages import get_install_cmd ++ ++setup( ++ cmdclass={ ++ 'build_manpages': build_manpages, ++ 'build_py': get_build_py_cmd(build_py), ++ 'install': get_install_cmd(install), ++ }, ++) ++ +-- +2.46.0 + diff --git a/rpm/distgen.spec.dg b/rpm/distgen.spec.dg index aeb8640..e11523b 100644 --- a/rpm/distgen.spec.dg +++ b/rpm/distgen.spec.dg @@ -10,43 +10,93 @@ URL: https://github.com/devexp-db/distgen BuildArch: noarch BuildRequires: python3-devel -BuildRequires: pyproject-rpm-macros BuildRequires: python3-pytest +%if 0%{?rhel} != 8 +BuildRequires: pyproject-rpm-macros +%endif + +%if 0%{?rhel} >= 8 +BuildRequires: python3-setuptools +BuildRequires: python3-tomli +BuildRequires: python3-jinja2 +BuildRequires: python3-PyYAML +BuildRequires: python3-distro +%endif + +%if 0%{?rhel} == 8 +BuildRequires: python3-importlib-metadata +%endif + Source0: https://pypi.org/packages/source/d/%name/%name-%version.tar.gz +Patch0: BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch +Patch1: BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch + %description Based on given template specification (configuration for template), template file and preexisting distribution metadata generate output file. - %prep -%autosetup -p1 +%autosetup -N + +%if 0%{?rhel} == 8 +%patch -p1 -P 0 +%endif + +%if 0%{?rhel} == 9 +%patch -p1 -P 1 +%endif -%generate_buildrequires -%pyproject_buildrequires -x pytest,pytest-catchlog,pytest-cov,coverage,flake8 +%if 0%{?rhel} != 8 +%generate_buildrequires +%pyproject_buildrequires -x pytest,pytest-catchlog,pytest-cov,coverage,flake8,pyyaml +%endif %build +%if 0%{?rhel} == 8 +ls -la +%__python3 setup.py build +%else %pyproject_wheel - +%endif %install +%if 0%{?rhel} == 8 +%__python3 setup.py install --root=%{buildroot} +mkdir -p %{buildroot}%{_datadir}/distgen +mv %{buildroot}%{python3_sitelib}/distgen/{distconf,templates} %{buildroot}%{_datadir}/distgen +%else %pyproject_install %pyproject_save_files distgen - +%endif %check +%if 0%{?rhel} == 8 +%__python3 -m pytest tests/unittests/ +%else %pytest tests/unittests/ +%endif - +%if 0%{?rhel} == 8 +%files +%license LICENSE +%doc NEWS +%doc docs/ +%{_bindir}/dg +%{python3_sitelib}/distgen +%{python3_sitelib}/%{name}-*.egg-info +%{_datadir}/%{name} +%{_mandir}/man1/* +%else %files -f %{pyproject_files} %license LICENSE %doc NEWS %doc docs/ %{_bindir}/dg %{_mandir}/man1/* - +%endif %changelog * Wed Mar 21 2018 Pavel Raiskup - {{ m.VERSION }}-{{ m.RELEASE }} From 92abd9043bd07bed15f271815d9f25158c1a8e98 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Tue, 17 Sep 2024 17:37:51 +0200 Subject: [PATCH 15/16] Revert "Fix builds on EPELs due to outdated components" This reverts commit a4b4aa9e60d0a03c4de0fbfd9e78b6ef2250628e. --- ...-on-EPEL8-due-to-outdated-components.patch | 182 ------------------ ...-on-EPEL9-due-to-outdated-components.patch | 100 ---------- rpm/distgen.spec.dg | 68 +------ 3 files changed, 9 insertions(+), 341 deletions(-) delete mode 100644 rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch delete mode 100644 rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch diff --git a/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch b/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch deleted file mode 100644 index 764eff3..0000000 --- a/rpm/BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch +++ /dev/null @@ -1,182 +0,0 @@ -From b4b3faaad0c1d7a3665b0a0709342267f2dc63e7 Mon Sep 17 00:00:00 2001 -From: Ales Nezbeda -Date: Tue, 17 Sep 2024 09:17:24 +0200 -Subject: [PATCH] Fix builds on EPEL8 due to outdated components - -Some of the new functionalities that are present in Fedora and are -needed for distgen to build using the refreshed build system are not -present in EPEL8. - -This means that we have to rollback some changes to allow build on -EPEL8. This shouldn't impact functionality of the application, but -keeping it in the main repository would create mess in the codebase. -It can also be unpredictable how will setuptools work with different -config files, so it's better to just use one config. ---- - distgen/cli_parser.py | 2 +- - pyproject.toml | 47 ------------------------------------------- - setup.cfg | 42 +++++++++++++++++++++++++++++++++++++- - setup.py | 31 ++++++++++++++++++++++++++++ - 4 files changed, 73 insertions(+), 49 deletions(-) - delete mode 100644 pyproject.toml - create mode 100644 setup.py - -diff --git a/distgen/cli_parser.py b/distgen/cli_parser.py -index 676f1ac..3040239 100644 ---- a/distgen/cli_parser.py -+++ b/distgen/cli_parser.py -@@ -2,7 +2,7 @@ - - from argparse import ArgumentParser, RawDescriptionHelpFormatter - --from importlib.metadata import version, PackageNotFoundError -+from importlib_metadata import version, PackageNotFoundError - - try: - VERSION = version("distgen") -diff --git a/pyproject.toml b/pyproject.toml -deleted file mode 100644 -index 28652c5..0000000 ---- a/pyproject.toml -+++ /dev/null -@@ -1,47 +0,0 @@ --[build-system] --requires = ["argparse-manpage[setuptools]"] --build-backend = "setuptools.build_meta" --# requires = ["setuptools>=58.5.0"] --# build-backend = "setuptools.build_meta" -- --[project] --name = "distgen" --version = "2.0" --dependencies = [ -- "distro", -- "jinja2", -- "pyyaml", -- "setuptools" --] --requires-python = ">=3.0" --authors = [ -- {name = "Red Hat Databases team"}, --] --maintainers = [ -- {name = "Ales Nezbeda", email = "anezbeda@redhat.com"} --] --description = "Templating system/generator for distributions" --readme = "README.md" --license = {file = "LICENSE"} --classifiers = [ -- "Development Status :: 5 - Production/Stable", -- "Programming Language :: Python :: 3", -- "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)" --] -- --[tool.setuptools.cmdclass] --build_py = "build_manpages.build_py" --install = "build_manpages.install" --build_manpages = "build_manpages.build_manpages" -- --[project.scripts] --dg = "distgen.__main__:main" -- --[tool.setuptools.packages.find] --where = ["."] --include = ['distgen*'] -- --[tool.build_manpages] --manpages = [ -- "man/dg.1:object=parser:pyfile=distgen/cli_parser.py", --] -diff --git a/setup.cfg b/setup.cfg -index acd96a0..12ff987 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -1,8 +1,49 @@ -+[metadata] -+name = distgen -+version = 2.0 -+author = Red Hat Databases team -+description = Templating system/generator for distributions -+long_description = file: README.md -+license = GPLv2+ -+classifiers = -+ Development Status :: 5 - Production/Stable -+ Programming Language :: Python :: 3 -+ License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) -+ -+[options] -+include_package_data = True -+packages = find: -+python_requires = >=3.0 -+install_requires = -+ importlib-metadata -+ distro -+ jinja2 -+ pyyaml -+ setuptools -+ -+[options.package_data] -+distgen = distconf/*.yaml, distconf/**/*.yaml, templates/*.tpl, templates/**/*.tpl, templates/**/**/*.tpl -+ -+[options.packages.find] -+exclude = -+ rpm* -+ man* -+ build_manpages* -+ -+[options.entry_points] -+console_scripts = -+ dg = distgen.__main__:main -+ -+[build_manpages] -+manpages = -+ man/dg.1:object=parser:pyfile=distgen/cli_parser.py -+ - [flake8] --ignore = -- E402, -- C0116 --max-complexity = 15 -+ignore= -+ # E402 module level import not at top of file -+ E402, -+ C0116 -+max-complexity=15 - - [egg_info] - tag_build = -diff --git a/setup.py b/setup.py -new file mode 100644 -index 0000000..fe58d0a ---- /dev/null -+++ b/setup.py -@@ -0,0 +1,26 @@ -+import sys -+ -+from os import path, getcwd -+from setuptools import setup -+ -+from setuptools.command.build_py import build_py -+from setuptools.command.install import install -+ -+project = "distgen" -+datadir = "share" -+pkgdatadir = datadir + "/" + project -+tpldir = pkgdatadir + "/templates" -+distconfdir = pkgdatadir + "/distconf" -+ -+sys.path = [path.join(getcwd(), 'build_manpages')] + sys.path -+from build_manpages.build_manpages import ( -+ build_manpages, get_build_py_cmd, get_install_cmd) -+ -+setup( -+ cmdclass={ -+ 'build_manpages': build_manpages, -+ 'build_py': get_build_py_cmd(build_py), -+ 'install': get_install_cmd(install), -+ }, -+) -+ --- -2.46.0 - diff --git a/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch b/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch deleted file mode 100644 index f581cf9..0000000 --- a/rpm/BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 59ad66a9f1d94e8fc6ef0cf34293ca7cd8ced590 Mon Sep 17 00:00:00 2001 -From: Ales Nezbeda -Date: Tue, 17 Sep 2024 09:17:24 +0200 -Subject: [PATCH] Fix builds on EPEL9 due to outdated components - -Some of the new functionalities that are present in Fedora and are -needed for distgen to build using the refreshed build system are not -present in EPEL9. - -This means that we have to rollback some changes to allow build on -EPEL9. This shouldn't impact functionality of the application, but -keeping it in the main repository would create mess in the codebase. -It can also be unpredictable how will setuptools work with different -config files, so it's better to just use one config. ---- - setup.cfg | 36 ++++++++++++++++++++++++++++++++++++ - setup.py | 22 ++++++++++++++++++++++ - 2 files changed, 58 insertions(+) - create mode 100644 setup.py - -diff --git a/setup.cfg b/setup.cfg -index acd96a0..3151c89 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -1,8 +1,45 @@ -+[metadata] -+name = distgen -+version = 2.0 -+author = Red Hat Databases team -+description = Templating system/generator for distributions -+long_description = file: README.md -+license = GPLv2+ -+classifiers = -+ Development Status :: 5 - Production/Stable -+ Programming Language :: Python :: 3 -+ License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) -+ -+[options] -+setup_requires = -+ argparse-manpage[setuptools] -+include_package_data = True -+packages = find: -+python_requires = >=3.0 -+ -+[options.package_data] -+distgen = distconf/*.yaml, distconf/**/*.yaml, templates/*.tpl, templates/**/*.tpl, templates/**/**/*.tpl -+ -+[options.packages.find] -+exclude = -+ rpm* -+ man* -+ build_manpages* -+ -+[options.entry_points] -+console_scripts = -+ dg = distgen.__main__:main -+ -+[build_manpages] -+manpages = -+ man/dg.1:object=parser:pyfile=distgen/cli_parser.py -+ - [flake8] --ignore = -- E402, -- C0116 --max-complexity = 15 -+ignore= -+ # E402 module level import not at top of file -+ E402, -+ C0116 -+max-complexity=15 - - [egg_info] - tag_build = -diff --git a/setup.py b/setup.py -new file mode 100644 -index 0000000..ac2b9de ---- /dev/null -+++ b/setup.py -@@ -0,0 +1,17 @@ -+from setuptools import setup -+ -+from setuptools.command.build_py import build_py -+from setuptools.command.install import install -+ -+from build_manpages.build_manpages import build_manpages -+from build_manpages import get_build_py_cmd -+from build_manpages import get_install_cmd -+ -+setup( -+ cmdclass={ -+ 'build_manpages': build_manpages, -+ 'build_py': get_build_py_cmd(build_py), -+ 'install': get_install_cmd(install), -+ }, -+) -+ --- -2.46.0 - diff --git a/rpm/distgen.spec.dg b/rpm/distgen.spec.dg index e11523b..aeb8640 100644 --- a/rpm/distgen.spec.dg +++ b/rpm/distgen.spec.dg @@ -10,93 +10,43 @@ URL: https://github.com/devexp-db/distgen BuildArch: noarch BuildRequires: python3-devel -BuildRequires: python3-pytest - -%if 0%{?rhel} != 8 BuildRequires: pyproject-rpm-macros -%endif - -%if 0%{?rhel} >= 8 -BuildRequires: python3-setuptools -BuildRequires: python3-tomli -BuildRequires: python3-jinja2 -BuildRequires: python3-PyYAML -BuildRequires: python3-distro -%endif - -%if 0%{?rhel} == 8 -BuildRequires: python3-importlib-metadata -%endif +BuildRequires: python3-pytest Source0: https://pypi.org/packages/source/d/%name/%name-%version.tar.gz -Patch0: BUILT-Fix-builds-on-EPEL8-due-to-outdated-components.patch -Patch1: BUILT-Fix-builds-on-EPEL9-due-to-outdated-components.patch - %description Based on given template specification (configuration for template), template file and preexisting distribution metadata generate output file. -%prep -%autosetup -N - -%if 0%{?rhel} == 8 -%patch -p1 -P 0 -%endif - -%if 0%{?rhel} == 9 -%patch -p1 -P 1 -%endif +%prep +%autosetup -p1 -%if 0%{?rhel} != 8 %generate_buildrequires -%pyproject_buildrequires -x pytest,pytest-catchlog,pytest-cov,coverage,flake8,pyyaml -%endif +%pyproject_buildrequires -x pytest,pytest-catchlog,pytest-cov,coverage,flake8 + %build -%if 0%{?rhel} == 8 -ls -la -%__python3 setup.py build -%else %pyproject_wheel -%endif + %install -%if 0%{?rhel} == 8 -%__python3 setup.py install --root=%{buildroot} -mkdir -p %{buildroot}%{_datadir}/distgen -mv %{buildroot}%{python3_sitelib}/distgen/{distconf,templates} %{buildroot}%{_datadir}/distgen -%else %pyproject_install %pyproject_save_files distgen -%endif + %check -%if 0%{?rhel} == 8 -%__python3 -m pytest tests/unittests/ -%else %pytest tests/unittests/ -%endif -%if 0%{?rhel} == 8 -%files -%license LICENSE -%doc NEWS -%doc docs/ -%{_bindir}/dg -%{python3_sitelib}/distgen -%{python3_sitelib}/%{name}-*.egg-info -%{_datadir}/%{name} -%{_mandir}/man1/* -%else + %files -f %{pyproject_files} %license LICENSE %doc NEWS %doc docs/ %{_bindir}/dg %{_mandir}/man1/* -%endif + %changelog * Wed Mar 21 2018 Pavel Raiskup - {{ m.VERSION }}-{{ m.RELEASE }} From cdb2ebf4f3a56feeb7da17a3531342cc6e564e19 Mon Sep 17 00:00:00 2001 From: Ales Nezbeda Date: Wed, 25 Sep 2024 14:28:14 +0200 Subject: [PATCH 16/16] Set required Python version correctly --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 28652c5..e90bb5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ "pyyaml", "setuptools" ] -requires-python = ">=3.0" +requires-python = ">=3.9" authors = [ {name = "Red Hat Databases team"}, ]