-
Notifications
You must be signed in to change notification settings - Fork 0
/
python.spec
3096 lines (2464 loc) · 117 KB
/
python.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SCL macros
%{!?scl:%global pkg_name %{name}}
%{?scl:%scl_package python}
# Turn off default SCL bytecompiling.
%{?scl:%global _turn_off_bytecompile 1}
# ==================
# Top-level metadata
# ==================
%global pybasever 3.10
# pybasever without the dot:
%global pyshortver 310
Name: %{?scl_prefix}python
Summary: Interpreter of the Python programming language
URL: https://www.python.org/
# WARNING When rebasing to a new Python version,
# remember to update the python3-docs package as well
%global general_version %{pybasever}.0
#global prerel ...
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 1%{?dist}
License: Python
# ==================================
# Conditionals controlling the build
# ==================================
# Note that the bcond macros are named for the CLI option they create.
# "%%bcond_without" means "ENABLE by default and create a --without option"
# Flat package, i.e. python36, python37, python38 for tox etc.
# WARNING: This also influences the main_python bcond below.
# in Fedora, never turn this on for the python3 package
# and always keep it on for python37 etc.
# WARNING: This does not change the package name and summary above.
%bcond_with flatpackage
# Main Python, i.e. whether this is the main Python version in the distribution
# that owns /usr/bin/python3 and other unique paths
%bcond_with main_python
# When bootstrapping python3, we need to build setuptools.
# but setuptools BR python3-devel and that brings in python3-rpm-generators;
# python3-rpm-generators needs python3-setuptools, so we cannot have it yet.
#
# Procedure: https://fedoraproject.org/wiki/SIGs/Python/UpgradingPython
#
# IMPORTANT: When bootstrapping, it's very likely the wheels for pip and
# setuptools are not available. Turn off the rpmwheels bcond until
# the two packages are built with wheels to get around the issue.
# temporary enable bootstrap
%bcond_without bootstrap
# Whether to use RPM build wheels from the python-{pip,setuptools}-wheel package
# Uses upstream bundled prebuilt wheels otherwise
%bcond_with rpmwheels
%global pip_version 21.2.3
%global setuptools_version 57.4.0
# Expensive optimizations (mainly, profile-guided optimizations)
%bcond_without optimizations
# Run the test suite in %%check
%bcond_without tests
# Extra build for debugging the interpreter or C-API extensions
# (the -debug subpackages)
%if %{with flatpackage}
%bcond_with debug_build
%else
%bcond_without debug_build
%endif
# Support for the GDB debugger
%bcond_without gdb_hooks
# The dbm.gnu module (key-value database)
%bcond_without gdbm
# Main interpreter loop optimization
%bcond_without computed_gotos
# Support for the Valgrind debugger/profiler
%ifarch %{valgrind_arches}
%bcond_without valgrind
%else
%bcond_with valgrind
%endif
# =====================
# General global macros
# =====================
# SCL
# We want to byte-compile the .py files within the packages using the new
# python3 binary.
#
# Unfortunately, rpmbuild's infrastructure requires us to jump through some
# hoops to avoid byte-compiling with the system python 2 version:
# /usr/lib/rpm/redhat/macros sets up build policy that (amongst other things)
# defines __os_install_post. In particular, "brp-python-bytecompile" is
# invoked without an argument thus using the wrong version of python
# (/usr/bin/python, rather than the freshly built python), thus leading to
# numerous syntax errors, and incorrect magic numbers in the .pyc files. We
# thus override __os_install_post to avoid invoking this script:
%global __os_install_post /usr/lib/rpm/brp-%{?scl:scl-}compress %{?_scl_root}\
%{!?__debug_package:/usr/lib/rpm/brp-strip %{__strip}} \
/usr/lib/rpm/brp-strip-static-archive %{__strip} \
/usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} \
/usr/lib/rpm/redhat/brp-python-hardlink
# to remove the invocation of brp-python-bytecompile, whilst keeping the
# invocation of brp-python-hardlink (since this should still work for python3
# pyc/pyo files)
# SCL:
%if %{without bootstrap}
BuildRequires: %{?scl_prefix}python-rpm-macros
%else
# These two macros are defined in the `macros.python3` file, part of python-devel.
# We define them here as well so they are available when building Python
# itself, as Python does not have a BuildRequires on the `python-devel` package
# and thus it's not part of its buildroot.
# Adding a build-time dependency on `python-devel` was contemplated but decided
# against because it could create hard-to-debug issues: python-devel installs
# header files into the buildroot which could be then mistakenly used during
# the building of a newer Python version if there is a bug in the build
# scripts.
# Note that the macros point to a file in the buildroot which will already be
# copied there by the time this macros are invoked in %%__os_install_post.
%{?scl:%global python310_python_provides %{buildroot}%{_root_prefix}/lib/rpm/pythondeps-scl-310.sh --provides %{scl}-}
%{?scl:%global python310_python_requires %{buildroot}%{_root_prefix}/lib/rpm/pythondeps-scl-310.sh --requires %{scl}-}
%endif
# Set python3_pkgversion so that python_provide macro works for python310-
# prefixes in this spec file
# This is also set in the python310-rpm-macros package so that it works in other
# packages of this module.
%global python3_pkgversion 310
%global pylibdir %{_libdir}/python%{pybasever}
%global dynload_dir %{pylibdir}/lib-dynload
# ABIFLAGS, LDVERSION and SOABI are in the upstream configure.ac
# See PEP 3149 for some background: http://www.python.org/dev/peps/pep-3149/
%global ABIFLAGS_optimized %{nil}
%global ABIFLAGS_debug d
%global LDVERSION_optimized %{pybasever}%{ABIFLAGS_optimized}
%global LDVERSION_debug %{pybasever}%{ABIFLAGS_debug}
%global SOABI_optimized cpython-%{pyshortver}%{ABIFLAGS_optimized}-%{_arch}-linux%{_gnu}
%global SOABI_debug cpython-%{pyshortver}%{ABIFLAGS_debug}-%{_arch}-linux%{_gnu}
# All bytecode files are in a __pycache__ subdirectory, with a name
# reflecting the version of the bytecode.
# See PEP 3147: http://www.python.org/dev/peps/pep-3147/
# For example,
# foo/bar.py
# has bytecode at:
# foo/__pycache__/bar.cpython-%%{pyshortver}.pyc
# foo/__pycache__/bar.cpython-%%{pyshortver}.opt-1.pyc
# foo/__pycache__/bar.cpython-%%{pyshortver}.opt-2.pyc
%global bytecode_suffixes .cpython-%{pyshortver}*.pyc
# Python's configure script defines SOVERSION, and this is used in the Makefile
# to determine INSTSONAME, the name of the libpython DSO:
# LDLIBRARY='libpython$(VERSION).so'
# INSTSONAME="$LDLIBRARY".$SOVERSION
# We mirror this here in order to make it easier to add the -gdb.py hooks.
# (if these get out of sync, the payload of the libs subpackage will fail
# and halt the build)
%global py_SOVERSION %{scl}-1.0
%global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION}
%global py_INSTSONAME_debug libpython%{LDVERSION_debug}.so.%{py_SOVERSION}
# Disable automatic bytecompilation. The python3 binary is not yet be
# available in /usr/bin when Python is built. Also, the bytecompilation fails
# on files that test invalid syntax.
%undefine py_auto_byte_compile
# For multilib support, files that are different between 32- and 64-bit arches
# need different filenames. Use "64" or "32" according to the word size.
# Currently, the best way to determine an architecture's word size happens to
# be checking %%{_lib}.
%if "%{_lib}" == "lib64"
%global wordsize 64
%else
%global wordsize 32
%endif
# =======================
# Build-time requirements
# =======================
# (keep this list alphabetized)
%{?scl:BuildRequires: %{scl}-runtime}
BuildRequires: autoconf
BuildRequires: bluez-libs-devel
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: desktop-file-utils
BuildRequires: expat-devel
BuildRequires: findutils
# SCL: build with gcc from devtoolset SCL
# Update to new devtoolset version if necessary
%global dts devtoolset-9
BuildRequires: %{dts}-gcc-c++
# BuildRequires: gcc-c++
%if %{with gdbm}
BuildRequires: gdbm-devel
%endif
# BuildRequires: glibc-all-langpacks - SCL: Disabled
BuildRequires: glibc-devel
BuildRequires: gmp-devel
BuildRequires: libappstream-glib
BuildRequires: libffi-devel
# BuildRequires: libnsl2-devel - SCL: Disabled
BuildRequires: libtirpc-devel
BuildRequires: libGL-devel
BuildRequires: libuuid-devel
BuildRequires: libX11-devel
BuildRequires: ncurses-devel
%if 0%{?fedora} || 0%{?rhel} >= 8
BuildRequires: openssl-devel
%else
BuildRequires: openssl11-devel
%endif
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: redhat-rpm-config
BuildRequires: sqlite-devel
BuildRequires: gdb
BuildRequires: tar
BuildRequires: tcl-devel
BuildRequires: tix-devel
BuildRequires: tk-devel
%if %{with valgrind}
BuildRequires: valgrind-devel
%endif
BuildRequires: xz-devel
BuildRequires: zlib-devel
BuildRequires: /usr/bin/dtrace
# workaround http://bugs.python.org/issue19804 (test_uuid requires ifconfig)
# SCL: changed from file name to package name
BuildRequires: net-tools
%if %{with rpmwheels}
BuildRequires: %{?scl_prefix}python-setuptools-wheel
BuildRequires: %{?scl_prefix}python-pip-wheel
%endif
%if %{without bootstrap}
# for make regen-all and distutils.tests.test_bdist_rpm
BuildRequires: %{?scl_prefix}python
%endif
# =======================
# Source code and patches
# =======================
Source0: %{url}ftp/python/%{general_version}/Python-%{upstream_version}.tar.xz
# A simple script to check timestamps of bytecode files
# Run in check section with Python that is currently being built
# Originally written by bkabrda
Source8: check-pyc-timestamps.py
# Desktop menu entry for idle3
Source10: idle3.desktop
# AppData file for idle3
Source11: idle3.appdata.xml
# SCL-custom version of pythondeps.sh
# Append 310 to not collide with python27 SCL
Source20: pythondeps-scl-310.sh
# SCL:
# Append 310 for the same reason here
Source21: brp-python-bytecompile-with-scl-python-310
# SCL:
# Supply an RPM macro "py_byte_compile" for the python3-devel subpackage
# to enable specfiles to selectively byte-compile individual files and paths
# with different Python runtimes as necessary:
Source22: macros.pybytecompile
# SCL:
# Supply various useful macros for building python 3 modules:
# __python3, python3_sitelib, python3_sitearch
Source23: macros.python3
Source24: macros.python-scl
Source25: macros.python-srpm
# 00001 #
# Fixup distutils/unixccompiler.py to remove standard library path from rpath:
# Was Patch0 in ivazquez' python3000 specfile:
Patch1: 00001-rpath.patch
# DOESN'T need anymore after --with-platlibdir=%{_lib} support in python 3.9
# bpo-1294959
# 00102 #
# Change the various install paths to use /usr/lib64/ instead or /usr/lib
# Only used when "%%{_lib}" == "lib64"
# Not yet sent upstream.
#
# Patch102: 00102-lib64.patch
# 00111 #
# fixed by --without-static-libpython and it's built and enabled by default in configure
# Patch the Makefile.pre.in so that the generated Makefile doesn't try to build
# a libpythonMAJOR.MINOR.a
# See https://bugzilla.redhat.com/show_bug.cgi?id=556092
# Downstream only: not appropriate for upstream
#Patch111: 00111-no-static-lib.patch
# 00189 #
# doesn't need anymore since --with-wheel-pkg-dir directive
# Instead of bundled wheels, use our SCL RPM packaged wheels from
# /usr/share/python-wheels
#Patch189: 00189-use-rpm-wheels.patch
# 00251 # 0952e38e5bf725ebbab48b13a35566e30635ddf8
# Change user install location
#
# Change the values of sysconfig's "posix_prefix" install scheme to /usr/local
# when RPM build or venv/virtualenv is not detected,
# to make pip, sysconfig and distutils install into an isolated location.
#
# The original values are saved as an additional "rpm_prefix" install scheme.
#
# The site module adds the /usr/local paths to sys.path when site packages are
# enabled and RPM build is not detected.
#
# Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
#
# Rewrote in Fedora 36+ to patch sysconfig instead of distutils,
# see https://discuss.python.org/t/pep-632-deprecate-distutils-module/5134/104
#
# Downstream only for now, waiting for https://bugs.python.org/issue43976
Patch251: 00251-change-user-install-location.patch
# 00251
# Set values of prefix and exec_prefix in distutils install command
# to /usr/local if executable is /usr/bin/python* and RPM build
# is not detected to make pip and distutils install into separate location
# Fedora Change: https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
#
# SCL: This patch contains hardcoded location for /usr/local that needed to be
# modified for SCLs: the `PREFIXES.insert` variable now contains a hardcoded
# path to /usr/local inside the SCL root folder
#Patch251: 00251-change-user-install-location.patch
# 00274 #
# Upstream uses Debian-style architecture naming. Change to match Fedora.
Patch274: 00274-fix-arch-names.patch
# 00300 #
# Traditional SCL patch to change so version
# Downstream only
Patch300: 00300-change-so-version-scl.patch
# 00328 #
# Restore pyc to TIMESTAMP invalidation mode as default in rpmbubild
# See https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/57#comment-27426
Patch328: 00328-pyc-timestamp-invalidation-mode.patch
# 00500 #
# Fix freed memory access in :class:`pyexpat.xmlparser` when building it with an
# installed expat library <= 2.2.0. https://bugs.python.org/issue45329
Patch500: 00500-fix-pyexpat.c-segfault.patch
# 00501 #
# Can't find correctly openssl11 libs in configure script
Patch501: 00501-openssl11-configure.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
# please try to keep the patch numbers in-sync between all specfiles.
#
# More information, and a patch number catalog, is at:
#
# https://fedoraproject.org/wiki/SIGs/Python/PythonPatches
#
# The patches are stored and rebased at:
#
# https://github.com/fedora-python/cpython
# ==========================================
# Descriptions, and metadata for subpackages
# ==========================================
# People might want to dnf install pythonX.Y instead of pythonXY;
# we enable this in both flat and nonflat package.
Provides: %{?scl_prefix}python%{pybasever} = %{version}-%{release}
# SCL: Let's also provide python3
Provides: %{?scl_prefix}python3 = %{version}-%{release}
%if %{without flatpackage}
# Packages with Python modules in standard locations automatically
# depend on python(abi). Provide that here.
Provides: %{?scl_prefix}python(abi) = %{pybasever}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
# In order to support multiple Python interpreters for development purposes,
# packages with the naming scheme flatpackage (e.g. python35) exist for
# non-default versions of Python 3.
# For consistency, and to keep the upgrade path clean, we Provide/Obsolete
# these names here.
Provides: %{?scl_prefix}python%{pyshortver} = %{version}-%{release}
%if %{with main_python}
# https://fedoraproject.org/wiki/Changes/Move_usr_bin_python_into_separate_package
# https://fedoraproject.org/wiki/Changes/Python_means_Python3
# We recommend /usr/bin/python so users get it by default
# Versioned recommends are problematic, and we know that the package requires
# python3 back with fixed version, so we just use the path here:
Recommends: %{_bindir}/python
%endif
# In Fedora 31, /usr/bin/pydoc was moved here from Python 2.
# Ideally we'd have an explicit conflict with "/usr/bin/pydoc < 3",
# but file provides aren't versioned and the file moved across packages.
# Instead, we rely on the conflict in python3-libs.
%if %{without bootstrap}
# Previously, this was required for our rewheel patch to work.
# This is technically no longer needed, but we keep it recommended
# for the developer experience.
# SCL: Recommends tags don't work on RHEL7 and so:
# SCL: Changed from Recommends to Requires
Requires: %{?scl_prefix}python-setuptools
# SCL: Disabled this Recommends
# Recommends: %{?scl_prefix}python-pip
%endif
# This prevents ALL subpackages built from this spec to require
# /usr/bin/python3*. Granularity per subpackage is impossible.
# It's intended for the libs package not to drag in the interpreter, see
# https://bugzilla.redhat.com/show_bug.cgi?id=1547131
# All others require %%{name} anyway.
%global __requires_exclude ^/usr/bin/python3
# The description used both for the SRPM and the main `python3` subpackage:
%description
Python is an accessible, high-level, dynamically typed, interpreted programming
language, designed with an emphasis on code readability.
It includes an extensive standard library, and has a vast ecosystem of
third-party libraries.
The %{name} package provides the "python3" executable: the reference
interpreter for the Python language, version 3.
The majority of its standard library is provided in the %{name}-libs package,
which should be installed automatically along with %{name}.
The remaining parts of the Python standard library are broken out into the
%{name}-tkinter and %{name}-test packages, which may need to be installed
separately.
Documentation for Python is provided in the %{name}-docs package.
Packages containing additional libraries for Python are generally named with
the "%{name}-" prefix.
%if %{with main_python}
# https://fedoraproject.org/wiki/Changes/Move_usr_bin_python_into_separate_package
# https://fedoraproject.org/wiki/Changes/Python_means_Python3
%package -n python-unversioned-command
Summary: The "python" command that runs Python 3
BuildArch: noarch
%{?scl:Requires: %{scl}-runtime}
# In theory this could require any python3 version
Requires: python3 == %{version}-%{release}
# But since we want to provide versioned python, we require exact version
Provides: python = %{version}-%{release}
# This also save us an explicit conflict for older python3 builds
%description -n python-unversioned-command
This package contains /usr/bin/python - the "python" command that runs Python 3.
%endif # with main_python
%package libs
Summary: Python runtime libraries
%{?scl:Requires: %{scl}-runtime}
%if %{with rpmwheels}
Requires: %{?scl_prefix}python-setuptools-wheel
Requires: %{?scl_prefix}python-pip-wheel
%else
Provides: bundled(%{?scl_prefix}python-pip) = %{pip_version}
Provides: bundled(%{?scl_prefix}python-setuptools) = %{setuptools_version}
%endif
# There are files in the standard library that have python shebang.
# We've filtered the automatic requirement out so libs are installable without
# the main package. This however makes it pulled in by default.
# See https://bugzilla.redhat.com/show_bug.cgi?id=1547131
# SCL: Changed from Recommends to Requires
Requires: %{name}%{?_isa} = %{version}-%{release}
%description libs
This package contains runtime libraries for use by Python:
- the majority of the Python standard library
- a dynamically linked library for use by applications that embed Python as
a scripting language, and by the main "python3" executable
%package devel
Summary: Libraries and header files needed for Python development
%{?scl:Requires: %{scl}-runtime}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
# SCL: BR on python-rpm-macros moved to the macros definitions
Requires: %{?scl_prefix}python-rpm-macros
%if %{without bootstrap}
Requires: %{?scl_prefix}python-setuptools
%endif
# we filtered provides of pkgconfig on rhel7 so we need to manully re add them
Provides: %{?scl_prefix}pkgconfig(python) = %{version}-%{release}
Provides: %{?scl_prefix}pkgconfig(python-3.10m) = %{version}-%{release}
Provides: %{?scl_prefix}pkgconfig(python-3.10) = %{version}-%{release}
Provides: %{?scl_prefix}pkgconfig(python3) = %{version}-%{release}
# Fix for rhbz#1144601
Requires: scl-utils-build
%description devel
This package contains the header files and configuration needed to compile
Python extension modules (typically written in C or C++), to embed Python
into other programs, and to make binary distributions for Python libraries.
It also contains the necessary macros to build RPM packages with Python modules
and 2to3 tool, an automatic source converter from Python 2.X.
If you want to build an RPM against the python310 module, you also need to
install the python310-rpm-macros package.
%package idle
Summary: A basic graphical development environment for Python
%{?scl:Requires: %{scl}-runtime}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-tkinter = %{version}-%{release}
%description idle
IDLE is Python’s Integrated Development and Learning Environment.
IDLE has the following features: Python shell window (interactive
interpreter) with colorizing of code input, output, and error messages;
multi-window text editor with multiple undo, Python colorizing,
smart indent, call tips, auto completion, and other features;
search within any window, replace within editor windows, and
search through multiple files (grep); debugger with persistent
breakpoints, stepping, and viewing of global and local namespaces;
configuration, browsers, and other dialogs.
%package tkinter
Summary: A GUI toolkit for Python
%{?scl:Requires: %{scl}-runtime}
Requires: %{name} = %{version}-%{release}
%description tkinter
The Tkinter (Tk interface) library is a graphical user interface toolkit for
the Python programming language.
%package test
Summary: The self-test suite for the main python3 package
%{?scl:Requires: %{scl}-runtime}
Requires: %{name} = %{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%description test
The self-test suite for the Python interpreter.
This is only useful to test Python itself. For testing general Python code,
you should use the unittest module from %{name}-libs, or a library such as
%{name}-pytest or %{name}-nose.
%if %{with debug_build}
%package debug
Summary: Debug version of the Python runtime
%{?scl:Requires: %{scl}-runtime}
# The debug build is an all-in-one package version of the regular build, and
# shares the same .py/.pyc files and directories as the regular build. Hence
# we depend on all of the subpackages of the regular build:
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Requires: %{name}-devel%{?_isa} = %{version}-%{release}
Requires: %{name}-test%{?_isa} = %{version}-%{release}
Requires: %{name}-tkinter%{?_isa} = %{version}-%{release}
Requires: %{name}-idle%{?_isa} = %{version}-%{release}
# we filtered provides of pkgconfig on rhel7 so we need to manully re add them
Provides: %{?scl_prefix}pkgconfig(python-3.10dm) = %{version}-%{release}
%description debug
python310-debug provides a version of the Python runtime with numerous debugging
features enabled, aimed at advanced Python users such as developers of Python
extension modules.
This version uses more memory and will be slower than the regular Python build,
but is useful for tracking down reference-counting issues and other bugs.
The debug build shares installation directories with the standard Python
runtime. Python modules -- source (.py), bytecode (.pyc), and C-API extensions
(.cpython*.so) -- are compatible between this and the standard version
of Python.
The debug runtime additionally supports debug builds of C-API extensions
(with the "d" ABI flag) for debugging issues in those extensions.
%endif # with debug_build
%else # with flatpackage
# We'll not provide this, on purpose
# No package in Fedora shall ever depend on flatpackage via this
%global __requires_exclude ^python\\(abi\\) = 3\\..$
%global __provides_exclude ^python\\(abi\\) = 3\\..$
%if %{with rpmwheels}
Requires: %{?scl_prefix}python-setuptools-wheel
Requires: %{?scl_prefix}python-pip-wheel
%else
Provides: bundled(%{?scl_prefix}python-pip) = %{pip_version}
Provides: bundled(%{?scl_prefix}python-setuptools) = %{setuptools_version}
%endif
# The description for the flat package
%description
Python %{pybasever} package for developers.
This package exists to allow developers to test their code against a newer
version of Python. This is not a full Python stack and if you wish to run
your applications with Python %{pybasever}, update your Fedora to a newer
version once Python %{pybasever} is stable.
%endif # with flatpackage
# python-rpm-macros subpackages
%package rpm-macros
Summary: RPM macros for building RPMs with Python 3.10
BuildArch: noarch
%{?scl:Requires: %{scl}-runtime}
%description rpm-macros
RPM macros for building RPMs with Python 3.10 from the python310 module.
If you want to build an RPM against the python310 module, you need to
BuildRequire: python310-rpm-macros.
%package srpm-macros
Summary: SRPM macros for building RPMs with Python 3.10
BuildArch: noarch
%{?scl:Requires: %{scl}-runtime}
%description srpm-macros
SRPM macros for building RPMs with Python 3.10 from the python310 module.
These macros need to be in the minimal buildroot.
# ======================================================
# The prep phase of the build:
# ======================================================
%prep
%setup -q -n Python-%{upstream_version}
# Remove all exe files to ensure we are not shipping prebuilt binaries
# note that those are only used to create Microsoft Windows installers
# and that functionality is broken on Linux anyway
find -name '*.exe' -print -delete
# Remove bundled libraries to ensure that we're using the system copy.
rm -r Modules/expat
#
# Apply patches:
#
%patch1 -p1
#if "%{_lib}" == "lib64"
#patch102 -p1
#endif
#patch111 -p1
%if %{with rpmwheels}
# patch is not needed anymore
#patch189 -p1
rm Lib/ensurepip/_bundled/*.whl
%endif
%patch251 -p1
%patch274 -p1
%patch328 -p1
#patch329 -p1
#patch359 -p1
#patch365 -p1
%patch500 -p1
%if 0%{?rhel} == 7
%patch501 -p1
%endif
cat %{PATCH300} | sed -e "s/__SCL_NAME__/%{?scl}/" \
| patch -p1
# Remove files that should be generated by the build
# (This is after patching, so that we can use patches directly from upstream)
rm configure pyconfig.h.in
# ======================================================
# Configuring and building the code:
# ======================================================
# SCL:
# filter pkgconfig Requires/Provides on rhel7 as filter_from doesnt work there
%global __provides_exclude ^pkgconfig\\(.*$
%build
# Regenerate the configure script and pyconfig.h.in
autoconf
autoheader
# Remember the current directory (which has sources and the configure script),
# so we can refer to it after we "cd" elsewhere.
topdir=$(pwd)
# Get proper option names from bconds
%if %{with computed_gotos}
%global computed_gotos_flag yes
%else
%global computed_gotos_flag no
%endif
%if %{with optimizations}
%global optimizations_flag "--enable-optimizations"
%else
%global optimizations_flag "--disable-optimizations"
%endif
# Set common compiler/linker flags
# We utilize the %%extension_...flags macros here so users building C/C++
# extensions with our python won't get all the compiler/linker flags used
# in Fedora RPMs.
# Standard library built here will still use the %%build_...flags,
# Fedora packages utilizing %%py3_build will use them as well
# https://fedoraproject.org/wiki/Changes/Python_Extension_Flags
# SCL: %%extension_... flags are not available in RHEL7, reverting to old flags
export CFLAGS="-I%{_includedir} $RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CFLAGS_NODIST="-I%{_includedir} $RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv -fno-semantic-interposition"
export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CPPFLAGS="$(pkg-config --cflags-only-I libffi)"
export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export LINKCC="gcc"
%if 0%{?rhel} == 7
export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)"
%else
export CFLAGS="$CFLAGS $(pkg-config --cflags openssl)"
%endif
# Passing to the dynamic linker parameters -rpath and --enable-new-dtags causes
# ld to set RUNPATH instead of RPATH in the executables and libraries
# Setting RUNPATH resolves rhbz#1479406
%if 0%{?rhel} == 7
export LDFLAGS="-L%{_libdir}$RPM_LD_FLAGS -Wl,-rpath,%{_libdir} -Wl,--enable-new-dtags -g $(pkg-config --libs-only-L openssl11)"
export LDFLAGS_NODIST="-L%{_libdir}$RPM_LD_FLAGS -Wl,-rpath,%{_libdir} -Wl,--enable-new-dtags -fno-semantic-interposition -g $(pkg-config --libs-only-L openssl11)"
%else
export LDFLAGS="-L%{_libdir}$RPM_LD_FLAGS -Wl,-rpath,%{_libdir} -Wl,--enable-new-dtags -g $(pkg-config --libs-only-L openssl)"
export LDFLAGS_NODIST="-L%{_libdir}$RPM_LD_FLAGS -Wl,-rpath,%{_libdir} -Wl,--enable-new-dtags -fno-semantic-interposition -g $(pkg-config --libs-only-L openssl)"
%endif
# We can build several different configurations of Python: regular and debug.
# Define a common function that does one build:
BuildPython() {
ConfName=$1
ExtraConfigArgs=$2
MoreCFlags=$3
# Each build is done in its own directory
ConfDir=build/$ConfName
echo STARTING: BUILD OF PYTHON FOR CONFIGURATION: $ConfName
mkdir -p $ConfDir
pushd $ConfDir
# Normally, %%configure looks for the "configure" script in the current
# directory.
# Since we changed directories, we need to tell %%configure where to look.
%global _configure $topdir/configure
%configure \
--enable-shared \
--with-computed-gotos=%{computed_gotos_flag} \
--with-dbmliborder=gdbm:ndbm:bdb \
--with-system-expat \
--with-system-ffi \
--enable-loadable-sqlite-extensions \
--with-dtrace \
--with-lto \
--with-ssl-default-suites=openssl \
--with-platlibdir=%{_lib} \
%if %{with rpmwheels}
--with-wheel-pkg-dir=%{?scl_prefix}%{_datadir}/python-wheels \
%endif
%if %{with valgrind}
--with-valgrind \
%endif
$ExtraConfigArgs \
%{nil}
%global flags_override EXTRA_CFLAGS="$MoreCFlags" CFLAGS_NODIST="$CFLAGS_NODIST $MoreCFlags"
%if %{without bootstrap}
# Regenerate generated files (needs python3)
%make_build %{flags_override} regen-all PYTHON_FOR_REGEN="python%{pybasever}"
%endif
# Invoke the build
%make_build %{flags_override}
popd
echo FINISHED: BUILD OF PYTHON FOR CONFIGURATION: $ConfName
}
# Call the above to build each configuration.
export -f BuildPython
export topdir
%{?scl:scl enable %{scl} %{?dts} - << \EOF}
%if %{with debug_build}
BuildPython debug \
"--without-ensurepip --with-pydebug" \
"-Og"
%endif # with debug_build
BuildPython optimized \
"--without-ensurepip %{optimizations_flag}" \
""
%{?scl:EOF}
# ======================================================
# Installing the built code:
# ======================================================
%install
# As in %%build, remember the current directory
topdir=$(pwd)
# install SCL custom RPM scripts
%{?scl:mkdir -p %{buildroot}%{_root_prefix}/lib/rpm/redhat}
%{?scl:cp -a %{SOURCE20} %{buildroot}%{_root_prefix}/lib/rpm}
%{?scl:cp -a %{SOURCE21} %{buildroot}%{_root_prefix}/lib/rpm/redhat}
# We install a collection of hooks for gdb that make it easier to debug
# executables linked against libpython3* (such as /usr/bin/python3 itself)
#
# These hooks are implemented in Python itself (though they are for the version
# of python that gdb is linked with)
#
# gdb-archer looks for them in the same path as the ELF file or its .debug
# file, with a -gdb.py suffix.
# We put them next to the debug file, because ldconfig would complain if
# it found non-library files directly in /usr/lib/
# (see https://bugzilla.redhat.com/show_bug.cgi?id=562980)
#
# We'll put these files in the debuginfo package by installing them to e.g.:
# /usr/lib/debug/usr/lib/libpython3.2.so.1.0.debug-gdb.py
# (note that the debug path is /usr/lib/debug for both 32/64 bit)
#
# See https://fedoraproject.org/wiki/Features/EasierPythonDebugging for more
# information
%if %{with gdb_hooks}
DirHoldingGdbPy=%{?scl:%_root_prefix}%{!?scl:%_prefix}/lib/debug/%{_libdir}
mkdir -p %{buildroot}$DirHoldingGdbPy
%endif # with gdb_hooks
# Multilib support for pyconfig.h
# 32- and 64-bit versions of pyconfig.h are different. For multilib support
# (making it possible to install 32- and 64-bit versions simultaneously),
# we need to install them under different filenames, and to make the common
# "pyconfig.h" include the right file based on architecture.
# See https://bugzilla.redhat.com/show_bug.cgi?id=192747
# Filanames are defined here:
%global _pyconfig32_h pyconfig-32.h
%global _pyconfig64_h pyconfig-64.h
%global _pyconfig_h pyconfig-%{wordsize}.h
# Use a common function to do an install for all our configurations:
InstallPython() {
ConfName=$1
PyInstSoName=$2
MoreCFlags=$3
LDVersion=$4
# Switch to the directory with this configuration's built files
ConfDir=build/$ConfName
echo STARTING: INSTALL OF PYTHON FOR CONFIGURATION: $ConfName
mkdir -p $ConfDir
pushd $ConfDir
make \
DESTDIR=%{buildroot} \
INSTALL="install -p" \
EXTRA_CFLAGS="$MoreCFlags" \
install
popd
%if %{with gdb_hooks}
# See comment on $DirHoldingGdbPy above
PathOfGdbPy=$DirHoldingGdbPy/$PyInstSoName-%{version}-%{release}.%{_arch}.debug-gdb.py
cp Tools/gdb/libpython.py %{buildroot}$PathOfGdbPy
%endif # with gdb_hooks
# Rename the -devel script that differs on different arches to arch specific name
mv %{buildroot}%{_bindir}/python${LDVersion}-{,`uname -m`-}config
echo -e '#!/bin/sh\nexec `dirname $0`/python'${LDVersion}'-`uname -m`-config "$@"' > \
%{buildroot}%{_bindir}/python${LDVersion}-config
echo '[ $? -eq 127 ] && echo "Could not find python'${LDVersion}'-`uname -m`-config. Look around to see available arches." >&2' >> \
%{buildroot}%{_bindir}/python${LDVersion}-config
chmod +x %{buildroot}%{_bindir}/python${LDVersion}-config
# Make python3-devel multilib-ready
mv %{buildroot}%{_includedir}/python${LDVersion}/pyconfig.h \
%{buildroot}%{_includedir}/python${LDVersion}/%{_pyconfig_h}
cat > %{buildroot}%{_includedir}/python${LDVersion}/pyconfig.h << EOF
#include <bits/wordsize.h>
#if __WORDSIZE == 32
#include "%{_pyconfig32_h}"
#elif __WORDSIZE == 64
#include "%{_pyconfig64_h}"
#else
#error "Unknown word size"
#endif
EOF
echo FINISHED: INSTALL OF PYTHON FOR CONFIGURATION: $ConfName
}
# Install the "debug" build first; any common files will be overridden with
# later builds
%if %{with debug_build}
InstallPython debug \
%{py_INSTSONAME_debug} \
-O0 \
%{LDVERSION_debug}
%endif # with debug_build
# Now the optimized build:
InstallPython optimized \
%{py_INSTSONAME_optimized} \
"" \
%{LDVERSION_optimized}
# Install directories for additional packages
install -d -m 0755 %{buildroot}%{pylibdir}/site-packages/__pycache__
%if "%{_lib}" == "lib64"
# The 64-bit version needs to create "site-packages" in /usr/lib/ (for