ff2ff58
%global with_python2 1
ff2ff58
%if 0%{?rhel} && 0%{?rhel} >= 8
ff2ff58
%global with_python2 0
ff2ff58
%endif
ff2ff58
Jeroen van Meeuwen (Kolab Systems) f39cbc2
%if 0%{?fedora} || 0%{?rhel} >= 8
dc8f213
%global with_python3 1
dc8f213
%endif
dc8f213
dc8f213
%global modname alembic
dc8f213
dc8f213
Name:             python-alembic
4c64425
Version:          1.0.11
ff2ff58
Release:          2%{?dist}
dc8f213
Summary:          Database migration tool for SQLAlchemy
dc8f213
dc8f213
License:          MIT
9e1dd60
URL:              https://pypi.io/project/alembic
b2935d8
Source0:          %pypi_source alembic
896b32f
dc8f213
BuildArch:        noarch
dc8f213
dc8f213
BuildRequires:    help2man
ff2ff58
ff2ff58
%if 0%{?with_python2}
dc8f213
BuildRequires:    python2-devel
54db439
BuildRequires:    python2-mako
54db439
BuildRequires:    python2-setuptools
54db439
BuildRequires:    python2-mock
54db439
BuildRequires:    python2-dateutil
54db439
BuildRequires:    python2-editor
24a7c65
BuildRequires:    python2-pytest
dc8f213
dc8f213
# See if we're building for python earlier than 2.7
c146b27
%if 0%{?rhel} && 0%{?rhel} <= 6
3e18ecd
BuildRequires:    python-sqlalchemy0.7 >= 0.7.4
dc8f213
BuildRequires:    python-argparse
dc8f213
BuildRequires:    python-nose1.1
dc8f213
%else
54db439
BuildRequires:    python2-nose
54db439
BuildRequires:    python2-sqlalchemy >= 0.7.4
dc8f213
%endif
dc8f213
8b3ce78
# Just for the tests
54db439
BuildRequires:    python2-psycopg2
54db439
BuildRequires:    python2-mysql
ff2ff58
%endif
8b3ce78
dc8f213
%if 0%{?with_python3}
dc8f213
BuildRequires:    python3-devel
54db439
BuildRequires:    python2-tools
3e18ecd
BuildRequires:    python3-sqlalchemy >= 0.7.4
dc8f213
BuildRequires:    python3-mako
dc8f213
BuildRequires:    python3-nose
e160057
BuildRequires:    python3-setuptools
c146b27
BuildRequires:    python3-mock
e2b1806
BuildRequires:    python3-dateutil
24a7c65
BuildRequires:    python3-editor
24a7c65
BuildRequires:    python3-pytest
dc8f213
%endif
dc8f213
dc8f213
cd6b849
%global _description\
cd6b849
Alembic is a new database migrations tool, written by the author of\
cd6b849
SQLAlchemy.  A migrations tool offers the following functionality:\
cd6b849
\
cd6b849
* Can emit ALTER statements to a database in order to change the structure\
cd6b849
  of tables and other constructs.\
cd6b849
* Provides a system whereby "migration scripts" may be constructed; each script\
cd6b849
  indicates a particular series of steps that can "upgrade" a target database\
cd6b849
  to a new version, and optionally a series of steps that can "downgrade"\
cd6b849
  similarly, doing the same steps in reverse.\
