4
4
# Copyright © 2012 Pierre Raybaut
5
5
# Copyright © 2014-2025+ The Winpython development team https://github.com/winpython/
6
6
# Licensed under the terms of the MIT License
7
- # (see winpython /__init__.py for details)
7
+ # (see wppm /__init__.py for details)
8
8
9
9
import os
10
10
import re
@@ -40,27 +40,27 @@ def parse_list_argument(argument_value: str | list[str], separator=" ") -> list[
40
40
class WinPythonDistributionBuilder :
41
41
"""Builds a WinPython distribution."""
42
42
43
- def __init__ (self , build_number : int , release_level : str , target_directory : Path , wheels_directory : Path ,
44
- tools_directories : list [Path ] = None , verbose : bool = False ,
45
- flavor : str = "" ):
43
+ def __init__ (self , build_number : int , release_level : str , basedir_wpy : Path ,
44
+ source_dirs : Path , tools_directories : list [Path ] = None ,
45
+ verbose : bool = False , flavor : str = "" ):
46
46
"""
47
47
Initializes the WinPythonDistributionBuilder.
48
48
Args:
49
49
build_number: The build number (integer).
50
50
release_level: The release level (e.g., "beta", "").
51
- target_directory: The base directory below which WinPython will be created.
52
- wheels_directory : Directory containing wheel files for packages.
51
+ basedir_wpy: top directory of the build (c:\...\Wpy...)
52
+ source_dirs : Directory containing wheel files for packages.
53
53
tools_directories: List of directories containing development tools to include.
54
54
verbose: Enable verbose output.
55
55
flavor: WinPython flavor (e.g., "Barebone").
56
56
"""
57
57
self .build_number = build_number
58
58
self .release_level = release_level
59
- self .target_directory = Path (target_directory )
60
- self .wheels_directory = Path (wheels_directory )
59
+ self .winpython_directory = Path (basedir_wpy )
60
+ self .target_directory = self .winpython_directory .parent
61
+ self .source_dirs = Path (source_dirs )
61
62
self .tools_directories = tools_directories or []
62
63
self .verbose = verbose
63
- self .winpython_directory : Path | None = None
64
64
self .distribution : wppm .Distribution | None = None
65
65
self .flavor = flavor
66
66
self .python_zip_file : Path = self ._get_python_zip_file ()
@@ -69,10 +69,10 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
69
69
70
70
def _get_python_zip_file (self ) -> Path :
71
71
"""Finds the Python .zip file in the wheels directory."""
72
- for source_item in self .wheels_directory .iterdir ():
72
+ for source_item in self .source_dirs .iterdir ():
73
73
if re .match (r"(pypy3|python-).*\.zip" , source_item .name ):
74
74
return source_item
75
- raise RuntimeError (f"Could not find Python zip package in { self .wheels_directory } " )
75
+ raise RuntimeError (f"Could not find Python zip package in { self .source_dirs } " )
76
76
77
77
@property
78
78
def winpython_version_name (self ) -> str :
@@ -108,7 +108,6 @@ def _copy_essential_files(self):
108
108
109
109
def _create_env_config (self ):
110
110
"""Creates environment setup"""
111
- self ._print_action ("Creating env.ini environment setup" )
112
111
executable_name = self .distribution .short_exe if self .distribution else "python.exe"
113
112
config = {
114
113
"WINPYthon_exe" : executable_name ,
@@ -123,10 +122,9 @@ def _create_env_config(self):
123
122
self ._print_action (f"Creating env.ini environment { env_path } " )
124
123
env_path .write_text ("\n " .join (f"{ k } ={ v } " for k , v in config .items ()))
125
124
126
- def build (self , winpy_dir : Path = None ):
125
+ def build (self ):
127
126
"""Make or finalise WinPython distribution in the target directory"""
128
127
print (f"Building WinPython with Python archive: { self .python_zip_file .name } " )
129
- self .winpython_directory = Path (winpy_dir )
130
128
self ._print_action (f"Creating WinPython { self .winpython_directory } base directory" )
131
129
if self .winpython_directory .is_dir () and len (self .winpython_directory .parts )>= 4 :
132
130
shutil .rmtree (self .winpython_directory )
@@ -139,10 +137,8 @@ def build(self, winpy_dir: Path = None):
139
137
self ._create_env_config ()
140
138
141
139
def make_all (build_number : int , release_level : str , basedir_wpy : Path = None ,
142
- verbose : bool = False ,
143
- flavor : str = "" ,
144
140
source_dirs : Path = None , toolsdirs : str | list [Path ] = None ,
145
- ):
141
+ verbose : bool = False , flavor : str = "" ):
146
142
"""
147
143
Make a WinPython distribution for a given set of parameters:
148
144
Args:
@@ -157,16 +153,14 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
157
153
assert basedir_wpy is not None , "The *winpython_dirname* directory must be specified"
158
154
159
155
tools_directories = [Path (d ) for d in parse_list_argument (toolsdirs , "," )]
160
- winpy_dir = Path (basedir_wpy )
161
- utils .print_box (f"Making WinPython at { winpy_dir } " )
162
- os .makedirs (winpy_dir , exist_ok = True )
156
+ utils .print_box (f"Making WinPython at { basedir_wpy } " )
157
+ os .makedirs (basedir_wpy , exist_ok = True )
163
158
164
159
builder = WinPythonDistributionBuilder (
165
- build_number , release_level , winpy_dir .parent , wheels_directory = source_dirs ,
166
- tools_directories = tools_directories ,
167
- verbose = verbose , flavor = flavor
168
- )
169
- builder .build (winpy_dir )
160
+ build_number , release_level , Path (basedir_wpy ),
161
+ verbose = verbose , flavor = flavor ,
162
+ source_dirs = source_dirs , tools_directories = tools_directories )
163
+ builder .build ()
170
164
171
165
if __name__ == "__main__" :
172
166
make_all (
0 commit comments