File mingw64-python3.spec of Package mingw64-python3
#
# spec file for package mingw64-python3
#
# 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/
#
%global _mingw64_find_requires_exclude api-ms-win-core-path-l1-1-0.dll cabinet.dll msi.dll msvcr100.dll %{nil}
# TODO CRTL-Z needs pressing return to work
# TODO add to mingw64-filesystem
%global _mingw64_debugsrcdir %{_mingw64_prefix}/src/debug
%define pyversion 3.9.10
%global pyvermm %(echo %{version} | gawk -F . '{ print $1 "." $2 }' )
%global _mingw64_python3_platlibdir %{_mingw64_libdir}/python%{pyvermm}
%define gitversion master+git.bb45aa7
%define shared 1
%define _check 0
%define readline 0
Name: mingw64-python3
Version: %{pyversion}
Release: 0
Summary: Python Interpreter
License: PSF-2.0 OR 0BSD
Group: Development/Languages/Python
Url: http://python.org/
Source0: python-cmake-buildsystem-%{gitversion}.tar.xz
Source1: Python-%{pyversion}.tgz
Source2: python3.pc
Source3: macros.mingw64-python3
# cmake
Patch01: 0001-Fix-build-error-on-linux-not-finding-panel.h.patch
Patch02: 0002-Fix-cross-building-Python-3.9.10.patch
Patch03: 0003-Use-static-zlilb-to-avoid-the-requirement-of-setting.patch
Patch04: 0004-Install-import-libraries-into-lib.patch
Patch05: 0005-Install-python-files-into-lib-python-mn-for-mingw.patch
Patch06: 0006-Install-cmake-files-in-lib-cmake-python-majorminor.patch
Patch07: 0007-Install-cmake-support-to-be-able-to-use-find_package.patch
Patch08: 0008-Disable-have-ipa-pure-const-bug-on-newer-gcc-compile.patch
Patch09: 0009-Fix-finding-wide-variant-of-ncurses-library.patch
Patch10: 0010-Fixed-invalid-inclusion-of-io.h-from-Python-source-c.patch
Patch11: 0011-Use-major.minor-for-version-number-on-mingw.patch
Patch12: 0012-Define-UINT-on-MINGW.patch
Patch13: 0013-Remove-macro-PREFIX-which-conflicts-a-type-with-the-.patch
Patch14: 0014-Add-missing-library-requirement-for-faulthandler-for.patch
Patch15: 0015-Enable-msvcrt-module-on-MinGW.patch
Patch16: 0016-Fix-file-name-case-issue-for-crypt32-library.patch
Patch17: 0017-Limit-compiling-vcdiv64.asm-to-msvc.patch
Patch18: 0018-set-have-decl-tzname.patch
Patch20: 0020-Do-not-define-copysign-which-will-break-compiling-gd.patch
Patch21: 0021-Add-3-suffix-to-python-executable.patch
Patch22: 0022-fix-patch-detection.patch
# python C code
Patch30: python-3.9.10-mingw-fixes.patch
Patch31: python-3.9.10-mingw-workaround.patch
Patch32: python-3.9.10-add-site-packages-path.patch
# python libs
Patch40: python-3.9.10-lib-fixes.patch
Patch41: python-3.9.10-sysconfig-return-version-with-dot.patch
#!BuildIgnore: post-build-checks
BuildRequires: mingw64-cross-cmake
BuildRequires: gcc-c++
BuildRequires: mingw64-cross-gcc-c++
BuildRequires: mingw64-cross-wine
BuildRequires: mingw64-dlfcn-win32-devel
BuildRequires: mingw64-libbz2-devel
BuildRequires: mingw64-libdb-devel
BuildRequires: mingw64-libffi-devel
BuildRequires: mingw64-libintl-devel
BuildRequires: mingw64-libopenssl-devel
BuildRequires: mingw64-ncurses-devel
%if %readline
BuildRequires: mingw64-readline-devel
%endif
BuildRequires: mingw64-sqlite-devel
BuildRequires: mingw64-tcl-devel
BuildRequires: mingw64-termcap-devel
BuildRequires: mingw64-tk-devel
BuildRequires: mingw64-winpthreads-devel
BuildRequires: mingw64-xz-devel
BuildRequires: mingw64-zlib-devel
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: tar
BuildRequires: zlib-devel
%_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 %{shared}
%package -n mingw64-libpython3
Summary: Python Interpreter base package
Group: Development/Libraries
%description -n mingw64-libpython3
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
%if %{shared}
Requires: mingw64-python3 = %{version}
%endif
%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 -N -n python-cmake-buildsystem-%{gitversion}
tar -xzf %{SOURCE1}
%autopatch -p1
# Remove all those shebangs
for dir in Python-%{pyversion}; do
find $dir -name '*.py' -type f -exec sed -i '1{/^#!.*python/ d}' '{}' \;
done
%build
%_mingw64_cmake \
-DBUILD_LIBPYTHON_SHARED=%{shared} \
-DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/wine \
-DCURSES_INCLUDE_DIRS=%{_mingw64_includedir}/ncursesw \
-DCURSES_INCLUDE_PATH=%{_mingw64_includedir}/ncursesw \
-DCURSES_LIBRARY=%{_mingw64_libdir}/libncursesw.dll.a \
-DDOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754=0 \
-DDOUBLE_IS_BIG_ENDIAN_IEEE754=0 \
-DDOUBLE_IS_LITTLE_ENDIAN_IEEE754=1 \
-DDOWNLOAD_SOURCES=OFF \
-DHAVE_ALIGNED_REQUIRED=0 \
-DHAVE_BROKEN_MBSTOWCS=0 \
-DHAVE_BROKEN_SEM_GETVALUE=0 \
-DHAVE_COMPUTED_GOTOS=0 \
-DHAVE_GLIBC_MEMMOVE_BUG=0 \
-DHAVE_IPA_PURE_CONST_BUG=0 \
-DHAVE_LONG_LONG_FORMAT=0 \
-DHAVE_SIZE_T_FORMAT=0 \
-DHAVE_WORKING_TZSET=0 \
-DLOG1P_DROPS_ZERO_SIGN=0 \
-DLibFFI_INCLUDE_DIR=%{_mingw64_includedir} \
-DLibFFI_LIBRARY=%{_mingw64_libdir}/libffi.dll.a \
-DLZMA_INCLUDE_PATH=%{_mingw64_includedir} \
-DLZMA_LIBRARY=%{_mingw64_libdir}/liblzma.dll.a \
-DPANEL_LIBRARY=%{_mingw64_libdir}/libpanelw.dll.a \
-DPOSIX_SEMAPHORES_NOT_ENABLED=0 \
-DSQLite3_INCLUDE_DIRS=%{_mingw64_includedir} \
-DSQLite3_LIBRARIES=%{_mingw64_libdir}/libsqlite3.dll.a \
-DTANH_PRESERVES_ZERO_SIGN=0 \
-DTCL_LIBRARY=%{_mingw64_libdir}/libtcl.dll.a \
-DTCL_INCLUDE_PATH=%{_mingw64_includedir} \
-DTK_LIBRARY=%{_mingw64_libdir}/libtk.dll.a \
-DTK_INCLUDE_PATH=%{_mingw64_includedir} \
-DUSE_BUILTIN_ZLIB=OFF \
-DUSE_SYSTEM_READLINE=ON \
-DUSE_SYSTEM_SQLITE3=ON \
-DUSE_SYSTEM_ZLIB=ON \
-DX87_DOUBLE_ROUNDING=0
# required to run generated tool _freeze_importlib.exe
%_mingw64_cross_wine_init
%_mingw64_cross_wine_start_session
%_mingw64_cmake_build
%check
%if %_check
%_mingw64_cross_wine_init
# wine path settings seems not to work from .pyd files
cp %{_mingw64_bindir}/*.dll build/bin
export WINEDEBUG=fixme-all
export TMPDIR=/tmp/python
wine build/bin/python.exe -E Python-%{pyversion}/Tools/scripts/run_tests.py || true
%endif
%install
# fix finding libz.dll caused by not set WINEPREFIX env var
%_mingw64_cross_wine_init
%_mingw64_cmake_install
# Install pkg-config
mkdir -p %{buildroot}%{_mingw64_libdir}/pkgconfig
install --mode=644 %{SOURCE2} %{buildroot}%{_mingw64_libdir}/pkgconfig/python3.pc
# Install rpm macros
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d
install --mode=644 %{SOURCE3} %{buildroot}%{_rpmconfigdir}/macros.d/$(basename %{SOURCE3})
# drop obsolete import libraries from extensions
find %{buildroot}%{_mingw64_libdir} -name 'lib*.dll.a' | grep -v libpython | xargs rm
# install python debug source
mkdir -p %{buildroot}%{_mingw64_debugsrcdir}
cp -a Python-%{pyversion} %{buildroot}%{_mingw64_debugsrcdir}
# rpmlintrc fix W: non-linux-readme
rm %{buildroot}%{_mingw64_debugsrcdir}/Python-3.9.10/Misc/README.AIX
# rpmlintrc fix W: version-control-internal-file
rm %{buildroot}%{_mingw64_debugsrcdir}/Python-3.9.10/Tools/peg_generator/.gitignore
%files
%defattr(-,root,root)
%{_mingw64_bindir}/python3.exe
%{_mingw64_bindir}/libpython*.py
%{_mingw64_python3_platlibdir}/*.py
%{_mingw64_python3_platlibdir}/asyncio
%{_mingw64_python3_platlibdir}/collections
%{_mingw64_python3_platlibdir}/concurrent
%{_mingw64_python3_platlibdir}/ctypes
%{_mingw64_python3_platlibdir}/curses
%{_mingw64_python3_platlibdir}/dbm
%{_mingw64_python3_platlibdir}/email
%{_mingw64_python3_platlibdir}/encodings
%{_mingw64_python3_platlibdir}/ensurepip
%{_mingw64_python3_platlibdir}/html
%{_mingw64_python3_platlibdir}/http
%{_mingw64_python3_platlibdir}/idlelib
%{_mingw64_python3_platlibdir}/importlib
%{_mingw64_python3_platlibdir}/json
%{_mingw64_python3_platlibdir}/lib-dynload
%{_mingw64_python3_platlibdir}/logging
%{_mingw64_python3_platlibdir}/msilib
%{_mingw64_python3_platlibdir}/multiprocessing
%{_mingw64_python3_platlibdir}/pydoc_data
%{_mingw64_python3_platlibdir}/site-packages
%{_mingw64_python3_platlibdir}/sqlite3
%{_mingw64_python3_platlibdir}/tkinter
%{_mingw64_python3_platlibdir}/turtledemo
%{_mingw64_python3_platlibdir}/urllib
%{_mingw64_python3_platlibdir}/wsgiref
%{_mingw64_python3_platlibdir}/xml
%{_mingw64_python3_platlibdir}/xmlrpc
%{_mingw64_python3_platlibdir}/zoneinfo
%{_mingw64_python3_platlibdir}/distutils
%{_mingw64_python3_platlibdir}/lib2to3
%{_mingw64_python3_platlibdir}/test
%{_mingw64_python3_platlibdir}/unittest
%{_mingw64_python3_platlibdir}/venv
%if %{shared}
%files -n mingw64-libpython3
%defattr(-,root,root)
%{_mingw64_bindir}/libpython*.dll
#%%{_mingw64_libdir}/python*/*.pyd
%endif
%files devel
%defattr(-,root,root)
%{_mingw64_includedir}/python*
%{_mingw64_libdir}/lib*.a
%{_mingw64_libdir}/pkgconfig
%{_mingw64_libdir}/cmake
%{_mingw64_libdir}/Tools
%{_mingw64_python3_platlibdir}/LICENSE.txt
%{_rpmconfigdir}/macros.d
#%%{_mingw64_python3_platlibdir}/config
%changelog