cd6b849
* Allows the scripts to execute in some sequential manner.\
cd6b849
\
cd6b849
Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/
dc8f213
cd6b849
%description %_description
dc8f213
ff2ff58
%if 0%{?with_python2}
cd6b849
%package -n python2-alembic
cd6b849
Summary:          %summary
cd6b849
cd6b849
# See if we're building for python earlier than 2.7
cd6b849
%if 0%{?rhel} && 0%{?rhel} <= 6
cd6b849
Requires:         python-sqlalchemy0.7 >= 0.7.4
cd6b849
Requires:         python-argparse
cd6b849
%else
168a35b
Requires:         python2-sqlalchemy >= 0.9.0
cd6b849
%endif
cd6b849
54db439
Requires:         python2-editor
54db439
Requires:         python2-dateutil
54db439
Requires:         python2-setuptools
54db439
Requires:         python2-mako
cd6b849
%{?python_provide:%python_provide python2-alembic}
cd6b849
cd6b849
%description -n python2-alembic %_description
ff2ff58
%endif
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
%package -n python3-alembic
cd6b849
Summary:          %summary
dc8f213
168a35b
Requires:         python3-sqlalchemy >= 0.9.0
dc8f213
Requires:         python3-mako
e160057
Requires:         python3-setuptools
214ae92
Requires:         python3-editor
e2b1806
Requires:         python3-dateutil
cd6b849
%{?python_provide:%python_provide python3-alembic}
dc8f213
cd6b849
%description -n python3-alembic %_description
dc8f213
%endif
dc8f213
dc8f213
%prep
896b32f
%autosetup -p1 -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
c146b27
%if 0%{?rhel} && 0%{?rhel} <= 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
%build
ff2ff58
%if 0%{?with_python2}
582595e
%{__python2} setup.py build
ff2ff58
%endif
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
dc8f213
%{__python3} setup.py build
dc8f213
popd
dc8f213
%endif
dc8f213
ff2ff58
%if 0%{?with_python2}
dc8f213
# Hack around setuptools so we can get access to help strings for help2man
e2b1806
# Credit for this goes to Toshio Kuratomi
c146b27
%if 0%{?rhel} && 0%{?rhel} <= 6
b9bfc9a
%else
dc8f213
%{__mkdir_p} bin
392dc63
echo 'python2 -c "import alembic.config; alembic.config.main()" $*' > bin/alembic
392dc63
chmod 0755 bin/alembic
392dc63
help2man --version-string %{version} --no-info -s 1 bin/alembic > python2-alembic.1
392dc63
mv bin/alembic bin/python2-alembic
c146b27
%endif
ff2ff58
%endif
dc8f213
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
dc8f213
%{__mkdir_p} bin
24a7c65
echo 'python3 -c "import alembic.config; alembic.config.main()" $*' > bin/alembic
24a7c65
chmod 0755 bin/alembic
24a7c65
help2man --version-string %{version} --no-info -s 1 bin/alembic > alembic.1
dc8f213
popd
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%install
24a7c65
dc8f213
install -d -m 0755 %{buildroot}%{_mandir}/man1
24a7c65
dc8f213
%if 0%{?with_python3}
dc8f213
pushd %{py3dir}
befdccf
%{__python3} setup.py install --skip-build --root=%{buildroot}
392dc63
mv %{buildroot}/%{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-3
392dc63
ln -s %{_bindir}/%{modname}-3 %{buildroot}/%{_bindir}/%{modname}-%{python3_version}
392dc63
install -m 0644 alembic.1 %{buildroot}%{_mandir}/man1/alembic-3.1
392dc63
ln -s %{_mandir}/man1/alembic-3.1 %{buildroot}%{_mandir}/man1/alembic-%{python3_version}.1
dc8f213
popd
dc8f213
%endif
dc8f213
ff2ff58
%if 0%{?with_python2}
392dc63
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
392dc63
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-2
392dc63
ln -s %{_bindir}/%{modname} %{buildroot}/%{_bindir}/%{modname}-%{python2_version}
392dc63
install -m 0644 python2-alembic.1 %{buildroot}%{_mandir}/man1/alembic.1
392dc63
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-2.1
392dc63
ln -s %{_mandir}/man1/alembic.1 %{buildroot}%{_mandir}/man1/alembic-%{python2_version}.1
ff2ff58
%endif
392dc63
c146b27
%if 0%{?rhel} && 0%{?rhel} <= 6
befdccf
# Modify /usr/bin/alembic to require SQLAlchemy>=0.6
befdccf
# Hacky but setuptools only creates this file after setup.py install is run :-(
befdccf
# Root cause is that setuptools doesn't recurse the requirements when it processes
befdccf
# the __requires__.  It waits until pkg_resources.require('MODULE') is called.
befdccf
# Since that isn't done in the entrypoints script, we need to specify the dependency
befdccf
# on a specific SQLAlchemy version explicitly.
24a7c65
sed -i -e "s|__requires__ = 'alembic==0.4.2'|__requires__ = ['alembic==0.4.2', 'SQLAlchemy>=0.6']|" %{buildroot}%{_bindir}/python2-%{modname}
a43a9a2
%endif
dc8f213
24a7c65
%check
ff2ff58
%if 0%{?with_python2}
24a7c65
%{__python2} setup.py test
ff2ff58
%endif
24a7c65
24a7c65
%if 0%{?with_python3}
24a7c65
pushd %{py3dir}
24a7c65
%{__python3} setup.py test
24a7c65
popd
24a7c65
%endif
dc8f213
dc8f213
ff2ff58
%if 0%{?with_python2}
cd6b849
%files -n python2-alembic
dc8f213
%doc README.rst LICENSE CHANGES docs
582595e
%{python2_sitelib}/%{modname}/
582595e
%{python2_sitelib}/%{modname}-%{version}*
392dc63
%{_bindir}/%{modname}
392dc63
%{_bindir}/%{modname}-2
392dc63
%{_bindir}/%{modname}-%{python2_version}
b9bfc9a
c146b27
%if 0%{?rhel} && 0%{?rhel} <= 6
b9bfc9a
%else
392dc63
%{_mandir}/man1/alembic.1*
392dc63
%{_mandir}/man1/alembic-2.1*
392dc63
%{_mandir}/man1/alembic-%{python2_version}.1*
b9bfc9a
%endif
ff2ff58
%endif
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}-*
392dc63
%{_bindir}/%{modname}-3
392dc63
%{_bindir}/%{modname}-%{python3_version}
392dc63
%{_mandir}/man1/alembic-3.1*
392dc63
%{_mandir}/man1/alembic-%{python3_version}.1*
dc8f213
%endif
dc8f213
dc8f213
dc8f213
%changelog
4c64425
* Sun Jun 30 2019 Kevin Fenzi <kevin@scrye.com> - 1.0.11-1
4c64425
- Update to 1.0.11. Fixes bug #1723981
4c64425
ff2ff58
* Wed Jun 19 2019 Troy Dawson <tdawson@redhat.com> - 1.0.10-1.1
ff2ff58
- Make python2 optional
ff2ff58
- Do not build python2 on RHEL8
ff2ff58
189fcd0
* Wed Jun 05 2019 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.0.10-1
189fcd0
- Update to 1.0.10 (#1700050).
189fcd0
- https://alembic.sqlalchemy.org/en/latest/changelog.html#change-1.0.10
189fcd0
1a8ab75
* Thu Mar 28 2019 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.0.8-1
1a8ab75
- Update to 1.0.8 (#1685262).
1a8ab75
- https://alembic.sqlalchemy.org/en/latest/changelog.html#change-1.0.8
1a8ab75
168a35b
* Tue Feb 05 2019 Alfredo Moralejo <amoralej@redhat.com> - 1.0.7-1
168a35b
- Update to 1.0.7
168a35b
dd95074
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-2
dd95074
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
dd95074
b2935d8
* Wed Jul 25 2018 Pierre-Yves Chibon <pingou@pingoured.fr> - 1.0.0-1
b2935d8
- Update to 1.0.0
b2935d8
74eee9e
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.7-7
74eee9e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
74eee9e
b5d95b8
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.9.7-6
b5d95b8
- Rebuilt for Python 3.7
b5d95b8
efeb836
* Sun Jun 17 2018 Miro Hrončok <mhroncok@redhat.com> - 0.9.7-5
efeb836
- Rebuilt for Python 3.7
efeb836
54db439
* Wed Feb 21 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.9.7-4
54db439
- Update Python 2 dependency declarations to new packaging standards
54db439
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
54db439
392dc63
* Thu Feb 08 2018 Randy Barlow <bowlofeggs@fedoraproject.org> - 0.9.7-3
392dc63
- The python3-alembic package now provides only alembic-3 and alembic-3.y.
392dc63
- The python2-alembic package now provides alembic, alembic-2, and alembic-2.y.
392dc63
24a7c65
* Sat Jan 27 2018 Ralph Bean <rbean@redhat.com> - 0.9.7-2
24a7c65
- The python3-alembic package now provides the alembic executable.
24a7c65
e2b1806
* Thu Jan 18 2018 Ralph Bean <rbean@redhat.com> - 0.9.7-1
e2b1806
- new version
e2b1806
- New dependency on python-dateutil.