Blob Blame History Raw
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

%if 0%{?fedora}
%global with_python3 1
%endif

%define srcname jenkins-job-builder
#define checkout 20141111gitgbaff62b

Name:           python-%{srcname}
Version:        1.1.0
Release:        1%{dist}
Summary:        Manage Jenkins jobs with YAML
Group:          Development/Libraries
License:        ASL 2.0
URL:            http://ci.openstack.org/jenkins-job-builder/
Source0:        http://pypi.python.org/packages/source/j/%{srcname}/%{srcname}-%{version}.tar.gz
Requires:       python-jenkins
Requires:       PyYAML
%if 0%{?fc20}
Requires:       python-ordereddict
%endif
Requires:       python-pbr
BuildRequires:  pytest
BuildRequires:  python-devel >= 2.6
BuildRequires:  python-six >= 1.5.2
BuildRequires:  python-sphinx
BuildRequires:  PyYAML
BuildRequires:  python-jenkins >= 0.3.4
BuildRequires:  python-mock
BuildRequires:  python-testtools
BuildRequires:  python-testscenarios
%if 0%{?fc20}
BuildRequires:  python-ordereddict
%endif
%if 0%{?with_python3}
Requires:       python3-jenkins
Requires:       python3-pbr
BuildRequires:  python3-devel >= 3.1
BuildRequires:  python3-setuptools
BuildRequires:  python3-pytest
BuildRequires:  python3-six >= 1.5.2
BuildRequires:  python3-sphinx
BuildRequires:  python3-PyYAML
BuildRequires:  python3-jenkins >= 0.3.4
BuildRequires:  python3-mock
BuildRequires:  python3-testtools
# python3-testscenarios not yet available: https://bugzilla.redhat.com/1208889
#BuildRequires:  python3-testscenarios
%endif # with_python3
BuildArch:      noarch

%description
Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format
and uses them to configure Jenkins. You can keep your job descriptions in
human readable text format in a version control system to make changes and
auditing easier. It also has a flexible template system, so creating many
similarly configured jobs is easy.

%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary:        Manage Jenkins jobs with YAML
Group:          Development/Languages
Requires:       python3 >= 3.1

%description -n python3-%{srcname}
Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format
and uses them to configure Jenkins. You can keep your job descriptions in
human readable text format in a version control system to make changes and
auditing easier. It also has a flexible template system, so creating many
similarly configured jobs is easy.
%endif # with_python3

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

# remove shebangs
find jenkins_jobs -type f -name '*.py' \
  -exec sed -i -e '/^#!/{1D}' {} \;

# remove old Python 2.6-era requirements:
%if 0%{?fedora} > 20
sed -i requirements.txt \
  -e '/argparse/d' \
  -e '/ordereddict/d'
%endif

# Loosen python-pbr requirement
sed -i 's/pbr>=0.8.2/pbr>=0.8.0/' requirements.txt

%if 0%{?with_python3}
cp -a . %{py3dir}
%endif # with_python3

%build
export PBR_VERSION=%{version}

%{__python} setup.py build
# This requires sphinxcontrib-programoutput, which is not packaged in Fedora.
#make -C doc html man

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
# This requires sphinxcontrib-programoutput, which is not packaged in Fedora.
#SPHINXBUILD=sphinx-build-%{python3_version} make -C doc html man
popd
# Can't get to docs in py3dir (RHBZ #563622)
#cp -a %{py3dir}/doc py3doc
%endif # with_python3

%install
%{__python} setup.py install -O1 --skip-build --root %{buildroot}

# rename binary
mv %{buildroot}%{_bindir}/jenkins-jobs{,-%{python_version}}

%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
popd

# rename binary
mv %{buildroot}%{_bindir}/jenkins-jobs{,-%{python3_version}}
%endif # with_python3

# 2.X binary is called by default for now
ln -s jenkins-jobs-%{python_version} %{buildroot}%{_bindir}/jenkins-jobs

%check
export PYTHONPATH=$(pwd)

py.test-%{python_version} -v tests

%if 0%{?with_python3}
pushd %{py3dir}
# python3-testscenarios not yet available: https://bugzilla.redhat.com/1208889
py.test-%{python3_version} -v tests || :
popd
%endif # with_python3

%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
#doc doc/build/html
%{python_sitelib}/*
%{_bindir}/jenkins-jobs
%{_bindir}/jenkins-jobs-%{python_version}

%if 0%{?with_python3}
%files -n python3-%{srcname}
%license LICENSE
#doc doc/build/html
%{python3_sitelib}/*
%{_bindir}/jenkins-jobs-%{python3_version}
%endif # with_python3

%changelog
* Fri Apr 03 2015 Ken Dreyer <ktdreyer@ktdreyer.com> - 1.1.0-1
- update to 1.1.0
- rm python3_version compat macro; this has been defined since F13
- remove hard-coded srcname in some places
- add more test suite BRs
- run tests using py.test directly instead of setuptools
- add LICENSE

* Wed Nov 19 2014 Ken Dreyer <ktdreyer@ktdreyer.com> - 1.0.0-1
- update to 1.0.0
- rm argparse dep (this is in Python 2.7 core)
- Use PBR_VERSION instead of trying to avoid pbr.

* Wed Nov 19 2014 Ken Dreyer <ktdreyer@ktdreyer.com> - 0.9.0-0.20141111gitgbaff62b.1
- update to post-release git snapshot

* Tue Nov 11 2014 Ken Dreyer <ktdreyer@ktdreyer.com> - 0.9.0-1
- New package.