@@ -189,7 +189,7 @@ def __init__(
189
189
self .flavor = flavor
190
190
self .python_zip_file : Path = self ._get_python_zip_file ()
191
191
self .python_name = self .python_zip_file .stem # Filename without extension
192
- self .python_dir_name = "python" # Standardized Python directory name
192
+ self .python_directory_name = "python" # Standardized Python directory name
193
193
194
194
def _get_python_zip_file (self ) -> Path :
195
195
"""Finds the Python .zip file in the wheels directory."""
@@ -241,8 +241,8 @@ def _get_installed_tools_markdown(self) -> str:
241
241
"""Generates Markdown for installed tools section in package index."""
242
242
installed_tools = []
243
243
244
- def get_tool_path (rel_path ):
245
- path = self .winpython_directory / rel_path if self .winpython_directory else None
244
+ def get_tool_path (relative_path ):
245
+ path = self .winpython_directory / relative_path if self .winpython_directory else None
246
246
return path if path and (path .is_file () or path .is_dir ()) else None
247
247
248
248
nodejs_path = get_tool_path (self .NODEJS_RELATIVE_PATH )
@@ -272,7 +272,7 @@ def get_tool_path(rel_path):
272
272
def _get_installed_packages_markdown (self ) -> str :
273
273
"""Generates Markdown for installed packages section in package index."""
274
274
if self .distribution is None :
275
- return "" # Distribution not initialized yet.
275
+ return "" # Distribution not initialized yet.
276
276
self .installed_packages = self .distribution .get_installed_packages (update = True )
277
277
package_lines = [
278
278
f"[{ pkg .name } ]({ pkg .url } ) | { pkg .version } | { pkg .description } "
@@ -296,14 +296,14 @@ def python_full_version(self) -> str:
296
296
return utils .get_python_long_version (self .distribution .target )
297
297
298
298
@property
299
- def python_executable_dir (self ) -> str :
299
+ def python_executable_directory (self ) -> str :
300
300
"""Returns the directory containing the Python executable."""
301
- python_path_dir = self .winpython_directory / self .python_dir_name if self .winpython_directory else None
302
- if python_path_dir and python_path_dir .is_dir ():
303
- return str (python_path_dir )
301
+ python_path_directory = self .winpython_directory / self .python_directory_name if self .winpython_directory else None
302
+ if python_path_directory and python_path_directory .is_dir ():
303
+ return str (python_path_directory )
304
304
else :
305
- python_path_exe = self .winpython_directory / self .python_name if self .winpython_directory else None # Fallback for older structure
306
- return str (python_path_exe ) if python_path_exe else ""
305
+ python_path_executable = self .winpython_directory / self .python_name if self .winpython_directory else None # Fallback for older structure
306
+ return str (python_path_executable ) if python_path_executable else ""
307
307
308
308
@property
309
309
def architecture_bits (self ) -> int :
@@ -325,11 +325,11 @@ def pre_path_entries(self) -> list[str]:
325
325
]
326
326
327
327
@property
328
- def docs_directories (self ) -> list [Path ]:
328
+ def documentation_directories_list (self ) -> list [Path ]:
329
329
"""Returns the list of documentation directories to include."""
330
- default_docs_dir = Path (__file__ ).resolve ().parent / "docs"
331
- if default_docs_dir .is_dir ():
332
- return [default_docs_dir ] + self .documentation_directories
330
+ default_docs_directory = Path (__file__ ).resolve ().parent / "docs"
331
+ if default_docs_directory .is_dir ():
332
+ return [default_docs_directory ] + self .documentation_directories
333
333
return self .documentation_directories
334
334
335
335
def create_batch_script (self , name : str , contents : str , replacements : list [tuple [str , str ]] = None ):
@@ -341,21 +341,20 @@ def create_batch_script(self, name: str, contents: str, replacements: list[tuple
341
341
contents: The contents of the batch script.
342
342
replacements: A list of tuples for text replacements in the content.
343
343
"""
344
- script_dir = self .winpython_directory / "scripts" if self .winpython_directory else None
345
- if not script_dir :
344
+ script_directory = self .winpython_directory / "scripts" if self .winpython_directory else None
345
+ if not script_directory :
346
346
print ("Warning: WinPython directory not set, cannot create batch script." )
347
347
return
348
- script_dir .mkdir (parents = True , exist_ok = True )
348
+ script_directory .mkdir (parents = True , exist_ok = True )
349
349
final_contents = contents
350
350
if replacements :
351
351
for old_text , new_text in replacements :
352
352
final_contents = final_contents .replace (old_text , new_text )
353
- script_path = script_dir / name
353
+ script_path = script_directory / name
354
354
with open (script_path , "w" ) as f :
355
355
f .write (final_contents )
356
356
print (f"Created batch script: { script_path } " )
357
357
358
-
359
358
def create_installer_7zip (self , installer_type : str = ".exe" ):
360
359
"""
361
360
Creates a WinPython installer using 7-Zip.
@@ -399,63 +398,63 @@ def _extract_python_archive(self):
399
398
targetdir = str (self .winpython_directory ), # Extract directly to winpython_directory
400
399
)
401
400
# Relocate to /python subfolder if needed (for newer structure) #2024-12-22 to /python
402
- python_target_dir = self .winpython_directory / self .python_dir_name
403
- if self .python_dir_name != self .python_name and not python_target_dir .is_dir ():
404
- os .rename (self .winpython_directory / self .python_name , python_target_dir )
401
+ expected_python_directory = self .winpython_directory / self .python_directory_name
402
+ if self .python_directory_name != self .python_name and not expected_python_directory .is_dir ():
403
+ os .rename (self .winpython_directory / self .python_name , expected_python_directory )
405
404
406
405
def _copy_tools (self ):
407
406
"""Copies development tools to the WinPython 't' directory."""
408
- tools_target_dir = self .winpython_directory / "t"
409
- self ._print_action (f"Copying tools to { tools_target_dir } " )
410
- _copy_items (self .tools_directories , tools_target_dir , self .verbose )
407
+ tools_target_directory = self .winpython_directory / "t"
408
+ self ._print_action (f"Copying tools to { tools_target_directory } " )
409
+ _copy_items (self .tools_directories , tools_target_directory , self .verbose )
411
410
412
411
# Special handling for Node.js to move it up one level
413
- nodejs_current_dir = tools_target_dir / "n"
414
- nodejs_target_dir = self .winpython_directory / self .NODEJS_RELATIVE_PATH
415
- if nodejs_current_dir != nodejs_target_dir and nodejs_current_dir .is_dir ():
412
+ nodejs_current_directory = tools_target_directory / "n"
413
+ nodejs_target_directory = self .winpython_directory / self .NODEJS_RELATIVE_PATH
414
+ if nodejs_current_directory != nodejs_target_directory and nodejs_current_directory .is_dir ():
416
415
try :
417
- shutil .move (nodejs_current_dir , nodejs_target_dir )
416
+ shutil .move (nodejs_current_directory , nodejs_target_directory )
418
417
except Exception as e :
419
418
print (f"Error moving Node.js directory: { e } " )
420
419
421
420
def _copy_documentation (self ):
422
421
"""Copies documentation files to the WinPython 'docs' directory."""
423
- docs_target_dir = self .winpython_directory / "notebooks" / "docs"
424
- self ._print_action (f"Copying documentation to { docs_target_dir } " )
425
- _copy_items (self .docs_directories , docs_target_dir , self .verbose )
426
-
422
+ docs_target_directory = self .winpython_directory / "notebooks" / "docs"
423
+ self ._print_action (f"Copying documentation to { docs_target_directory } " )
424
+ _copy_items (self .documentation_directories_list , docs_target_directory , self .verbose )
425
+
427
426
def _copy_launchers (self ):
428
427
"""Copies pre-made launchers to the WinPython directory."""
429
428
self ._print_action ("Creating launchers" )
430
429
_copy_items ([PORTABLE_DIRECTORY / "launchers_final" ], self .winpython_directory , self .verbose )
431
430
432
431
def _copy_default_scripts (self ):
433
- """Copies launchers and defeult scripts."""
432
+ """Copies launchers and default scripts."""
434
433
self ._print_action ("copying pre-made scripts" )
435
434
_copy_items ([PORTABLE_DIRECTORY / "scripts" ], self .winpython_directory / "scripts" , self .verbose )
436
-
435
+
437
436
def _create_initial_batch_scripts (self ):
438
437
"""Creates initial batch scripts, including environment setup."""
439
438
self ._print_action ("Creating initial batch scripts" )
440
439
441
- path_entries_str = ";" .join ([rf"%WINPYDIR%\{ pth } " for pth in self .pre_path_entries ])
442
- full_path_env_var = f"{ path_entries_str } ;%PATH%"
440
+ path_entries_string = ";" .join ([rf"%WINPYDIR%\{ path } " for path in self .pre_path_entries ])
441
+ full_path_environment_variable = f"{ path_entries_string } ;%PATH%"
443
442
444
- path_entries_ps_str = ";" .join ([rf"$env:WINPYDIR\\{ pth } " for pth in self .pre_path_entries ])
445
- full_path_ps_env_var = f"{ path_entries_ps_str } ;$env:path"
443
+ path_entries_powershell_string = ";" .join ([rf"$env:WINPYDIR\\{ path } " for path in self .pre_path_entries ])
444
+ full_path_powershell_environment_variable = f"{ path_entries_powershell_string } ;$env:path"
446
445
447
446
# Replacements for batch scripts (PyPy compatibility)
448
- exe_name = self .distribution .short_exe if self .distribution else "python.exe" # default to python.exe if distribution is not yet set
447
+ executable_name = self .distribution .short_exe if self .distribution else "python.exe" # default to python.exe if distribution is not yet set
449
448
450
449
destination = self .winpython_directory / "scripts"
451
- for specials in ('env.bat' , 'WinPython_PS_Prompt.ps1' ):
452
- destspe = str (destination / specials )
453
- print ('destspe :' , destspe )
454
- utils .patch_sourcefile (destspe , '{self.python_dir_name} ' , self . python_dir_name )
455
- utils .patch_sourcefile (destspe , '{self.winpython_version_name }' , self .winpython_version_name )
456
- utils .patch_sourcefile (destspe , '{full_path_env_var }' , full_path_env_var )
457
- utils .patch_sourcefile (destspe , '{full_path_ps_env_var }' , full_path_ps_env_var )
458
-
450
+ for script_name in ('env.bat' , 'WinPython_PS_Prompt.ps1' ):
451
+ destination_script_path = str (destination / script_name )
452
+ print ('destination_script_path :' , destination_script_path )
453
+ utils .patch_sourcefile (destination_script_path , 'python.exe ' , executable_name )
454
+ utils .patch_sourcefile (destination_script_path , '{self.python_dir_name }' , self .python_directory_name )
455
+ utils .patch_sourcefile (destination_script_path , '{self.winpython_version_name }' , self . winpython_version_name )
456
+ utils .patch_sourcefile (destination_script_path , '{full_path_env_var }' , full_path_environment_variable )
457
+ utils . patch_sourcefile ( destination_script_path , '{full_path_ps_env_var}' , full_path_powershell_environment_variable )
459
458
460
459
def build (self , rebuild : bool = True , requirements = None , winpy_dirname : str = None ):
461
460
"""Make WinPython distribution in target directory from the installers
@@ -485,7 +484,7 @@ def build(self, rebuild: bool = True, requirements=None, winpy_dirname: str = No
485
484
self ._extract_python_archive ()
486
485
487
486
self .distribution = wppm .Distribution (
488
- self .python_executable_dir ,
487
+ self .python_executable_directory ,
489
488
verbose = self .verbose ,
490
489
indent = True ,
491
490
)
@@ -528,11 +527,11 @@ def build(self, rebuild: bool = True, requirements=None, winpy_dirname: str = No
528
527
self ._print_action ("Writing package index" )
529
528
# winpyver2 = the version without build part but with self.distribution.architecture
530
529
self .winpyver2 = f"{ self .python_full_version } .{ self .build_number } "
531
- fname = str (self .winpython_directory .parent / f"WinPython{ self .flavor } -{ self .distribution .architecture } bit-{ self .winpyver2 } .md" )
532
- open (fname , "w" , encoding = 'utf-8' ).write (self .package_index_markdown )
530
+ output_markdown_filename = str (self .winpython_directory .parent / f"WinPython{ self .flavor } -{ self .distribution .architecture } bit-{ self .winpyver2 } .md" )
531
+ open (output_markdown_filename , "w" , encoding = 'utf-8' ).write (self .package_index_markdown )
533
532
534
533
# Copy to winpython/changelogs
535
- shutil .copyfile (fname , str (Path (CHANGELOGS_DIRECTORY ) / Path (fname ).name ))
534
+ shutil .copyfile (output_markdown_filename , str (Path (CHANGELOGS_DIRECTORY ) / Path (output_markdown_filename ).name ))
536
535
537
536
# Writing changelog
538
537
self ._print_action ("Writing changelog" )
@@ -594,22 +593,22 @@ def make_all(
594
593
docs_dirs_list = _parse_list_argument (docsdirs , "," )
595
594
install_options_list = _parse_list_argument (install_options , " " )
596
595
find_links_dirs_list = _parse_list_argument (find_links , "," )
597
- requirements_files_list = [Path (f ) for f in _parse_list_argument (requirements , "," ) if f ] # ensure Path objects
596
+ requirements_files_list = [Path (f ) for f in _parse_list_argument (requirements , "," ) if f ] # ensure Path objects
598
597
find_links_options = [f"--find-links={ link } " for link in find_links_dirs_list + [source_dirs ]]
599
- builddir = str (Path (basedir ) / ("bu" + flavor ))
598
+ build_directory = str (Path (basedir ) / ("bu" + flavor ))
600
599
601
600
if rebuild :
602
601
# Rebuild Winpython Wheel Package
603
602
utils .print_box (f"Making WinPython { architecture } bits at { Path (basedir ) / ('bu' + flavor )} " )
604
- os .makedirs (Path (builddir ), exist_ok = True )
603
+ os .makedirs (Path (build_directory ), exist_ok = True )
605
604
# use source_dirs as the directory to re-build Winpython wheel
606
605
winpython_source_dir = Path (__file__ ).resolve ().parent
607
606
rebuild_winpython_package (winpython_source_dir , source_dirs , architecture , verbose )
608
607
609
608
builder = WinPythonDistributionBuilder (
610
609
build_number ,
611
610
release_level ,
612
- builddir ,
611
+ build_directory ,
613
612
wheels_directory = source_dirs ,
614
613
tools_directories = [Path (d ) for d in tools_dirs_list ],
615
614
documentation_directories = [Path (d ) for d in docs_dirs_list ],
0 commit comments