8000 Merge pull request #1539 from stonebig/master · winpython/winpython@7d839c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d839c2

Browse files
authored
Merge pull request #1539 from stonebig/master
remove no more used functions
2 parents 2b01d20 + 57f7007 commit 7d839c2

File tree

1 file changed

+6
-59
lines changed

1 file changed

+6
-59
lines changed

winpython/wppm.py

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,6 @@ def remove_directory(self, path: str):
6464
except OSError:
6565
self.to_be_removed.append(path)
6666

67-
def copy_files(self, package: Package, targetdir: str, srcdir: str, dstdir: str, create_bat_files: bool = False):
68-
"""Copy files from srcdir to dstdir within the target distribution."""
69-
srcdir = str(Path(targetdir) / srcdir)
70-
if not Path(srcdir).is_dir():
71-
return
72-
offset = len(srcdir) + len(os.pathsep)
73-
for dirpath, dirnames, filenames in os.walk(srcdir):
74-
for dname in dirnames:
75-
t_dname = str(Path(dirpath) / dname)[offset:]
76-
src = str(Path(srcdir) / t_dname)
77-
dst = str(Path(dstdir) / t_dname)
78-
if self.verbose:
79-
print(f"mkdir: {dst}")
80-
full_dst = str(Path(self.target) / dst)
81-
if not Path(full_dst).exists():
82-
os.mkdir(full_dst)
83-
package.files.append(dst)
84-
for fname in filenames:
85-
t_fname = str(Path(dirpath) / fname)[offset:]
86-
src = str(Path(srcdir) / t_fname)
87-
dst = fname if dirpath.endswith("_system32") else str(Path(dstdir) / t_fname)
88-
if self.verbose:
89-
print(f"file: {dst}")
90-
full_dst = str(Path(self.target) / dst)
91-
shutil.move(src, full_dst)
92-
package.files.append(dst)
93-
name, ext = Path(dst).stem, Path(dst).suffix
94-
if create_bat_files and ext in ("", ".py"):
95-
dst = name + ".bat"
96-
if self.verbose:
97-
print(f"file: {dst}")
98-
full_dst = str(Path(self.target) / dst)
99-
fd = open(full_dst, "w")
100-
fd.write(f"""@echo off\npython "%~dpn0{ext}" %*""")
101-
fd.close()
102-
package.files.append(dst)
103-
10467
def create_file(self, package, name, dstdir, contents):
10568
"""Generate data file -- path is relative to distribution root dir"""
10669
dst = str(Path(dstdir) / name)
@@ -157,8 +120,8 @@ def install(self, package: Package, install_options: list[str] = None): # Type h
157120
# minimal post-install actions
158121
self.patch_standard_packages(package.name)
159122

160-
def do_pip_action(self, actions=None, install_options=None):
161-
"""Do pip action in a distribution"""
123+
def do_pip_action(self, actions: list[str] = None, install_options: list[str] = None):
124+
"""Execute pip action in the distribution."""
162125
my_list = install_options or []
163126
my_actions = actions or []
164127
executing = str(Path(self.target).parent / "scripts" / "env.bat")
@@ -169,10 +132,12 @@ def do_pip_action(self, actions=None, install_options=None):
169132
complement = ["-m", "pip"]
170133
try:
171134
fname = utils.do_script(this_script=None, python_exe=executing, verbose=self.verbose, install_options=complement + my_actions + my_list)
172-
except RuntimeError:
135+
except RuntimeError as e:
173136
if not self.verbose:
174137
print("Failed!")
175138
raise
139+
else:
140+
print(f"Pip action failed with error: {e}") # Print error if verbose
176141

177142
def patch_standard_packages(self, package_name="", to_movable=True):
178143
"""patch Winpython packages in need"""
@@ -256,7 +221,6 @@ def create_pybat(self, names="", contents=r"""@echo off
256221
):
257222
with open(scriptpy / (name + ".bat"), "w") as fd:
258223
fd.write(contents)
259-
fd.close()
260224

261225
def handle_specific_packages(self, package):
262226
"""Packages requiring additional configuration"""
@@ -302,7 +266,7 @@ def _print_done(self):
302266
def uninstall(self, package):
303267
"""Uninstall package from distribution"""
304268
self._print(package, "Uninstalling")
305-
if not package.name == "pip":
269+
if package.name != "pip":
306270
# trick to get true target (if not current)
307271
this_exec = utils.get_python_executable(self.target) # PyPy !
308272
subprocess.call([this_exec, "-m", "pip", "uninstall", package.name, "-y"], cwd=self.target)
@@ -327,23 +291,6 @@ def install_bdist_direct(self, package, install_options=None):
327291
self._print_done()
328292

329293

330-
def install_script(self, script: str, install_options: list[str] = None): # Type hint install_options
331-
"""Install a script using pip."""
332-
try:
333-
fname = utils.do_script(
334-
script,
335-
python_exe=utils.get_python_executable(self.target), # PyPy3 !
336-
verbose=self.verbose,
337-
install_options=install_options,
338-
)
339-
except RuntimeError as e: # Catch specific RuntimeError
340-
if not self.verbose:
341-
print("Failed!")
342-
raise # Re-raise if not verbose
343-
else:
344-
print(f"Script installation failed: {e}") # Print error if verbose
345-
346-
347294
def main(test=False):
348295
if test:
349296
sbdir = str(Path(__file__).parents[0].parent.parent.parent / "sandbox")

0 commit comments

Comments
 (0)
0