diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53eaeeb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/specfile-*.tar.gz diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 0000000..0c8b732 --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,285 @@ +--- +packit_instances: ["prod", "stg"] + +upstream_project_url: https://github.com/packit/specfile +issue_repository: https://github.com/packit/specfile + +# PEP440 +prerelease_suffix_pattern: "([.\\-_]?)(a(lpha)?|b(eta)?|r?c|pre(view)?)([.\\-_]?\\d+)?" +prerelease_suffix_macro: prerelease + +copy_upstream_release_description: true + +packages: + specfile: &specfile + upstream_package_name: specfile + downstream_package_name: python-specfile + specfile_path: &specfile_path fedora/python-specfile.spec + files_to_sync: + - *specfile_path + - .packit.yaml + - src: plans/ + dest: plans/ + - src: .fmf/ + dest: .fmf/ + srpm_build_deps: + - python3-build + - python3-setuptools_scm + actions: &actions + pre-sync: + - python3 plans/git_reference.py + create-archive: + - python3 -m build --sdist --outdir ./fedora/ + - bash -c "ls -1t ./fedora/*.tar.gz | head -n 1" + get-current-version: python3 -m setuptools_scm + + specfile-epel8: + <<: *specfile + specfile_path: &specfile_path_epel8 epel8/python-specfile.spec + files_to_sync: + - *specfile_path_epel8 + - .packit.yaml + - src: plans/ + dest: plans/ + - src: .fmf/ + dest: .fmf/ + actions: + <<: *actions + create-archive: + - python3 setup.py sdist --dist-dir ./epel8/ + - bash -c "ls -1t ./epel8/*.tar.gz | head -n 1" + + specfile-epel10: + <<: *specfile + specfile_path: &specfile_path_epel10 epel10/python-specfile.spec + files_to_sync: + - *specfile_path_epel10 + - .packit.yaml + - src: plans/ + dest: plans/ + - src: .fmf/ + dest: .fmf/ + actions: + <<: *actions + create-archive: + - python3 setup.py sdist --dist-dir ./epel10/ + - bash -c "ls -1t ./epel10/*.tar.gz | head -n 1" + + # docs: https://gitlab.com/CentOS/Integration/packit-cbs/docs + specfile-centos-integration-sig: + <<: *specfile + specfile_path: &specfile_path_centos_sig centos-integration-sig/python-specfile.spec + files_to_sync: + - *specfile_path_centos_sig + - .packit.yaml + - src: plans/ + dest: plans/ + - src: .fmf/ + dest: .fmf/ + actions: + <<: *actions + create-archive: + - python3 -m build --sdist --outdir ./centos-integration-sig/ + - bash -c "ls -1t ./centos-integration-sig/*.tar.gz | head -n 1" + dist_git_base_url: https://gitlab.com + dist_git_namespace: CentOS/Integration/packit-cbs/rpms + sig: Integration/packit-cbs + pkg_tool: centpkg-sig + +jobs: + - &copr_build_pr + job: copr_build + trigger: pull_request + packages: [specfile] + targets: + - fedora-all + - fedora-all-aarch64 + - epel-9 + - <<: *copr_build_pr + packages: [specfile-epel8] + targets: + - epel-8 + - <<: *copr_build_pr + packages: [specfile-epel10] + targets: + - epel-10-all + + - &copr_build_commit_main + job: copr_build + trigger: commit + branch: main + packages: [specfile] + targets: + - fedora-all + - fedora-all-aarch64 + - epel-9 + project: packit-dev + list_on_homepage: True + preserve_project: True + - <<: *copr_build_commit_main + packages: [specfile-epel8] + targets: + - epel-8 + - <<: *copr_build_commit_main + packages: [specfile-epel10] + targets: + - epel-10-all + + - &copr_build_commit_stable + job: copr_build + trigger: commit + branch: stable + packages: [specfile] + targets: + - fedora-stable + - fedora-stable-aarch64 + project: packit-stable + list_on_homepage: True + preserve_project: True + + - &copr_build_release + job: copr_build + trigger: release + packages: [specfile] + targets: + - fedora-all + - fedora-all-aarch64 + - epel-9 + project: packit-releases + list_on_homepage: True + preserve_project: True + - <<: *copr_build_release + packages: [specfile-epel8] + targets: + - epel-8 + - <<: *copr_build_release + packages: [specfile-epel10] + targets: + - epel-10-all + + - &tests + job: tests + trigger: pull_request + packages: [specfile] + tmt_plan: "smoke|full|packit-integration" + targets: + - fedora-all + - epel-9 + - <<: *tests + identifier: performance + tmt_plan: performance + targets: + - fedora-rawhide + - <<: *tests + packages: [specfile-epel8] + tmt_plan: "smoke|full" + use_internal_tf: true + targets: + epel-8-x86_64: + distros: [RHEL-8.10.0-Nightly] + # enable EPEL + tf_extra_params: + environments: + - kickstart: + post-install: | + %post --log=/dev/console + set -x + dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm + %end + - <<: *tests + packages: [specfile-epel10] + tmt_plan: "smoke|full" + targets: + - epel-10-all + + - &propose_downstream + job: propose_downstream + trigger: release + packages: [specfile] + dist_git_branches: + rawhide: + fast_forward_merge_into: + - fedora-branched + epel-9: {} + - <<: *propose_downstream + packages: [specfile-epel8] + dist_git_branches: + - epel-8 + - <<: *propose_downstream + packages: [specfile-epel10] + dist_git_branches: + epel-10: + fast_forward_merge_into: + - epel-10-branched + - <<: *propose_downstream + packages: [specfile-centos-integration-sig] + dist_git_branches: + - c9-sig-integration + + - &pull_from_upstream + job: pull_from_upstream + trigger: release + packages: [specfile] + dist_git_branches: + rawhide: + fast_forward_merge_into: + - fedora-branched + epel-9: {} + - <<: *pull_from_upstream + packages: [specfile-epel8] + dist_git_branches: + - epel-8 + - <<: *pull_from_upstream + packages: [specfile-epel10] + dist_git_branches: + epel-10: + fast_forward_merge_into: + - epel-10-branched + - <<: *pull_from_upstream + packages: [specfile-centos-integration-sig] + dist_git_branches: + - c9-sig-integration + + - &koji_build + job: koji_build + trigger: commit + packages: [specfile] + packit_instances: ["stg"] + allowed_pr_authors: ["packit-stg", "packit"] + dist_git_branches: + - epel-9 + - <<: *koji_build + packages: [specfile-epel8] + dist_git_branches: + - epel-8 + - <<: *koji_build + packages: [specfile-epel10] + dist_git_branches: + - epel-10-all + - <<: *koji_build + packages: [specfile-centos-integration-sig] + dist_git_branches: + - c9-sig-integration + - <<: *koji_build + sidetag_group: packit-specfile-ogr-releases + dependents: + - packit + dist_git_branches: + - fedora-all + + - &bodhi_update + job: bodhi_update + trigger: commit + packages: [specfile] + packit_instances: ["stg"] + allowed_builders: ["packit-stg", "packit"] + dist_git_branches: + - epel-9 + - <<: *bodhi_update + packages: [specfile-epel8] + dist_git_branches: + - epel-8 + - <<: *bodhi_update + packages: [specfile-epel10] + dist_git_branches: + - epel-10-all diff --git a/README.packit b/README.packit new file mode 100644 index 0000000..fb341a1 --- /dev/null +++ b/README.packit @@ -0,0 +1,3 @@ +This repository is maintained by packit. +https://packit.dev/ +The file was generated using packit 1.11.0.post1.dev7+gfdcdf3a32. diff --git a/plans/full.fmf b/plans/full.fmf new file mode 100644 index 0000000..dc00841 --- /dev/null +++ b/plans/full.fmf @@ -0,0 +1,18 @@ +summary: + Unit & integration tests +discover+: + filter: tier:1 +adjust: + - when: "distro == rhel-8" + because: "only platform-python is installed on RHEL 8 by default" + prepare+: + - how: install + package: python3 + + - when: "distro == rhel-10 or distro == centos-10 or distro == centos-stream-10" + because: "flexmock is not in EPEL 10: https://bugzilla.redhat.com/show_bug.cgi?id=2351835" + prepare+: + - how: install + package: python3-pip + - how: shell + script: pip3 install flexmock diff --git a/plans/git_reference.py b/plans/git_reference.py new file mode 100644 index 0000000..fe4e906 --- /dev/null +++ b/plans/git_reference.py @@ -0,0 +1,32 @@ +#!/usr/bin/python + +# Copyright Contributors to the Packit project. +# SPDX-License-Identifier: MIT + +import subprocess +from pathlib import Path + +import fmf + +# Set discover of specfile tests to a fixed commit +tree_root = Path.cwd().absolute() +tree = fmf.Tree(tree_root) +main_node = tree.find("/plans") +with main_node as data: + data["discover"]["url"] = "https://github.com/packit/specfile.git" + data["discover"]["ref"] = ( + subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip() + ) + + +# Set discover of packit integration tests to the current main +packit_node = tree.find("/plans/packit-integration") +with packit_node as data: + data["discover"]["ref"] = ( + subprocess.check_output( + ["git", "ls-remote", "https://github.com/packit/packit", "main"] + ) + .decode() + .strip() + .split()[0] + ) diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 0000000..94e3a90 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,6 @@ +discover: + how: fmf + url: https://github.com/packit/specfile.git + ref: 21a45baa7c1ca166485b48e98069baad7ca1b99e +execute: + how: tmt diff --git a/plans/packit-integration.fmf b/plans/packit-integration.fmf new file mode 100644 index 0000000..ea56a89 --- /dev/null +++ b/plans/packit-integration.fmf @@ -0,0 +1,29 @@ +discover: + how: fmf + url: https://github.com/packit/packit + filter: tag:full + ref: dbe235f913d74de4e1fb8175a14ca0e0f17a15e4 +prepare: + - how: install + copr: packit/packit-dev + - how: shell + script: sed -i -n '/^priority=/!p;$apriority=5' + /etc/yum.repos.d/*:packit:packit-dev.repo +adjust: + - when: how == integration + because: provide latest python-specfile rpm when running locally + prepare+: + - name: python3-specfile rpm + how: install + directory: noarch/ + - when: distro == rhel-9 or distro == centos-9 or distro == centos-stream-9 + because: 'build and deepdiff are not in EPEL 9: https://bugzilla.redhat.com/show_bug.cgi?id=2120251' + prepare+: + - how: install + package: python3-pip + - how: shell + script: pip3 install build 'deepdiff < 8.0.0' + - when: | + distro == rhel-8 or distro == centos-8 or distro == centos-stream-8 or distro == rhel-9 or distro == centos-9 or distro == centos-stream-9 + because: packit doesn't support EL 8 + enabled: false diff --git a/plans/performance.fmf b/plans/performance.fmf new file mode 100644 index 0000000..341d17e --- /dev/null +++ b/plans/performance.fmf @@ -0,0 +1,15 @@ +summary: + Performance tests +discover+: + filter: tier:3 +prepare: + - how: install + package: python3-pip + - how: shell + script: pip3 install pytest-fail-slow + - how: shell + script: curl --output-dir /tmp -O https://src.fedoraproject.org/rpms/texlive/raw/rawhide/f/texlive.spec +adjust: + - when: "initiator != packit" + because: "skip this plan on dist-git pull requests" + enabled: false diff --git a/plans/smoke.fmf b/plans/smoke.fmf new file mode 100644 index 0000000..059ee80 --- /dev/null +++ b/plans/smoke.fmf @@ -0,0 +1,10 @@ +summary: + Basic smoke test +discover+: + filter: tier:0 +adjust: + - when: "distro == rhel-8" + because: "only platform-python is installed on RHEL 8 by default" + prepare+: + - how: install + package: python3 diff --git a/python-specfile.spec b/python-specfile.spec new file mode 100644 index 0000000..c3fc0ef --- /dev/null +++ b/python-specfile.spec @@ -0,0 +1,95 @@ +%bcond_with tests + + +%global desc %{expand: +Python library for parsing and manipulating RPM spec files. +Main focus is on modifying existing spec files, any change should result +in a minimal diff.} + + +%global base_version 0.37.1 +#global prerelease rc1 + +%global package_version %{base_version}%{?prerelease:~%{prerelease}} +%global pypi_version %{base_version}%{?prerelease} + + +Name: python-specfile +Version: %{package_version} +Release: 1%{?dist} + +Summary: A library for parsing and manipulating RPM spec files +License: MIT +URL: https://github.com/packit/specfile + +Source0: %{pypi_source specfile %{pypi_version}} + +BuildArch: noarch + +BuildRequires: python3-devel +%if %{with tests} +# tests/unit/test_guess_packager.py +BuildRequires: git-core +%endif + + +%description +%{desc} + + +%package -n python%{python3_pkgversion}-specfile +Summary: %{summary} + + +%description -n python%{python3_pkgversion}-specfile +%{desc} + + +%prep +%autosetup -p1 -n specfile-%{pypi_version} + +# since we are building from PyPI source, we don't need git-archive +# support in setuptools_scm +sed -i 's/setuptools_scm\[toml\]>=7/setuptools_scm[toml]/' pyproject.toml + + +%generate_buildrequires +%pyproject_buildrequires %{?with_tests: -x testing} + + +%build +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files specfile + + +%if %{with tests} +%check +%pytest --verbose tests/unit tests/integration +%endif + + +%files -n python%{python3_pkgversion}-specfile -f %{pyproject_files} +%doc README.md + + +%changelog +* Fri Oct 3 2025 Packit - 0.37.1-1 +- We have solved a FutureWarning in our codebase. (#485) + +* Fri Sep 5 2025 Packit - 0.37.0-1 +- Added support for Elbrus E2K CPU architectures. (#484) + +* Fri May 30 2025 Packit - 0.36.0-1 +- We have fixed a bug that caused specfile to traceback when section names with conditional macro expansions containing spaces were present in the spec file. (#476) + +* Sun Apr 13 2025 Packit - 0.35.0-1 +- Added support for creating Specfile instances from file objects and strings. (#458) +- The `context_management` type stubs now use `ParamSpec` from `typing_extensions` to support Python < 3.10. (#466) + +* Thu Mar 20 2025 Packit - 0.34.2-1 +- context_management: add a type stub override to fix typing. Type checkers like mypy and pyright can now correctly determine the types for `.sources()`, `.sections()`, and the other `Specfile` methods that return context managers. (#457) +- Resolves: rhbz#2344364 diff --git a/sources b/sources new file mode 100644 index 0000000..dbdd35e --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (specfile-0.37.1.tar.gz) = cd77cac206fc9cafc111c0f9c409dbbc8c250481e638b7bc1937c6d8bca5d03f0ccf711cbbb34bfde1f7912d417cb0381fe8aeef19c28d94afe068484ef2884d