Files
integ/python/python-mechanize/centos/python-mechanize.spec
Dongqi Chen 81efadf2d3 Centos8: Remove python2 related macros
Because there is a macro related to python2,
it will cause a build error, so remove it

Story: 2006729
Task: 39875

Change-Id: I0284141f839f30206bd2197dab65b4110576a960
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
2020-05-28 10:28:11 +08:00

127 lines
3.2 KiB
RPMSpec

# Dependencies for check and wheel introduce circular dependencies
# Set this to 0 after we've bootstrapped.
%global with_check 0
%global build_wheel 0
%define with_python3 1
Name: mechanize
Version: 0.4.5
Release: 1.el8%{?_tis_dist}.%{tis_patch_ver}
Summary: Automate interaction with HTTP web servers
Group: Applications/System
License: (Python or ZPLv2.0) and ASL 2.0
URL: https://github.com/python-mechanize/mechanize
Source0: mechanize-0.4.5.tar.gz
BuildArch: noarch
%if 0%{?with_python3}
Requires: python3-html5lib
%else
Requires: python-html5lib
%endif
%description
Stateful programmatic web browsing in Python.
%if 0%{?with_python2}
%package -n python2-mechanize
Summary: Automate interaction with HTTP web servers
%{?python_provide:%python_provide python2-mechanize}
%description -n python2-mechanize
Stateful programmatic web browsing in Python.
%endif # with_python2
%if 0%{?with_python3}
%package -n python3-mechanize
Summary: Automate interaction with HTTP web servers
Group: Applications/System
%{?python_provide:%python_provide python3-mechanize}
%description -n python3-mechanize
Stateful programmatic web browsing in Python.
%endif # with_python3
%prep
%setup
%build
export PBR_VERSION=%{version}
%if 0%{?with_python2}
%{__python} setup.py build
%endif # with_python2
%if 0%{?with_python3}
%{__python3} setup.py build
%endif # with_python3
%install
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2 version
# to be the default for now).
%if 0%{?with_python3}
%if 0%{?build_wheel}
pip3 install -I dist/%{python3_wheelname} --root %{buildroot} --strip-file-prefix %{buildroot}
%else
%{__python3} setup.py install --skip-build --root %{buildroot}
%endif
rm -rf %{buildroot}%{python3_sitelib}/mechanize/test
rm -rf %{buildroot}%{python3_sitelib}/mechanize/test-tools
rm -rf %{buildroot}%{python3_sitelib}/mechanize/run_tests.py
%if 0%{?build_wheel}
sed -i '/^mechanize\/tests\//d' %{buildroot}%{python3_record}
%endif
find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f
%endif # with_python3
%if 0%{?with_python2}
%if 0%{?build_wheel}
pip2 install -I dist/%{python2_wheelname} --root %{buildroot} --strip-file-prefix %{buildroot}
%else
%{__python2} setup.py install --skip-build --root %{buildroot}
%endif
rm -rf %{buildroot}%{python2_sitelib}/mechanize/test
rm -rf %{buildroot}%{python2_sitelib}/mechanize/test-tools
rm -rf %{buildroot}%{python2_sitelib}/mechanize/run_tests.py
%if 0%{?build_wheel}
sed -i '/^mechanize\/tests\//d' %{buildroot}%{python2_record}
%endif
find %{buildroot}%{python2_sitelib} -name '*.exe' | xargs rm -f
%endif # with_python2
# Don't ship these
rm -r docs/{Makefile,conf.py}
%if 0%{?with_check}
%check
%if 0%{?with_python2}
LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test
%endif # with_python2
%if 0%{?with_python3}
LANG=en_US.utf8 PYTHONPATH=$(pwd) py.test-%{python3_version}
%endif # with_python3
%endif # with_check
%if 0%{?with_python2}
%files -n python2-mechanize
%doc docs/*
%{python2_sitelib}/*
%endif # with_python2
%if 0%{?with_python3}
%files -n python3-mechanize
%doc docs/*
%{python3_sitelib}/mechanize*/
%endif # with_python3
%changelog