From 8b339aeb2e34b4b414dea84e5711ab1ff05dfdfd Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 28 May 2024 10:18:01 +0100 Subject: [PATCH] Fix packit configuration (#345) --- .config/python3-ansible-compat.spec | 66 +++++++++++++++++++++++++++++ .gitignore | 2 +- .packit.yaml | 9 ++-- tools/get-version.sh | 9 +++- tools/update-version.sh | 4 +- tox.ini | 2 +- 6 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 .config/python3-ansible-compat.spec diff --git a/.config/python3-ansible-compat.spec b/.config/python3-ansible-compat.spec new file mode 100644 index 00000000..362b563d --- /dev/null +++ b/.config/python3-ansible-compat.spec @@ -0,0 +1,66 @@ +# spell-checker:ignore bcond pkgversion buildrequires autosetup PYTHONPATH noarch buildroot bindir sitelib numprocesses clib +# All tests require Internet access +# to test in mock use: --enable-network --with check +# to test in a privileged environment use: +# --with check --with privileged_tests +%bcond_with check +%bcond_with privileged_tests + +Name: ansible-compat +Version: VERSION_PLACEHOLDER +Release: 1%{?dist} +Summary: Ansible-compat library + +License: GPL-3.0-or-later +URL: https://github.com/ansible/ansible-compat +Source0: %{pypi_source} + +BuildArch: noarch + +BuildRequires: python%{python3_pkgversion}-devel +%if %{with check} +# These are required for tests: +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-pytest-xdist +BuildRequires: python%{python3_pkgversion}-libselinux +BuildRequires: git-core +%endif +Requires: git-core + + +%description +Ansible-compat. + +%prep +%autosetup + + +%generate_buildrequires +%pyproject_buildrequires + + +%build +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files ansible_compat + + +%check +%pyproject_check_import +%if %{with check} +%pytest \ + -v \ + --disable-pytest-warnings \ + --numprocesses=auto \ + test +%endif + + +%files -f %{pyproject_files} +%license LICENSE +%doc docs/ README.md + +%changelog diff --git a/.gitignore b/.gitignore index a20c99cf..8e14d578 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ MANIFEST # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest -*.spec +/*.spec rpm/*.spec *.rpm diff --git a/.packit.yaml b/.packit.yaml index 575e3515..24b82bba 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -2,16 +2,15 @@ # https://packit.dev/docs/configuration/ # Test locally running: packit build locally # spell-checker:ignore packit specfile copr epel -specfile_path: dist/python-ansible-compat.spec +specfile_path: dist/python3-ansible-compat.spec actions: create-archive: - # packit.dev service does have these module pre-installed: + - sh -c "rm dist/*.tar.gz || true" - python3 -m build --sdist --outdir dist - - sh -c "ls dist/ansible-compat-*.tar.gz" + - sh -c "ls dist/ansible_compat-*.tar.gz" get-current-version: - ./tools/get-version.sh post-upstream-clone: - - rm -f dist/*.tar.gz || true - ./tools/update-version.sh srpm_build_deps: - python3-build @@ -20,7 +19,7 @@ srpm_build_deps: - python3-pytest-mock jobs: - job: copr_build - trigger: commit + trigger: pull_request branch: main targets: - fedora-rawhide-x86_64 diff --git a/tools/get-version.sh b/tools/get-version.sh index 67033f8c..a8b9a535 100755 --- a/tools/get-version.sh +++ b/tools/get-version.sh @@ -1,7 +1,14 @@ #!/bin/bash set -e { - python3 -c "import setuptools_scm" || python3 -m pip install --user setuptools-scm + python3 -c "import setuptools_scm" >/dev/null || { + if [[ "$VIRTUAL_ENV" != "" ]]; then + PIPARGS="" + else + PIPARGS="--user" + fi + python3 -m pip install $PIPARGS setuptools-scm + } } 1>&2 # redirect stdout to stderr to avoid polluting the output python3 -m setuptools_scm | \ sed 's/Guessed Version\([^+]\+\).*/\1/' diff --git a/tools/update-version.sh b/tools/update-version.sh index a2270233..321d7f28 100755 --- a/tools/update-version.sh +++ b/tools/update-version.sh @@ -3,5 +3,5 @@ DIR=$(dirname "$0") VERSION=$(./tools/get-version.sh) mkdir -p "${DIR}/../dist" sed -e "s/VERSION_PLACEHOLDER/${VERSION}/" \ - "${DIR}/../dist/python-ansible-compat.spec.in" \ - > "${DIR}/../dist/python-ansible-compat.spec" + "${DIR}/../.config/python3-ansible-compat.spec" \ + > "${DIR}/../dist/python3-ansible-compat.spec" diff --git a/tox.ini b/tox.ini index 99b93b7e..06f505d0 100644 --- a/tox.ini +++ b/tox.ini @@ -155,7 +155,7 @@ description = Use packit to build RPM (requires RPM based Linux distro) deps = packitos commands = - packit build in-mock + sh -c "packit build in-mock --root=fedora-40-$(arch)" [testenv:docs] description = Build docs