Jump to: navigation, search

Difference between revisions of "Rpm-packaging/ContentStyle"

(Add style guide and example)
 
(Example)
Line 22: Line 22:
 
Source:        https://pypi.python.org/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
 
Source:        https://pypi.python.org/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
 
BuildRequires: openstack-macros
 
BuildRequires: openstack-macros
BuildRequires: python-devel
+
BuildRequires: {{ py2pkg('devel') }}
 
BuildRequires: {{ py2pkg('build_req0') }}
 
BuildRequires: {{ py2pkg('build_req0') }}
 
BuildRequires: {{ py2pkg('build_req1') }}
 
BuildRequires: {{ py2pkg('build_req1') }}

Revision as of 11:46, 21 April 2016

Code style definition

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

Head

  • 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 .

Indentation

  • 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 2 newlines.

Example

%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


%description
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') }}


%description doc
Documentation for the testr wrapper.


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


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


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


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


%files
%defattr(-,root,root,-)
%license LICENSE
%doc README.rst ChangeLog
%{_bindir}/py_name_cli
%{python2_sitelib}/py_name
%{python2_sitelib}/py_name*egg-info


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


%changelog