dc8f213
%if 0%{?fedora} > 12 || 0%{?rhel} > 6
dc8f213
%global with_python3 1
dc8f213
%endif
dc8f213
dc8f213
%global modname alembic
dc8f213
dc8f213
Name:             python-alembic
dc8f213
Version:          0.3.4
f3d1230
Release:          4%{?dist}
dc8f213
Summary:          Database migration tool for SQLAlchemy
dc8f213
dc8f213
Group:            Development/Libraries
dc8f213
License:          MIT
dc8f213
URL:              http://pypi.python.org/pypi/alembic
dc8f213
Source0:          http://pypi.python.org/packages/source/a/%{modname}/%{modname}-%{version}.tar.gz
dc8f213
dc8f213
BuildArch:        noarch
dc8f213
dc8f213
dc8f213
BuildRequires:    help2man
dc8f213
BuildRequires:    python2-devel
dc8f213
BuildRequires:    python-mako
dc8f213
dc8f213
Requires:         python-mako
dc8f213
dc8f213
# See if we're building for python earlier than 2.7
dc8f213
%if %{?rhel}%{!?rhel:0} >= 6
dc8f213
BuildRequires:    python-sqlalchemy0.7
dc8f213
BuildRequires:    python-argparse
dc8f213
BuildRequires:    python-nose1.1
dc8f213
Requires:         python-sqlalchemy0.7
dc8f213
Requires:         python-argparse
dc8f213
%else
dc8f213
BuildRequires:    python-nose
dc8f213
BuildRequires:    python-sqlalchemy
dc8f213
Requires:         python-sqlalchemy
dc8f213
%endif
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
BuildRequires:    python3-devel
dc8f213
BuildRequires:    python-tools
dc8f213
BuildRequires:    python3-sqlalchemy
dc8f213
BuildRequires:    python3-mako
dc8f213
BuildRequires:    python3-nose
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%description
dc8f213
Alembic is a new database migrations tool, written by the author of
dc8f213
`SQLAlchemy <http://www.sqlalchemy.org>`_.  A migrations tool offers the
dc8f213
following functionality:
dc8f213
dc8f213
* Can emit ALTER statements to a database in order to change the structure
dc8f213
of tables and other constructs.
dc8f213
* Provides a system whereby "migration scripts" may be constructed; each script
dc8f213
indicates a particular series of steps that can "upgrade" a target database to
dc8f213
a new version, and optionally a series of steps that can "downgrade"
dc8f213
similarly, doing the same steps in reverse.
dc8f213
* Allows the scripts to execute in some sequential manner.
dc8f213
dc8f213
Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
%package -n python3-alembic
dc8f213
Summary:        A database migration tool for SQLAlchemy
dc8f213
Group:          Development/Libraries
dc8f213
dc8f213
Requires:         python3-sqlalchemy
dc8f213
Requires:         python3-mako
dc8f213
dc8f213
%description -n python3-alembic
dc8f213
Alembic is a new database migrations tool, written by the author of
dc8f213
`SQLAlchemy <http://www.sqlalchemy.org>`_.  A migrations tool offers the
dc8f213
following functionality:
dc8f213
dc8f213
* Can emit ALTER statements to a database in order to change the structure
dc8f213
of tables and other constructs.
dc8f213
* Provides a system whereby "migration scripts" may be constructed; each script
dc8f213
indicates a particular series of steps that can "upgrade" a target database to
dc8f213
a new version, and optionally a series of steps that can "downgrade"
dc8f213
similarly, doing the same steps in reverse.
dc8f213
* Allows the scripts to execute in some sequential manner.
dc8f213
dc8f213
Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/
dc8f213
%endif
dc8f213
dc8f213
%prep
dc8f213
%setup -q -n %{modname}-%{version}
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
rm -rf %{py3dir}
dc8f213
cp -a . %{py3dir}
dc8f213
%endif
dc8f213
dc8f213
# Make sure that epel/rhel picks up the correct version of sqlalchemy
dc8f213
%if %{?rhel}%{!?rhel:0} >= 6
dc8f213
awk 'NR==1{print "import __main__; __main__.__requires__ = __requires__ = [\"sqlalchemy>=0.6\", \"nose>=0.11\"]; import pkg_resources"}1' setup.py > setup.py.tmp
dc8f213
mv setup.py.tmp setup.py
dc8f213
%endif
dc8f213
dc8f213
dc8f213
dc8f213
%build
dc8f213
%{__python} setup.py build
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
/usr/bin/2to3 -w -n %{py3dir}
dc8f213
pushd %{py3dir}
dc8f213
%{__python3} setup.py build
dc8f213
popd
dc8f213
%endif
dc8f213
dc8f213
# Hack around setuptools so we can get access to help strings for help2man
dc8f213
# Credit for this goes to Toshio Kuratomi 
dc8f213
%{__mkdir_p} bin
dc8f213
echo 'python -c "import alembic.config; alembic.config.main()" $*' > bin/alembic
dc8f213
chmod 0755 bin/alembic
dc8f213
help2man --version-string %{version} --no-info -s 1 bin/alembic > alembic.1
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
dc8f213
%{__mkdir_p} bin
dc8f213
echo 'python3 -c "import alembic.config; alembic.config.main()" $*' > bin/python3-alembic
dc8f213
chmod 0755 bin/python3-alembic
dc8f213
help2man  --version-string %{version} --no-info -s 1 bin/python3-alembic > python3-alembic.1
dc8f213
popd
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%install
dc8f213
install -d -m 0755 %{buildroot}%{_mandir}/man1
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
dc8f213
%{__python3} setup.py install -O1 --skip-build --root=%{buildroot}
dc8f213
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/python3-%{modname}
dc8f213
install -m 0644 python3-alembic.1 %{buildroot}%{_mandir}/man1/python3-alembic.1
dc8f213
popd
dc8f213
%endif
dc8f213
dc8f213
%{__python} setup.py install -O1 --skip-build --root=%{buildroot}
dc8f213
install -m 0644 alembic.1 %{buildroot}%{_mandir}/man1/alembic.1
dc8f213
dc8f213
%check
dc8f213
%{__python} setup.py test
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
dc8f213
%{__python3} setup.py test
dc8f213
popd
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%files
dc8f213
%doc README.rst LICENSE CHANGES docs
dc8f213
%{python_sitelib}/%{modname}/
dc8f213
%{python_sitelib}/%{modname}-%{version}*
dc8f213
%{_bindir}/%{modname}
f3d1230
%{_mandir}/man1/alembic.1*
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
%files -n python3-%{modname}
dc8f213
%doc LICENSE README.rst CHANGES docs
dc8f213
%{python3_sitelib}/%{modname}/
dc8f213
%{python3_sitelib}/%{modname}-%{version}-*
dc8f213
%{_bindir}/python3-%{modname}
f3d1230
%{_mandir}/man1/python3-alembic.1*
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%changelog
f3d1230
* Fri Aug 31 2012 Ralph Bean <rbean@redhat.com> - 0.3.4-4
f3d1230
- Correct %%files entries for the man pages.
f3d1230
dc8f213
* Fri Aug 31 2012 Ralph Bean <rbean@redhat.com> - 0.3.4-3
dc8f213
- Include docs folder in %%doc section.
dc8f213
- Use help2man to build man pages for executables.
dc8f213
- Remove article from summary (cosmetic).
dc8f213
- Add trailing slash to directories in %%files (cosmetic).
dc8f213
dc8f213
* Thu Jul 05 2012 Ralph Bean <rbean@redhat.com> - 0.3.4-2
dc8f213
- Require python-argparse if running on py2.6 or earlier.
dc8f213
- Require the forward-compat python-sqlalchemy on epel.
dc8f213
- Require the forward-compat python-nose on epel.
dc8f213
dc8f213
* Thu Jul 05 2012 Ralph Bean <rbean@redhat.com> - 0.3.4-1
dc8f213
- initial package for Fedora