From 719a36fdb3974919b0db66805f7318357bc1c6f7 Mon Sep 17 00:00:00 2001 From: stonebig Date: Thu, 13 Mar 2025 20:26:03 +0100 Subject: [PATCH] remove useless complexity: "working_directory" program generator --- make.py | 24 ------------------- ...directory_and_userprofile_be_winpython.bat | 3 +++ ...ake_working_directory_be_not_winpython.bat | 3 +++ .../make_working_directory_be_winpython.bat | 2 ++ 4 files changed, 8 insertions(+), 24 deletions(-) create mode 100644 portable/scripts/make_working_directory_and_userprofile_be_winpython.bat create mode 100644 portable/scripts/make_working_directory_be_not_winpython.bat create mode 100644 portable/scripts/make_working_directory_be_winpython.bat diff --git a/make.py b/make.py index 68bac141..f05f98b9 100644 --- a/make.py +++ b/make.py @@ -31,12 +31,6 @@ def find_7zip_executable() -> str: """ Locates the 7-Zip executable (7z.exe) in common installation directories. - - Raises: - RuntimeError: If 7-Zip executable is not found. - - Returns: - str: Path to the 7-Zip executable. """ program_files_dirs = [ Path(r"C:\Program Files"), @@ -116,11 +110,6 @@ def build_installer_7zip( def _copy_items(source_dirs: list[Path], target_dir: Path, verbose: bool = False): """ Copies items from source directories to the target directory. - - Args: - source_dirs: List of source directories to copy items from. - target_dir: Target directory to copy items to. - verbose: Enable verbose output. """ target_dir.mkdir(parents=True, exist_ok=True) for source_dir in source_dirs: @@ -538,19 +527,6 @@ def _create_standard_batch_scripts(self): if self.distribution and (Path(self.distribution.target) / r"lib-python\3\idlelib").is_dir(): batch_replacements.append((r"\Lib\idlelib", r"\lib-python\3\idlelib")) - for ini_patch_script in [ - ("make_working_directory_be_not_winpython.bat", "[active_environment", "[inactive_environment", "[inactive_environment_per_user]", "[active_environment_per_user]"), - ("make_working_directory_be_winpython.bat", "[active_environment", "[inactive_environment"), - ("make_working_directory_and_userprofile_be_winpython.bat", "[active_environment", "[inactive_environment", "[inactive_environment_common]", "[active_environment_common]") - ]: - name, patch1_start, patch1_end, *patch2 = ini_patch_script - content = f"""call "%~dp0env_for_icons.bat" -"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\\settings\winpython.ini', '{patch1_start}', '{patch1_end}' )" -""" - if patch2: - content += f""""%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\\settings\winpython.ini', '{patch2[0]}', '{patch2[1]}' )" """ - self.create_batch_script(name, content) - self._print_action_done() diff --git a/portable/scripts/make_working_directory_and_userprofile_be_winpython.bat b/portable/scripts/make_working_directory_and_userprofile_be_winpython.bat new file mode 100644 index 00000000..2806dc14 --- /dev/null +++ b/portable/scripts/make_working_directory_and_userprofile_be_winpython.bat @@ -0,0 +1,3 @@ +call "%~dp0env_for_icons.bat" +"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\settings\winpython.ini', '[active_environment', '[inactive_environment' )" +"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\settings\winpython.ini', '[inactive_environment_common]', '[active_environment_common]' )" \ No newline at end of file diff --git a/portable/scripts/make_working_directory_be_not_winpython.bat b/portable/scripts/make_working_directory_be_not_winpython.bat new file mode 100644 index 00000000..759de71d --- /dev/null +++ b/portable/scripts/make_working_directory_be_not_winpython.bat @@ -0,0 +1,3 @@ +call "%~dp0env_for_icons.bat" +"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\settings\winpython.ini', '[active_environment', '[inactive_environment' )" +"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\settings\winpython.ini', '[inactive_environment_per_user]', '[active_environment_per_user]' )" \ No newline at end of file diff --git a/portable/scripts/make_working_directory_be_winpython.bat b/portable/scripts/make_working_directory_be_winpython.bat new file mode 100644 index 00000000..bcdd3c45 --- /dev/null +++ b/portable/scripts/make_working_directory_be_winpython.bat @@ -0,0 +1,2 @@ +call "%~dp0env_for_icons.bat" +"%PYTHON%" -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%~dp0..\settings\winpython.ini', '[active_environment', '[inactive_environment' )"