Blob Blame History Raw
Name:           python-pyct
Version:        0.5.0
Release:        %autorelease
Summary:        Python packaging Common Tasks

# The entire source is BSD-3-Clause, except for pyct/, which is
# (BSD-3-Clause and ISC).
License:        BSD-3-Clause AND ISC
# The PyPI archive lacks tox.ini, but it was not exactly suitable for testing
# in the RPM build environment anyway, so we just re-created the needed tests
# in %%check.
# Note that if we ever switch to the GitHub tarball we will need to re-create
# the pyct/.version file that appears in the PyPI source tarball in order for
# package versioning to work correctly. See the python-param package for an
# example of this.
Source0:        %{pypi_source pyct}

# Man pages written by hand for Fedora in groff_man(7) format using the
# command’s --help output
Source10:       pyct.1
Source11:       pyct-report.1

BuildArch:      noarch

ExcludeArch:    %{ix86}

BuildRequires:  python3-devel

BuildRequires:  python3dist(pytest)

%global common_description %{expand:
A utility package that includes:

 1. pyct.cmd: Makes various commands available to other packages. (Currently no
    sophisticated plugin system, just a try import/except in the other
    packages.) The same commands are available from within python. Can either
    add new subcommands to an existing argparse based command if the module has
    an existing command, or create the entire command if the module has no
    existing command. Currently, there are commands for copying examples and
    fetching data.

 2. Provides various commands to help package building, primarily
    as a convenience for project maintainers.}

%description %{common_description}

%package -n python3-pyct
Summary:        %{summary}

# The file pyct/ contains a progress bar implementation copied (and
# possibly slightly forked?) from an unknown version of
# It doesn’t make sense to ask pyct’s upstream
# to support using an external copy of clint, because clint appears to be
# unmaintained upstream.
Provides:       bundled(python3dist(clint))

%description -n python3-pyct %{common_description}

%pyproject_extras_subpkg -n python3-pyct build cmd

%autosetup -n pyct-%{version} -p1

sed -r -i '/\bflake8\b/d'

# Remove shebangs from subcommand modules. These are executable in the source
# tarball, but once installed in site-packages will no longer be executable and
# should be executed indirectly, typically via the “pyct” command. The
# find-then-modify pattern keeps us from discarding mtimes on sources that do
# not need modification.
find pyct -type f -exec \
    gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
  xargs -r -t sed -r -i '1{/^#!/d}'

%pyproject_buildrequires -x build,cmd,tests


# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# Since the documentation uses nbsite, which explicitly targets HTML, it’s
# unlikely we could package satisfactory and guideline-compliant documentation
# even if python3dist(nbsite) were packaged.

%pyproject_save_files -l pyct

install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 \
     '%{SOURCE10}' '%{SOURCE11}'

# Based loosely on{version}/tox.ini
# _cmd_examples
  set -o errexit
  export %{py3_test_envvars}
  %{python3} -c "import pyct;'pyct','python','system')"
  # _build_examples
  %{python3} -c "from import examples, get_setup_version"
  # _unit
  # (no need to run pytest again!)
  pyct --help
  pyct --version
  pyct report --help
  pyct report pyct python
  %{python3} -m pyct --version

%files -n python3-pyct -f %{pyproject_files}