Jump to: navigation, search


< Rpm-packaging
Revision as of 17:04, 30 June 2016 by IYozhikov (talk | contribs) (change vertical indentation according to linter setup)

Code style definition

Code should be written in common manner and in the way easy to read.


  • All %global variables must be declared at the very beginning
  • Name: value, which is used within py2name context function, must equals pypi name!
  • Version: value is almost equals to git tag. For non trivial versions containing dev, alpha, beta, rc in version should be used tilda=~ as delimiter from numerical version part .


  • Horizontal indentation - the values goes right after the BuildRequires: and 2 spaces.
  • Vertical indentation - all logical blocks like %pre, %build, %install, %files, etc should be separated with 1 newline.


%global sname py_name
Name:           {{ py2name('py_name') }}
Version:        X.Y.Z
Release:        0
Summary:        A for .... functionality for OpenStack projects
License:        {{ 'Apache-2.0' | license }}
Group:          Development/Languages/Python
Url:            http://www.homepage.org/
Source:         https://pypi.python.org/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
BuildRequires:  openstack-macros
BuildRequires:  {{ py2pkg('devel') }}
BuildRequires:  {{ py2pkg('build_req0') }}
BuildRequires:  {{ py2pkg('build_req1') }}
Requires:       {{ py2pkg('runtume_req0') }}
Requires:       {{ py2pkg('runtume_req1') }}
BuildArch:      noarch

A py_name ......... for OpenStack projects
* Documentation: http://docs.openstack.org/developer/py_name
* Source: http://git.openstack.org/cgit/openstack/py_name
* Bugs: http://bugs.launchpad.net/py_name

%package doc
Summary:        Documentation for the py_name
Group:          Documentation
BuildRequires:  {{ py2pkg('doc builld req0') }}
BuildRequires:  {{ py2pkg('doc builld req0') }}
Requires:       %{name} = ${version}

%description doc
Documentation for py_name .........

%setup -q -n %{sname}-%{version}

%{__python2} setup.py build
# generate html docs
%{__python2} setup.py build_sphinx
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}

export PATH="$PATH:%{buildroot}/%{_bindir}"
export PYTHONPATH="%{python2_sitearch}:%{python2_sitelib}:%{buildroot}%{python2_sitelib}"
%{__python2} setup.py testr

%license LICENSE
%doc README.rst ChangeLog

%files doc
%license LICENSE
%doc doc/build/html