Blob Blame History Raw
%bcond_without html_docs

Name:           pipx
Version:        0.16.3
Release:        %autorelease
Summary:        Install and run Python applications in isolated environments

License:        MIT
URL:  {name}/

Source10:       %{name}.1
Source11:       %{name}-install.1
Source12:       %{name}-inject.1
Source13:       %{name}-upgrade.1
Source14:       %{name}-upgrade-all.1
Source15:       %{name}-uninstall.1
Source16:       %{name}-uninstall-all.1
Source17:       %{name}-reinstall.1
Source18:       %{name}-reinstall-all.1
Source19:       %{name}-list.1
Source20:       %{name}-run.1
Source21:       %{name}-runpip.1
Source22:       %{name}-ensurepath.1
Source23:       %{name}-completions.1

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  pyproject-rpm-macros

BuildRequires:  pkgconfig(bash-completion)
%global bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null)
%global bashcomproot %(dirname %{bashcompdir} 2>/dev/null)
BuildRequires:  pkgconfig(fish)
%global fishcompdir %(pkg-config --variable=completionsdir fish 2>/dev/null)
%global fishcomproot %(dirname %{fishcompdir} 2>/dev/null)
BuildRequires:  /usr/bin/register-python-argcomplete

%{name} is a tool to help you install and run end-user applications written in
Python. It’s roughly similar to macOS’s brew, JavaScript’s npx, and Linux’s

It’s closely related to pip. In fact, it uses pip, but is focused on installing
and managing Python packages that can be run from the command line directly as

%package doc
Summary:        Documentation for %{name}

%if %{with html_docs}
# See
BuildRequires:  python3dist(jinja2)
BuildRequires:  python3dist(mkdocs)

%description doc
Documentation for %{name}.

# Drop dependency on mkdocs-material. See
# The result doesn’t
# look as nice but is still usable.
sed -r -i 's/"material"/"mkdocs"/' mkdocs.yml

# We do not run the tests; but we add the runtime requirements as BR’s anyway
# so that the build will fail if some are not available in the distribution.
%pyproject_buildrequires -r


  # Temporary local install
  if [ -n "${PYTHONPATH-}" ]; then PYTHONPATH="${PYTHONPATH}:"; fi
  if [ -n "${PATH-}" ]; then PATH="${PATH}:"; fi
  export PATH="${PATH}:${PYTEMP}/bin"
  %{__python3} -m pip install --target="${PYTEMP}" \
      --no-deps --use-pep517 --no-build-isolation \
      --disable-pip-version-check --no-clean --progress-bar off --verbose \

%if %{with html_docs}
  # Build the documentation
  %{__python3} scripts/
  mkdocs build

  # Generate shell completions. “pipx completions” says:
  # Add the appropriate command to your shell's config file
  # so that it is run on startup. You will likely have to restart
  # or re-login for the autocompletion to start working.
  # bash:
  #     eval "$(register-python-argcomplete pipx)"
  # zsh:
  #     To activate completions for zsh you need to have
  #     bashcompinit enabled in zsh:
  #     autoload -U bashcompinit
  #     bashcompinit
  #     Afterwards you can enable completion for pipx:
  #     eval "$(register-python-argcomplete pipx)"
  # tcsh:
  #     eval `register-python-argcomplete --shell tcsh pipx`
  # fish:
  #     register-python-argcomplete --shell fish pipx | source
  for sh in bash tcsh fish
    register-python-argcomplete --shell "${sh}" %{name} \
        > "%{name}.${sh}"

  rm -rf "${PYTEMP}"

%pyproject_save_files %{name}

install -p -m 0644 -D -t %{buildroot}%{bashcompdir} %{name}.bash
install -p -m 0644 -D -t %{buildroot}%{fishcompdir} %{name}.fish
# It seems that there is not a reasonable way to install tcsh completions
# system-wide, so we just make the completions file available for interested
# users.
install -p -m 0644 -D %{name}.tcsh \
# Note that there are no “native” zsh completions, so we do not attempt to
# install anything. This could change if an actual zsh user recommends a
# different plan.

install -p -m 0644 -D -t '%{buildroot}/%{_mandir}/man1' \
    %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} %{SOURCE15} \
    %{SOURCE16} %{SOURCE17} %{SOURCE18} %{SOURCE19} %{SOURCE20} %{SOURCE21} \
    %{SOURCE22} %{SOURCE23}

# It’s just not practical to run the tests. For most of them, we need either
# (by default) a bundle of sample wheels from PyPI–which is arch-specific, as
# some of them have compiled extensions—or network access. Previously, we tried
# to disentangle the tests that did not require PyPI packages, but this has
# become onerous.

%files -f %{pyproject_files}
%license LICENSE



# Note that it is standard in Fedora for packages providing shell completions
# to co-own the completions directory in lieu of having a runtime dependency on
# the relevant shell completions package.

%files doc
%license LICENSE
# Markdown
%doc docs
%if %{with html_docs}
%doc site