File mingw64-python.spec of Package mingw64-python
#
# spec file for package mingw64-python
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define shared 1
Name: mingw64-python
Version: 2.7.18
Release: 0
Summary: Python Interpreter
License: Python-2.0
Group: Development/Languages/Python
Url: http://python.org/
Source0: Python-%{version}.tar.xz
Source1: python.pc
Patch0: Python-2.7.18-cross.patch
#!BuildIgnore: post-build-checks
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gcc-c++
BuildRequires: libtool
BuildRequires: mingw64-cross-gcc
BuildRequires: mingw64-cross-gcc-c++
BuildRequires: mingw64-cross-pkg-config
BuildRequires: mingw64-dlfcn-win32-devel
BuildRequires: mingw64-filesystem
BuildRequires: mingw64-libbz2-devel
BuildRequires: mingw64-libdb-devel
BuildRequires: mingw64-libintl-devel
BuildRequires: mingw64-libopenssl-devel
BuildRequires: mingw64-ncurses-devel
BuildRequires: mingw64-readline-devel
BuildRequires: mingw64-sqlite-devel
BuildRequires: mingw64-termcap-devel
BuildRequires: mingw64-winpthreads-devel
BuildRequires: mingw64-zlib-devel
BuildRequires: ncurses-devel
BuildRequires: python
BuildRequires: python-devel
BuildRequires: xz
BuildRequires: zlib-devel
Provides: mingw64-python-ctypes = 1.1.0
Provides: mingw64-python-argparse = 1.4.0.1
Provides: mingw64-python2-argparse = 1.4.0.1
%_mingw64_package_header_debug
BuildArch: noarch
%description
Python is an interpreted, object-oriented programming language, and is
often compared to Tcl, Perl, Scheme, or Java. You can find an overview
of Python in the documentation and tutorials included in the python-doc
(HTML) or python-doc-pdf (PDF) packages.
If you want to install third party modules using distutils, you need to
install python-devel package.
%if 0
%package base
Summary: Python Interpreter base package
Group: Development/Libraries
%description base
Python is an interpreted, object-oriented programming language, and is
often compared to Tcl, Perl, Scheme, or Java. You can find an overview
of Python in the documentation and tutorials included in the python-doc
(HTML) or python-doc-pdf (PDF) packages.
This package contains all of stand-alone Python files, minus binary
modules that would pull in extra dependencies.
%endif
%package devel
Summary: Include Files and Libraries Mandatory for Building Python Modules
Group: Development/Libraries
%description devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.
This package contains header files, a static library, and development
tools for building Python modules, extending the Python interpreter or
embedding Python in applications.
%_mingw64_debug_package
%prep
%autosetup -p1 -n Python-%{version}
%build
libtoolize --force --copy --automake --install
autoreconf -f -i
echo "ac_cv_file__dev_ptmx=no" >>%{_mingw64_cache}
echo "ac_cv_file__dev_ptc=no" >>%{_mingw64_cache}
echo "ac_cv_have_long_long_format=yes" >>%{_mingw64_cache}
echo "ac_cv_have_size_t_format=yes" >>%{_mingw64_cache}
echo "ac_cv_printf_zd_format=yes" >>%{_mingw64_cache}
export MINGW64_CFLAGS="%_mingw64_cflags -DMS_WINDOWS -D_WIN32_WINNT=0x0602"
%{_mingw64_configure} --with-threads \
%if %shared
--enable-shared
%endif
%{_mingw64_make} %{?_smp_mflags} || %{_mingw64_make}
%install
%{_mingw64_make} DESTDIR=%{buildroot} install
%if %shared
mv %{buildroot}%{_mingw64_libdir}/python2.7/config/libpython2.7.dll.a \
%{buildroot}%{_mingw64_libdir}/
chmod +w %{buildroot}%{_mingw64_bindir}/libpython2.7.dll
%endif
#remove the distutils binaries
rm -f %{buildroot}%{_mingw64_libdir}/python2.7/distutils/command/wininst*.exe
# fix W: python-bytecode-inconsistent-mtime
find %{buildroot}%{_mingw64_libdir}/python2.7 -name "*.py[oc]" -exec rm \{\} \;
# fix E: env-script-interpreter
find %{buildroot}%{_mingw64_libdir}/python2.7 -name "*.py" -exec chmod -x \{\} \;
# replace rest of /usr/local/bin/python or /usr/bin/python2.5 with /usr/bin/python
find %{buildroot}%{_mingw64_libdir}/python2.7 -name '*.py' -type f | grep -vE "^./Parser/|^./Python/" \
| xargs grep -lE '^#! *(/usr/.*bin/(env +)?)?python' \
| xargs sed -r -i -e '1s@^#![[:space:]]*(/usr/(local/)?bin/(env +)?)?python([0-9]+\.[0-9]+)?@#!/usr/bin/python@'
# the grep inbetween makes it much faster
# Install pkg-config
mkdir -p %{buildroot}%{_mingw64_libdir}/pkgconfig
install --mode=644 %{SOURCE1} %{buildroot}%{_mingw64_libdir}/pkgconfig/python.pc
# fix /usr/lib/rpm/mingw64-find-requires.sh: line 149: /home/abuild/rpmbuild/BUILDROOT/mingw64-python-2.7.18-0.x86_64/usr/x86_64-w64-mingw32/sys-root/mingw/bin/python-config: cannot execute: required file not found
rm %{buildroot}%{_mingw64_bindir}/python*-config
# remove files with dependency to python2.7.exe
rm %{buildroot}%{_mingw64_bindir}/2to3
rm %{buildroot}%{_mingw64_bindir}/idle
rm %{buildroot}%{_mingw64_bindir}/pydoc
rm %{buildroot}%{_mingw64_bindir}/smtpd.py
# remove files with dependency to /bin/sh
rm %{buildroot}%{_mingw64_libdir}/python2.7/config/makesetup
rm %{buildroot}%{_mingw64_libdir}/python2.7/config/install-sh
rm %{buildroot}%{_mingw64_libdir}/python2.7/plat-mingw/regen
rm %{buildroot}%{_mingw64_libdir}/python2.7/ctypes/macholib/fetch_macholib
%files
%defattr(-,root,root)
%if %shared
%{_mingw64_bindir}/libpython2.7.dll
%endif
%{_mingw64_bindir}/python2.7.exe
%{_mingw64_bindir}/python2.exe
%{_mingw64_bindir}/python.exe
%{_mingw64_libdir}/python2.7
%exclude %{_mingw64_libdir}/python2.7/config
%exclude %{_mingw64_libdir}/python2.7/test
%{_mingw64_libdir}/python2.7/config/Makefile
%{_mingw64_libdir}/python2.7/config/Setup
%{_mingw64_mandir}/man1/python*
%files devel
%defattr(-,root,root)
%{_mingw64_includedir}/python2.7
%if %shared
%{_mingw64_libdir}/libpython2.7.dll.a
%else
%{_mingw64_libdir}/libpython2.7.a
%endif
%{_mingw64_libdir}/python2.7/config
%exclude %{_mingw64_libdir}/python2.7/config/Makefile
%exclude %{_mingw64_libdir}/python2.7/config/Setup
%{_mingw64_libdir}/python2.7/test
%{_mingw64_libdir}/pkgconfig/python*.pc
%changelog