diff --git a/.config/python3-ansible-compat.spec b/.config/python3-ansible-compat.spec new file mode 100644 index 00000000..3cd5b5a0 --- /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 ansiblecompat + + +%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..9a295ed2 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -2,12 +2,12 @@ # 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" - 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: @@ -20,7 +20,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"