1
1
# -*- coding: utf-8 -*-
2
2
#
3
+ # WinPython build script
3
4
# Copyright © 2012 Pierre Raybaut
4
5
# Copyright © 2014-2024+ The Winpython development team https://github.com/winpython/
5
6
# Licensed under the terms of the MIT License
6
7
# (see winpython/__init__.py for details)
7
8
8
- """
9
- WinPython build script
10
- """
11
-
12
9
import os
13
10
import re
14
11
import shutil
@@ -66,7 +63,7 @@ def replace_lines_in_file(filepath: Path, replacements: list[tuple[str, str]]):
66
63
for index , line in enumerate (lines ):
67
64
for prefix , new_text in replacements :
68
65
start_prefix = prefix
69
- if prefix not in ( "Icon" , "OutFile" ) and not prefix .startswith ("!" ):
66
+ if not prefix .startswith ("!" ):
70
67
start_prefix = "set " + prefix
71
68
if line .startswith (start_prefix + "=" ):
72
69
updated_lines [index ] = f"{ start_prefix } ={ new_text } \n "
@@ -90,13 +87,12 @@ def build_installer_7zip(
90
87
output_script_path: Path to save the generated 7-Zip script.
91
88
replacements: A list of tuples for text replacements (prefix, new_text).
92
89
"""
93
- sevenzip_executable = find_7zip_executable ()
94
90
shutil .copy (script_template_path , output_script_path )
95
91
96
92
# Standard replacements for all 7zip scripts
97
93
data_to_replace = [
98
94
("PORTABLE_DIR" , str (PORTABLE_DIRECTORY )),
99
- ("SEVENZIP_EXE" , sevenzip_executable ),
95
+ ("SEVENZIP_EXE" , find_7zip_executable () ),
100
96
] + replacements
101
97
102
98
replace_lines_in_file (output_script_path , data_to_replace )
@@ -108,7 +104,7 @@ def build_installer_7zip(
108
104
subprocess .run (
109
105
command , shell = True , check = True , stderr = sys .stderr , stdout = sys .stderr
110
106
# with stdout=sys.stdout, we would not see 7zip compressing
111
- ) # Use subprocess.run for better error handling
107
+ )
112
108
except subprocess .CalledProcessError as e :
113
109
print (f"Error executing 7-Zip script: { e } " , file = sys .stderr )
114
110
@@ -516,19 +512,17 @@ def make_all(
516
512
docsdirs : str | list [Path ] = None ,
517
513
python_target_release : str = None , # e.g. "37101" for 3.7.10
518
514
):
519
- """Make WinPython distribution, for a given base directory and
520
- architecture:
515
+ """Make a WinPython distribution for a given set of parameters:
521
516
`build_number`: build number [int]
522
517
`release_level`: release level (e.g. 'beta1', '') [str]
523
518
`pyver`: python version ('3.4' or 3.5')
524
519
`architecture`: [int] (32 or 64)
525
- `basedir`: where will be created tmp_wheel and Winpython build
526
- r'D:\Winpython\b asedir34'.
527
- `requirements`: the package list for pip r'D:\r equirements.txt',
528
- `install_options`: pip options r'--no-index --pre --trusted-host=None',
529
- `find_links`: package directories r'D:\Winpython\packages.srcreq',
530
- `source_dirs`: the python.zip + rebuilt winpython wheel package directory,
531
- `toolsdirs`: r'D:\WinPython\b asedir34\t .Slim',
520
+ `basedir`: where to create the build (r'D:\Winpython\b asedir34')
521
+ `requirements`: package lists for pip (r'D:\r equirements.txt')
522
+ `install_options`: pip options (r'--no-index --pre --trusted-host=None')
523
+ `find_links`: package directories (r'D:\Winpython\packages.srcreq')
524
+ `source_dirs`: the python.zip + rebuilt winpython wheel package directory
525
+ `toolsdirs`: r'D:\WinPython\b asedir34\t .Slim'
532
526
`docsdirs`: r'D:\WinPython\b asedir34\docs.Slim'"""
533
527
534
528
assert basedir is not None , "The *basedir* directory must be specified"
@@ -587,9 +581,7 @@ def make_all(
587
581
588
582
589
583
if __name__ == "__main__" :
590
- # DO create only one version at a time
591
- # You may have to manually delete previous build\winpython-.. directory
592
-
584
+ # DO create only one Winpython distribution at a time
593
585
make_all (
594
586
build_number = 1 ,
595
587
release_level = "build3" ,
0 commit comments