@@ -629,7 +629,7 @@ def process_setup_line(line, variant=None):
629
629
return bi
630
630
631
631
632
- def build_cpython (client , image , platform , optimized = False , musl = False ):
632
+ def build_cpython (client , image , platform , debug = False , optimized = False , musl = False ):
633
633
"""Build CPython in a Docker image'"""
634
634
python_archive = download_entry ('cpython-3.7' , BUILD )
635
635
setuptools_archive = download_entry ('setuptools' , BUILD )
@@ -639,7 +639,7 @@ def build_cpython(client, image, platform, optimized=False, musl=False):
639
639
static_modules_lines = [l .rstrip () for l in fh if not l .startswith (b'#' )]
640
640
641
641
setup = derive_setup_local (static_modules_lines , python_archive ,
642
- musl = musl )
642
+ musl = musl , debug = debug )
643
643
644
644
config_c_in = parse_config_c (setup ['config_c_in' ].decode ('utf-8' ))
645
645
setup_dist_content = setup ['setup_dist' ]
@@ -706,21 +706,27 @@ def build_cpython(client, image, platform, optimized=False, musl=False):
706
706
if musl :
707
707
env ['CC' ] = 'musl-clang'
708
708
709
+ if debug :
710
+ env ['CPYTHON_DEBUG' ] = '1'
709
711
if optimized :
710
712
env ['CPYTHON_OPTIMIZED' ] = '1'
711
713
712
714
container_exec (container , '/build/build-cpython.sh' ,
713
715
environment = env )
714
716
717
+ fully_qualified_name = 'python%s%sm' % (
718
+ '3.7' , 'd' if debug else ''
719
+ )
720
+
715
721
# Create PYTHON.json file describing this distribution.
716
722
python_info = {
717
723
'version' : '2' ,
718
724
'os' : 'linux' ,
719
725
'arch' : 'x86_64' ,
720
726
'python_flavor' : 'cpython' ,
721
727
'python_version' : DOWNLOADS ['cpython-3.7' ]['version' ],
722
- 'python_exe' : 'install/bin/python3.7' ,
723
- 'python_include' : 'install/include/python3.7m' ,
728
+ 'python_exe' : 'install/bin/%s' % fully_qualified_name ,
729
+ 'python_include' : 'install/include/%s' % fully_qualified_name ,
724
730
'python_stdlib' : 'install/lib/python3.7' ,
725
731
'build_info' : python_build_info (container , config_c_in ,
726
732
setup_dist_content , setup_local_content ),
@@ -740,6 +746,8 @@ def build_cpython(client, image, platform, optimized=False, musl=False):
740
746
741
747
if musl :
742
748
basename += '-musl'
749
+ if debug :
750
+ basename += '-debug'
743
751
if optimized :
744
752
basename += '-pgo'
745
753
@@ -764,6 +772,7 @@ def main():
764
772
return 1
765
773
766
774
parser = argparse .ArgumentParser ()
775
+ parser .add_argument ('--debug' , action = 'store_true' )
767
776
parser .add_argument ('--platform' )
768
777
parser .add_argument ('--optimized' , action = 'store_true' )
769
778
parser .add_argument ('action' )
@@ -775,6 +784,8 @@ def main():
775
784
name = action
776
785
if args .platform :
777
786
name += '-%s' % args .platform
787
+ if args .debug :
788
+ name += '-debug'
778
789
if args .optimized :
779
790
name += '-pgo'
780
791
@@ -823,7 +834,7 @@ def main():
823
834
824
835
elif action == 'cpython' :
825
836
build_cpython (client , get_image (client , 'build' ), platform = platform ,
826
- musl = musl , optimized = args .optimized )
837
+ musl = musl , debug = args . debug , optimized = args .optimized )
827
838
828
839
else :
829
840
print ('unknown build action: %s' % action )
0 commit comments