Skip to content

Commit

Permalink
Fix packit configuration (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored May 28, 2024
1 parent 60351d5 commit 8b339ae
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 10 deletions.
66 changes: 66 additions & 0 deletions .config/python3-ansible-compat.spec
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tools/get-version.sh
Original file line number Diff line number Diff line change
@@ -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/'
4 changes: 2 additions & 2 deletions tools/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b339ae

Please sign in to comment.