LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File python-optcomplete.spec of Package python-optcomplete (Project Documentation:Tools)

# spec file for package python-optcomplete
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/

%define modname optcomplete
%define _version 1.2_devel
%define unmangled_version 1.2-devel
%define release 1

Name:           python-optcomplete
Summary:        Automatic Shell Completion Support for Scripts Using Optparse
License:        BSD-3-Clause
Group:          Development/Libraries/Python
Version:        %{_version}
Release:        0
Source0:        %{modname}-%{unmangled_version}.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{?suse_version: %{suse_version} > 1110} %{!?suse_version:1}
BuildArch:      noarch
Url:            http://furius.ca/optcomplete
BuildRequires:  python-devel

This module provide automatic bash completion support for programs that use the
optparse module.  The premise is that the optparse options parser specifies
enough information (and more) for us to be able to generate completion strings
esily.  Another advantage of this over traditional completion schemes where the
completion strings are hard-coded in a separate bash source file, is that the
same code that parses the options is used to generate the completions, so the
completions is always up-to-date with the program itself.

In addition, we allow you specify a list of regular expressions or code that
define what kinds of files should be proposed as completions to this file if
needed.  If you want to implement more complex behaviour, you can instead
specify a function, which will be called with the current directory as an

You need to activate bash completion using the shell script function that comes
with optcomplete (see http://furius.ca/optcomplete for more details).

%setup -n %{modname}-%{unmangled_version}

python setup.py build

python setup.py install \
  --root=$RPM_BUILD_ROOT \
  --prefix=%{_prefix} \
mkdir -p $RPM_BUILD_ROOT%_sysconfdir/bash_completion.d

mv bin example
chmod -x example/README
mkdir bash_completion
mv etc/bashrc etc/env etc/optcomplete.zsh bash_completion/
chmod -x bash_completion/optcomplete.zsh

cp -v etc/optcomplete.bash \


%files -f %{name}.files
%config %_sysconfdir/bash_completion.d/*
%doc doc/* example bash_completion